From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1445BCD4933 for ; Wed, 20 Sep 2023 22:54:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229611AbjITWyd (ORCPT ); Wed, 20 Sep 2023 18:54:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbjITWyb (ORCPT ); Wed, 20 Sep 2023 18:54:31 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E2DFAB for ; Wed, 20 Sep 2023 15:54:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695250466; x=1726786466; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=rsUGUNTImlteVNQfnPuQwMwdTYicAuHzhtIdJ1lBzd4=; b=Xe+nLhIPxojw75rWP1oaddCNRt6CNrLxtkJVclcLfrpW2/j7mH69t4+d gnj26cD0PtjuoPQa84nmzZwgrzwE7NEZcenxK+jKg3seMlJYosO5A/j9+ 2b46+vV1NPvfAIqIhEh63a5vJVL6Ig/p+ixlo9h01TTm5kvx6U+PJJ832 tXYQJcPQGYeH8CZn3ImFtjSxgn4wB/EGJKPEpbRv+EWxAKwykmOsUtk3c 7d/ko1BOEGJdcRZ/l7zvWsRpHK/T29N5HZL9ILoqfL5DOCXjJdy8wRuIs hjwVXQhToqTbYzW0ZVGpwgWG2rtTzeNs8RGFQ3VvVL4F20CLvA/twFxJS g==; X-IronPort-AV: E=McAfee;i="6600,9927,10839"; a="380273940" X-IronPort-AV: E=Sophos;i="6.03,162,1694761200"; d="scan'208";a="380273940" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2023 15:54:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10839"; a="870556288" X-IronPort-AV: E=Sophos;i="6.03,162,1694761200"; d="scan'208";a="870556288" Received: from sindhu5-mobl1.amr.corp.intel.com (HELO [10.209.4.149]) ([10.209.4.149]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2023 15:54:14 -0700 Message-ID: <519a5116-a48a-61f9-9a93-d30d21eb7e75@intel.com> Date: Wed, 20 Sep 2023 15:54:14 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v2 1/2] x86/sev-es: Allow copy_from_kernel_nofault in earlier boot Content-Language: en-US To: Sean Christopherson , Adam Dunlap Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Kim Phillips , Juergen Gross , Ashok Raj , Joerg Roedel , Tom Lendacky , David Hildenbrand , Mike Rapoport , "Kirill A. Shutemov" , Nikunj A Dadhania , Dionna Glaze , Peter Gonda , David Rientjes , Khalid ElMously , Jacob Xu References: <20230912002703.3924521-1-acdunlap@google.com> <20230912002703.3924521-2-acdunlap@google.com> From: Dave Hansen In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/20/23 13:37, Sean Christopherson wrote: > On Mon, Sep 11, 2023, Adam Dunlap wrote: >> Previously, if copy_from_kernel_nofault was called before >> boot_cpu_data.x86_virt_bits was set up, then it would trigger undefined >> behavior due to a shift by 64. This ended up causing boot failures in >> the latest version of ubuntu2204 in the gcp project when using SEV-SNP. >> Specifically, this function is called during an early #VC handler which >> is triggered by a cpuid to check if nx is implemented. > Why not stuff boot_cpu_data.x86_virt_bits to a "default" value that is guaranteed > to be accurate (or at least safe) for the purposes of the early boot code. I.e. > set it to 48 for 64-bit kernels. > > That'd avoid the extra conditional, and would avoid laying whack-a-mole with > anything else that consumes x86_virt_bits. I'd be worried that could break things even more subtly. If we're truly worried about whack-a-mole, we should stick 'x86_virt_bits' in a wrapper, whine if it's accessed inadvertently, and *then* return some mostly sane data. That way we can actually go look at the caller and see what the heck it's doing. I did poke around and managed to convince myself that this site _is_ the only one at the moment.