Messages in this thread Patch in this message | | | From | Robert Richter <> | Subject | [PATCH 09/10] x86, xsave: check cpuid level for XSTATE_CPUID (0x0d) | Date | Tue, 20 Jul 2010 20:50:56 +0200 |
| |
The patch adds a check that tests if XSTATE_CPUID exists.
Signed-off-by: Robert Richter <robert.richter@amd.com> --- arch/x86/include/asm/xsave.h | 2 ++ arch/x86/kernel/xsave.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h index 4d3b5d1..d1b5f3a 100644 --- a/arch/x86/include/asm/xsave.h +++ b/arch/x86/include/asm/xsave.h @@ -4,6 +4,8 @@ #include <linux/types.h> #include <asm/processor.h> +#define XSTATE_CPUID 0x0000000d + #define XSTATE_FP 0x1 #define XSTATE_SSE 0x2 #define XSTATE_YMM 0x4 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c index 2322f58..49540b7 100644 --- a/arch/x86/kernel/xsave.c +++ b/arch/x86/kernel/xsave.c @@ -423,9 +423,15 @@ static void __init setup_xstate_init(void) */ static void __cpuinit xstate_enable_boot_cpu(void) { + struct cpuinfo_x86 *c = &cpu_data(0); unsigned int eax, ebx, ecx, edx; - cpuid_count(0xd, 0, &eax, &ebx, &ecx, &edx); + if (c->cpuid_level < XSTATE_CPUID) { + WARN(1, KERN_ERR "XSTATE_CPUID missing\n"); + return; + } + + cpuid_count(XSTATE_CPUID, 0, &eax, &ebx, &ecx, &edx); pcntxt_mask = eax + ((u64)edx << 32); if ((pcntxt_mask & XSTATE_FPSSE) != XSTATE_FPSSE) { -- 1.7.1.1
| |