Skip to content

Commit 3e6dba4

Browse files
PlaidCatbmastbergen
authored andcommitted
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> Signed-off-by: Shreeya Patel <spatel@ciq.com> Signed-off-by: Jonathan Maple <jmaple@ciq.com> Signed-off-by: Roxana Nicolescu <rnicolescu@ciq.com> Signed-off-by: Brett Mastbergen <bmastbergen@ciq.com>
1 parent 18dffe6 commit 3e6dba4

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
@@ -1511,6 +1511,7 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
15111511
get_cpu_cap(c);
15121512
get_model_name(c); /* RHEL8: get model name for unsupported check */
15131513
setup_force_cpu_cap(X86_FEATURE_CPUID);
1514+
get_cpu_address_sizes(c);
15141515
cpu_parse_early_param();
15151516

15161517
if (this_cpu->c_early_init)
@@ -1524,10 +1525,9 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
15241525
} else {
15251526
identify_cpu_without_cpuid(c);
15261527
setup_clear_cpu_cap(X86_FEATURE_CPUID);
1528+
get_cpu_address_sizes(c);
15271529
}
15281530

1529-
get_cpu_address_sizes(c);
1530-
15311531
setup_force_cpu_cap(X86_FEATURE_ALWAYS);
15321532

15331533
cpu_set_bug_bits(c);

0 commit comments

Comments
 (0)