Skip to content

Commit 9a45819

Browse files
bonzinihansendc
authored andcommitted
x86/cpu: Allow reducing x86_phys_bits during early_identify_cpu()
In commit fbf6449 ("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: fbf6449 ("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
1 parent 43fb862 commit 9a45819

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/kernel/cpu/common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,7 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
15891589
get_cpu_vendor(c);
15901590
get_cpu_cap(c);
15911591
setup_force_cpu_cap(X86_FEATURE_CPUID);
1592+
get_cpu_address_sizes(c);
15921593
cpu_parse_early_param();
15931594

15941595
if (this_cpu->c_early_init)
@@ -1601,10 +1602,9 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
16011602
this_cpu->c_bsp_init(c);
16021603
} else {
16031604
setup_clear_cpu_cap(X86_FEATURE_CPUID);
1605+
get_cpu_address_sizes(c);
16041606
}
16051607

1606-
get_cpu_address_sizes(c);
1607-
16081608
setup_force_cpu_cap(X86_FEATURE_ALWAYS);
16091609

16101610
cpu_set_bug_bits(c);

0 commit comments

Comments
 (0)