debuggers.hg
changeset 22259:eb247ea9db8c
x86: check CPUID level before enabling xsave
While not as relevant after c/s 21894, is still seems safer to check
the CPUID level here, just like Linux does. The is particularly
relevant for the 4.0 tree (which doesn't have said c/s), but also
possibly for nested environments where writing MSR_IA32_MISC_ENABLE
may not actually take effect (Xen itself ignores such writes).
Signed-off-by: Jan Beulich <jbeulich@novell.com>
While not as relevant after c/s 21894, is still seems safer to check
the CPUID level here, just like Linux does. The is particularly
relevant for the 4.0 tree (which doesn't have said c/s), but also
possibly for nested environments where writing MSR_IA32_MISC_ENABLE
may not actually take effect (Xen itself ignores such writes).
Signed-off-by: Jan Beulich <jbeulich@novell.com>
author | Keir Fraser <keir@xen.org> |
---|---|
date | Fri Sep 24 15:53:31 2010 +0100 (2010-09-24) |
parents | 105c938eacbb |
children | 71f836615ea2 |
files | xen/arch/x86/i387.c |
line diff
1.1 --- a/xen/arch/x86/i387.c Thu Sep 23 19:16:00 2010 +0100 1.2 +++ b/xen/arch/x86/i387.c Fri Sep 24 15:53:31 2010 +0100 1.3 @@ -132,6 +132,8 @@ void restore_fpu(struct vcpu *v) 1.4 } 1.5 } 1.6 1.7 +#define XSTATE_CPUID 0xd 1.8 + 1.9 /* 1.10 * Maximum size (in byte) of the XSAVE/XRSTOR save area required by all 1.11 * the supported and enabled features on the processor, including the 1.12 @@ -148,7 +150,12 @@ void xsave_init(void) 1.13 int cpu = smp_processor_id(); 1.14 u32 min_size; 1.15 1.16 - cpuid_count(0xd, 0, &eax, &ebx, &ecx, &edx); 1.17 + if ( boot_cpu_data.cpuid_level < XSTATE_CPUID ) { 1.18 + printk(XENLOG_ERR "XSTATE_CPUID missing\n"); 1.19 + return; 1.20 + } 1.21 + 1.22 + cpuid_count(XSTATE_CPUID, 0, &eax, &ebx, &ecx, &edx); 1.23 1.24 printk("%s: cpu%d: cntxt_max_size: 0x%x and states: %08x:%08x\n", 1.25 __func__, cpu, ecx, edx, eax); 1.26 @@ -169,7 +176,7 @@ void xsave_init(void) 1.27 */ 1.28 set_in_cr4(X86_CR4_OSXSAVE); 1.29 set_xcr0(eax & XCNTXT_MASK); 1.30 - cpuid_count(0xd, 0, &eax, &ebx, &ecx, &edx); 1.31 + cpuid_count(XSTATE_CPUID, 0, &eax, &ebx, &ecx, &edx); 1.32 clear_in_cr4(X86_CR4_OSXSAVE); 1.33 1.34 if ( cpu == 0 )