Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp222817rdb; Thu, 1 Feb 2024 06:55:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGq9wvs/F1yHVyMD3a5wG+0nyA8GpHHjVMzxtN2CsOk2zk4lqhREEdK4gWSrdgLAPSVjPLb X-Received: by 2002:ac8:5b8c:0:b0:42a:3ca8:910f with SMTP id a12-20020ac85b8c000000b0042a3ca8910fmr5721387qta.39.1706799343950; Thu, 01 Feb 2024 06:55:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706799343; cv=pass; d=google.com; s=arc-20160816; b=0JQNLqFQJSNx2HBpLIE9oFW1E7PlCVTtqwpcKT647iBSWYywV+UFgBQVryH6ih7Hx+ 9PL17FbNbYNN0RwPn4S6NtXLw8OwaoQylxGY89qQgLYCYKq1QV7qOSIgyBv79Aehgnwg n9kk2fweCyXQEFPVZfmi8x5den5jWiC6HgrgZZBNzIAKTv5QmfuVrDjVPX648AlANmaf cNH94bdwB17UGNPdTy9hG7v1Qhc8tOZJnDmE1trv2ZDYYyMrY9VhtWNvyCmYzwUEnplH T6lQShOB6sufWAyGC7A1Hj8OtI7to7RK5bi3XUvEqazyjIZ7zf2JKY64x6j7nMDAD9eY ouiQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=migrItR4aEXnsyDZ7wmy445W5OSSYtGtY/VhLnIVGsI=; fh=ZhE/sAduOOur/mlXKTBv1ApU5Yh9So1YT3YttOTzDbM=; b=Qrl2Gx+B9+Mwd8zb2Fd+CvFQ3svrNH9IqThVQVPt2BFVwL++Hmfrc/NVqnHE18GCSb ntc33HPSQt1j3fJaUk++wif1+dV1cM6WNg6Su5HuUNWl8R6sUgMUyLKHnNcChWWqryFq q5oevdioaJbjDR550JU15sIGRZU+qqPorI/C6mNHI3jdijim5nGO1RwSDDSJQbmAbGp3 sbRjLPoO3GkTlivBaR5DBpp9ADShbtPoudzOn7WSBJl4pjkEBtETt4TqWRB+Yp4MDkUn skV+2plrIdfGLqaFCJcwogEt4eBfFj7+0MaTP6glIZXzJWNfGAsstxfDgPpuSOYKNZBJ MFCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jgnklMa2; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-47791-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47791-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCU3SKxiR0cNwcVhd1B+YRkIbx9mVLv2/dm8irFnfAX81w/7UBWdC+IXMnKGzdHGRNCdoWeApn1KS/5QWsi4lj83HDb1EfmJfQ263CE25w== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c8-20020ac87dc8000000b0042bf9849fc8si691844qte.31.2024.02.01.06.55.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 06:55:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47791-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jgnklMa2; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-47791-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47791-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 18D381C22196 for ; Thu, 1 Feb 2024 08:41:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 54A6815AAAB; Thu, 1 Feb 2024 08:41:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jgnklMa2" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D91A52E3FE; Thu, 1 Feb 2024 08:41:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.55.52.115 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706776905; cv=none; b=Fm2XbmSKBP5CQU0RdizUe4rRpLfO1PdlwvYUbBBN2zJpbIOn1n+CH9dXZCXNB+DmjIsPF+kc1RG7zD1Cjp+M3O18d1O/zV4OQr4q2j7eOBTEF/9lqRVzjOjz3Iop4UWVVpinip7DQEqhENXFR5uk6avS76e9rV0CdKu+6TOQHR4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706776905; c=relaxed/simple; bh=VTaH4OKD+0kQFzbSZV77olKsxgKVO4SzwSYHx1uKUlQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HRyQ/OMsjdLduDZcvH8KNSuCEGjIX7QHJPAj1QoWCh/SesPwbzascxbAnXqXd1o5+s9hkHGxeJkoA3f4HjA06nTwTF8xhmsjAaKs+50SS1fVFteOSKzXqagrUmgVoPbGmY9AWBQjkCfqR/RMu4K1ZC9AOnLy1nKa7TZSNwSPTpA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=jgnklMa2; arc=none smtp.client-ip=192.55.52.115 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706776903; x=1738312903; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=VTaH4OKD+0kQFzbSZV77olKsxgKVO4SzwSYHx1uKUlQ=; b=jgnklMa2AYkv0SLg+wedUt9MYG5O3nME/8tdi3C9USx9F/UCSnULR7aR X2s+Xv+zaPAm8n7+l7I5jGhdhDBxR2fTZqaqABipejFNnpiLsbNmbCGfX G8PgIKWST+dYyzDYuYRfTRU3qkzlTObj2fruzNi4JHHijMP+VCEr5ZZIr gAtOAnjUAeWGKrbY/womhz8T77f22A/45zdikZ03CI8fewwUL2NK7iygp AWC8h6P6mIg2laD9DjX1Ei4FXBlPlL8W6jw0zR34g/zZJ8xed30PCWVkY 2SOuqvB9JTrPJzJKsTo4k9yvLTOTIHcw0dLFqr1rjyYxY6Eq97/nVS8Ku g==; X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="403457233" X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="403457233" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2024 00:41:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="879052024" X-IronPort-AV: E=Sophos;i="6.05,234,1701158400"; d="scan'208";a="879052024" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 01 Feb 2024 00:41:40 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 49F0E789; Thu, 1 Feb 2024 10:33:55 +0200 (EET) Date: Thu, 1 Feb 2024 10:33:55 +0200 From: "Kirill A . Shutemov" To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Zixi Chen , Adam Dunlap , Xiaoyao Li , Kai Huang , Dave Hansen , Thomas Gleixner , Ingo Molnar , x86@kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2 1/2] x86/cpu: allow reducing x86_phys_bits during early_identify_cpu() Message-ID: References: <20240131230902.1867092-1-pbonzini@redhat.com> <20240131230902.1867092-2-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240131230902.1867092-2-pbonzini@redhat.com> On Thu, Feb 01, 2024 at 12:09:01AM +0100, Paolo Bonzini wrote: > In commit fbf6449f84bf ("x86/sev-es: Set x86_virt_bits to the correct > value straight away, instead of a two-phase approach"), the initialization > of c->x86_phys_bits was moved after this_cpu->c_early_init(c). This is > incorrect because early_init_amd() expected to be able to reduce the > value according to the contents of CPUID leaf 0x8000001f. > > Fortunately, the bug was negated by init_amd()'s call to early_init_amd(), > which does reduce x86_phys_bits in the end. However, this is very > late in the boot process and, most notably, the wrong value is used for > x86_phys_bits when setting up MTRRs. > > To fix this, call get_cpu_address_sizes() as soon as X86_FEATURE_CPUID is > set/cleared, and c->extended_cpuid_level is retrieved. > > Fixes: fbf6449f84bf ("x86/sev-es: Set x86_virt_bits to the correct value straight away, instead of a two-phase approach") > Cc: Adam Dunlap > Cc: Kirill A. Shutemov > Cc: Xiaoyao Li > Cc: Kai Huang > Cc: Dave Hansen > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: x86@kernel.org > Cc: stable@vger.kernel.org > Signed-off-by: Paolo Bonzini Reviewed-by: Kirill A. Shutemov -- Kiryl Shutsemau / Kirill A. Shutemov