From: Andrew Cooper Date: Wed, 18 Nov 2015 11:43:01 +0000 (+0000) Subject: xen/x86: Improve disabling of features which have dependencies X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~1307 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=33d0d39b3b1b78b25a4590d6c723cdf4d24acd91;p=xen.git xen/x86: Improve disabling of features which have dependencies 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 Reviewed-by: Jan Beulich Reviewed-by: Konrad Rzeszutek Wilk --- diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c index b9601adeec..8df5bd35fa 100644 --- a/xen/arch/x86/apic.c +++ b/xen/arch/x86/apic.c @@ -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; diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c index 0942b44bfd..b5c023f743 100644 --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -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++) diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c index 48c01957b8..83597223fc 100644 --- a/xen/arch/x86/xstate.c +++ b/xen/arch/x86/xstate.c @@ -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);