early_cpu_init() calls intel_unlock_cpuid_leaves(), which arranges for the
boot trampoline to make the adjustment for all APs, meaning the call from
early_init_intel() is a no-op.  Drop it, allowing intel_unlock_cpuid_leaves()
to become __init code.

In turn, the adjustments in generic_identify() were a no-op too.  Nothing in
the c_early_init() hooks modifies the 1c/1d features, so their values in
c->x86_capability[] are still good from just above.

The ebx variable used to calculate c->x86_clflush_size is still good too, but
move the logic earlier so it's more obviously correct.

Fixes: fa4d026737a4 ("x86/Intel: unlock CPUID earlier for the BSP")
Signed-off-by: Andrew Cooper <[email protected]>
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau MonnĂ© <[email protected]>
CC: Julian Vetter <[email protected]>
CC: Teddy Astie <[email protected]>
---
 xen/arch/x86/cpu/common.c | 10 +---------
 xen/arch/x86/cpu/intel.c  |  4 +---
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index f8c80db6eb1d..dda0d5d39c92 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -479,6 +479,7 @@ static void generic_identify(struct cpuinfo_x86 *c)
        cpuid(1, &eax, &ebx, &ecx, &edx);
        c->x86 = get_cpu_family(eax, &c->x86_model, &c->x86_mask);
        c->apicid = phys_pkg_id((ebx >> 24) & 0xFF, 0);
+       c->x86_clflush_size = ((ebx >> 8) & 0xff) * 8;
        c->phys_proc_id = c->apicid;
 
        /*
@@ -502,15 +503,6 @@ static void generic_identify(struct cpuinfo_x86 *c)
        if (actual_cpu.c_early_init)
                alternative_vcall(actual_cpu.c_early_init, c);
 
-       /* c_early_init() may have adjusted cpuid levels/features.  Reread. */
-       c->cpuid_level = cpuid_eax(0);
-       cpuid(1, &eax, &ebx,
-             &c->x86_capability[FEATURESET_1c],
-             &c->x86_capability[FEATURESET_1d]);
-
-       if ( cpu_has(c, X86_FEATURE_CLFLUSH) )
-               c->x86_clflush_size = ((ebx >> 8) & 0xff) * 8;
-
        /* AMD-defined flags: level 0x80000001 */
        if (c->extended_cpuid_level >= 0x80000001)
                cpuid(0x80000001, &tmp, &tmp,
diff --git a/xen/arch/x86/cpu/intel.c b/xen/arch/x86/cpu/intel.c
index 584588e406f2..d585161dd32f 100644
--- a/xen/arch/x86/cpu/intel.c
+++ b/xen/arch/x86/cpu/intel.c
@@ -310,7 +310,7 @@ static void __init noinline intel_init_levelling(void)
 }
 
 /* Unmask CPUID levels if masked. */
-void intel_unlock_cpuid_leaves(struct cpuinfo_x86 *c)
+void __init intel_unlock_cpuid_leaves(struct cpuinfo_x86 *c)
 {
        uint64_t misc_enable, disable;
 
@@ -335,8 +335,6 @@ static void cf_check early_init_intel(struct cpuinfo_x86 *c)
            bootsym(trampoline_misc_enable_off) & 
MSR_IA32_MISC_ENABLE_XD_DISABLE)
                printk(KERN_INFO "re-enabled NX (Execute Disable) 
protection\n");
 
-       intel_unlock_cpuid_leaves(c);
-
        /* CPUID workaround for Intel 0F33/0F34 CPU */
        if (boot_cpu_data.x86 == 0xF && boot_cpu_data.x86_model == 3 &&
            (boot_cpu_data.x86_mask == 3 || boot_cpu_data.x86_mask == 4))
-- 
2.39.5


Reply via email to