xen/x86: Improve disabling of features which have dependencies
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 18 Nov 2015 11:43:01 +0000 (11:43 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 8 Apr 2016 20:54:07 +0000 (21:54 +0100)
APIC and XSAVE have dependent features, which also need disabling if Xen
chooses to disable a feature.

Use setup_clear_cpu_cap() rather than clear_bit(), as it takes care of
dependent features as well.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <JBeulich@suse.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
xen/arch/x86/apic.c
xen/arch/x86/cpu/common.c
xen/arch/x86/xstate.c

index b9601adeec12c1e3563997c584471cdf06848fd4..8df5bd35fa14e129732eb6bab79a17a49ca704d1 100644 (file)
@@ -1349,7 +1349,7 @@ void pmu_apic_interrupt(struct cpu_user_regs *regs)
 int __init APIC_init_uniprocessor (void)
 {
     if (enable_local_apic < 0)
-        __clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability);
+        setup_clear_cpu_cap(X86_FEATURE_APIC);
 
     if (!smp_found_config && !cpu_has_apic) {
         skip_ioapic_setup = 1;
index 0942b44bfdf3628522f2852adf3981ec3ea1261c..b5c023f7432b68e01407d93b2b47c89d728c19c0 100644 (file)
@@ -16,9 +16,6 @@
 
 #include "cpu.h"
 
-static bool_t use_xsave = 1;
-boolean_param("xsave", use_xsave);
-
 bool_t opt_arat = 1;
 boolean_param("arat", opt_arat);
 
@@ -341,12 +338,6 @@ void identify_cpu(struct cpuinfo_x86 *c)
        if (this_cpu->c_init)
                this_cpu->c_init(c);
 
-        /* Initialize xsave/xrstor features */
-       if ( !use_xsave )
-               __clear_bit(X86_FEATURE_XSAVE, boot_cpu_data.x86_capability);
-
-       if ( cpu_has_xsave )
-               xstate_init(c);
 
        if ( !opt_pku )
                setup_clear_cpu_cap(X86_FEATURE_PKU);
@@ -370,6 +361,9 @@ void identify_cpu(struct cpuinfo_x86 *c)
 
        /* Now the feature flags better reflect actual CPU features! */
 
+       if ( cpu_has_xsave )
+               xstate_init(c);
+
 #ifdef NOISY_CAPS
        printk(KERN_DEBUG "CPU: After all inits, caps:");
        for (i = 0; i < NCAPINTS; i++)
index 48c01957b8d035b4c9a99d9dee077c429f810b0b..83597223fc3230b0ebcf840bb7f9f0f9a8cb30e4 100644 (file)
@@ -533,11 +533,15 @@ unsigned int xstate_ctxt_size(u64 xcr0)
 /* Collect the information of processor's extended state */
 void xstate_init(struct cpuinfo_x86 *c)
 {
+    static bool_t __initdata use_xsave = 1;
+    boolean_param("xsave", use_xsave);
+
     bool_t bsp = c == &boot_cpu_data;
     u32 eax, ebx, ecx, edx;
     u64 feature_mask;
 
-    if ( boot_cpu_data.cpuid_level < XSTATE_CPUID )
+    if ( (bsp && !use_xsave) ||
+         boot_cpu_data.cpuid_level < XSTATE_CPUID )
     {
         BUG_ON(!bsp);
         setup_clear_cpu_cap(X86_FEATURE_XSAVE);