]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
x86/cpu: Allow reducing x86_phys_bits during early_identify_cpu()
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 31 Jan 2024 23:09:01 +0000 (00:09 +0100)
committerDave Hansen <dave.hansen@linux.intel.com>
Mon, 26 Feb 2024 16:16:15 +0000 (08:16 -0800)
commit9a458198eba98b7207669a166e64d04b04cb651b
treea574aa3c85eb923df636bd96dc6f4b857624cee3
parent43fb862de8f628c5db5e96831c915b9aebf62d33
x86/cpu: Allow reducing x86_phys_bits during early_identify_cpu()

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")
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc:stable@vger.kernel.org
Link: https://lore.kernel.org/all/20240131230902.1867092-2-pbonzini%40redhat.com
arch/x86/kernel/cpu/common.c