Skip to content

Commit 18d2121

Browse files
committed
x86/cpu: Allow reducing x86_phys_bits during early_identify_cpu()
jira LE-2183 bug-fix x86/sev-es: Set x86_virt_bits commit-author Paolo Bonzini <pbonzini@redhat.com> commit 9a45819 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 (cherry picked from commit 9a45819) Signed-off-by: Jonathan Maple <jmaple@ciq.com> Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 41f48c0 commit 18d2121

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
@@ -1494,6 +1494,7 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
14941494
get_cpu_cap(c);
14951495
get_model_name(c); /* RHEL8: get model name for unsupported check */
14961496
setup_force_cpu_cap(X86_FEATURE_CPUID);
1497+
get_cpu_address_sizes(c);
14971498
cpu_parse_early_param();
14981499

14991500
if (this_cpu->c_early_init)
@@ -1507,10 +1508,9 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
15071508
} else {
15081509
identify_cpu_without_cpuid(c);
15091510
setup_clear_cpu_cap(X86_FEATURE_CPUID);
1511+
get_cpu_address_sizes(c);
15101512
}
15111513

1512-
get_cpu_address_sizes(c);
1513-
15141514
setup_force_cpu_cap(X86_FEATURE_ALWAYS);
15151515

15161516
cpu_set_bug_bits(c);

0 commit comments

Comments
 (0)