diff options
author | Fenghua Yu <fenghua.yu@intel.com> | 2014-05-29 14:12:30 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2014-05-29 17:24:28 -0400 |
commit | 6229ad278ca74acdbc8bd3a3d469322a3de91039 (patch) | |
tree | d6e72f6129630ddbf3d46b9902fecf0fb331f364 | |
parent | 446fd806f5408b623fa51f3aa084e56844563779 (diff) |
x86/xsaves: Detect xsaves/xrstors feature
Detect the xsaveopt, xsavec, xgetbv, and xsaves features in processor extended
state enumberation sub-leaf (eax=0x0d, ecx=1):
Bit 00: XSAVEOPT is available
Bit 01: Supports XSAVEC and the compacted form of XRSTOR if set
Bit 02: Supports XGETBV with ECX = 1 if set
Bit 03: Supports XSAVES/XRSTORS and IA32_XSS if set
The above features are defined in the new word 10 in cpu features.
The IA32_XSS MSR (index DA0H) contains a state-component bitmap that specifies
the state components that software has enabled xsaves and xrstors to manage.
If the bit corresponding to a state component is clear in XCR0 | IA32_XSS,
xsaves and xrstors will not operate on that state component, regardless of
the value of the instruction mask.
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Link: http://lkml.kernel.org/r/1401387164-43416-3-git-send-email-fenghua.yu@intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r-- | arch/x86/include/asm/cpufeature.h | 10 | ||||
-rw-r--r-- | arch/x86/include/uapi/asm/msr-index.h | 2 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/common.c | 9 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/scattered.c | 1 |
4 files changed, 19 insertions, 3 deletions
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index 2837b9257291..b82f95144a05 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h | |||
@@ -8,7 +8,7 @@ | |||
8 | #include <asm/required-features.h> | 8 | #include <asm/required-features.h> |
9 | #endif | 9 | #endif |
10 | 10 | ||
11 | #define NCAPINTS 10 /* N 32-bit words worth of info */ | 11 | #define NCAPINTS 11 /* N 32-bit words worth of info */ |
12 | #define NBUGINTS 1 /* N 32-bit bug flags */ | 12 | #define NBUGINTS 1 /* N 32-bit bug flags */ |
13 | 13 | ||
14 | /* | 14 | /* |
@@ -180,7 +180,6 @@ | |||
180 | #define X86_FEATURE_ARAT ( 7*32+ 1) /* Always Running APIC Timer */ | 180 | #define X86_FEATURE_ARAT ( 7*32+ 1) /* Always Running APIC Timer */ |
181 | #define X86_FEATURE_CPB ( 7*32+ 2) /* AMD Core Performance Boost */ | 181 | #define X86_FEATURE_CPB ( 7*32+ 2) /* AMD Core Performance Boost */ |
182 | #define X86_FEATURE_EPB ( 7*32+ 3) /* IA32_ENERGY_PERF_BIAS support */ | 182 | #define X86_FEATURE_EPB ( 7*32+ 3) /* IA32_ENERGY_PERF_BIAS support */ |
183 | #define X86_FEATURE_XSAVEOPT ( 7*32+ 4) /* Optimized Xsave */ | ||
184 | #define X86_FEATURE_PLN ( 7*32+ 5) /* Intel Power Limit Notification */ | 183 | #define X86_FEATURE_PLN ( 7*32+ 5) /* Intel Power Limit Notification */ |
185 | #define X86_FEATURE_PTS ( 7*32+ 6) /* Intel Package Thermal Status */ | 184 | #define X86_FEATURE_PTS ( 7*32+ 6) /* Intel Package Thermal Status */ |
186 | #define X86_FEATURE_DTHERM ( 7*32+ 7) /* Digital Thermal Sensor */ | 185 | #define X86_FEATURE_DTHERM ( 7*32+ 7) /* Digital Thermal Sensor */ |
@@ -226,6 +225,12 @@ | |||
226 | #define X86_FEATURE_AVX512ER ( 9*32+27) /* AVX-512 Exponential and Reciprocal */ | 225 | #define X86_FEATURE_AVX512ER ( 9*32+27) /* AVX-512 Exponential and Reciprocal */ |
227 | #define X86_FEATURE_AVX512CD ( 9*32+28) /* AVX-512 Conflict Detection */ | 226 | #define X86_FEATURE_AVX512CD ( 9*32+28) /* AVX-512 Conflict Detection */ |
228 | 227 | ||
228 | /* Extended state features, CPUID level 0x0000000d:1 (eax), word 10 */ | ||
229 | #define X86_FEATURE_XSAVEOPT (10*32+ 0) /* XSAVEOPT */ | ||
230 | #define X86_FEATURE_XSAVEC (10*32+ 1) /* XSAVEC */ | ||
231 | #define X86_FEATURE_XGETBV1 (10*32+ 2) /* XGETBV with ECX = 1 */ | ||
232 | #define X86_FEATURE_XSAVES (10*32+ 3) /* XSAVES/XRSTORS */ | ||
233 | |||
229 | /* | 234 | /* |
230 | * BUG word(s) | 235 | * BUG word(s) |
231 | */ | 236 | */ |
@@ -328,6 +333,7 @@ extern const char * const x86_power_flags[32]; | |||
328 | #define cpu_has_x2apic boot_cpu_has(X86_FEATURE_X2APIC) | 333 | #define cpu_has_x2apic boot_cpu_has(X86_FEATURE_X2APIC) |
329 | #define cpu_has_xsave boot_cpu_has(X86_FEATURE_XSAVE) | 334 | #define cpu_has_xsave boot_cpu_has(X86_FEATURE_XSAVE) |
330 | #define cpu_has_xsaveopt boot_cpu_has(X86_FEATURE_XSAVEOPT) | 335 | #define cpu_has_xsaveopt boot_cpu_has(X86_FEATURE_XSAVEOPT) |
336 | #define cpu_has_xsaves boot_cpu_has(X86_FEATURE_XSAVES) | ||
331 | #define cpu_has_osxsave boot_cpu_has(X86_FEATURE_OSXSAVE) | 337 | #define cpu_has_osxsave boot_cpu_has(X86_FEATURE_OSXSAVE) |
332 | #define cpu_has_hypervisor boot_cpu_has(X86_FEATURE_HYPERVISOR) | 338 | #define cpu_has_hypervisor boot_cpu_has(X86_FEATURE_HYPERVISOR) |
333 | #define cpu_has_pclmulqdq boot_cpu_has(X86_FEATURE_PCLMULQDQ) | 339 | #define cpu_has_pclmulqdq boot_cpu_has(X86_FEATURE_PCLMULQDQ) |
diff --git a/arch/x86/include/uapi/asm/msr-index.h b/arch/x86/include/uapi/asm/msr-index.h index fcf2b3ae1bf0..5cd1569518ef 100644 --- a/arch/x86/include/uapi/asm/msr-index.h +++ b/arch/x86/include/uapi/asm/msr-index.h | |||
@@ -297,6 +297,8 @@ | |||
297 | #define MSR_IA32_TSC_ADJUST 0x0000003b | 297 | #define MSR_IA32_TSC_ADJUST 0x0000003b |
298 | #define MSR_IA32_BNDCFGS 0x00000d90 | 298 | #define MSR_IA32_BNDCFGS 0x00000d90 |
299 | 299 | ||
300 | #define MSR_IA32_XSS 0x00000da0 | ||
301 | |||
300 | #define FEATURE_CONTROL_LOCKED (1<<0) | 302 | #define FEATURE_CONTROL_LOCKED (1<<0) |
301 | #define FEATURE_CONTROL_VMXON_ENABLED_INSIDE_SMX (1<<1) | 303 | #define FEATURE_CONTROL_VMXON_ENABLED_INSIDE_SMX (1<<1) |
302 | #define FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX (1<<2) | 304 | #define FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX (1<<2) |
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index a135239badb7..e7c4b979d504 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
@@ -632,6 +632,15 @@ void get_cpu_cap(struct cpuinfo_x86 *c) | |||
632 | c->x86_capability[9] = ebx; | 632 | c->x86_capability[9] = ebx; |
633 | } | 633 | } |
634 | 634 | ||
635 | /* Extended state features: level 0x0000000d */ | ||
636 | if (c->cpuid_level >= 0x0000000d) { | ||
637 | u32 eax, ebx, ecx, edx; | ||
638 | |||
639 | cpuid_count(0x0000000d, 1, &eax, &ebx, &ecx, &edx); | ||
640 | |||
641 | c->x86_capability[10] = eax; | ||
642 | } | ||
643 | |||
635 | /* AMD-defined flags: level 0x80000001 */ | 644 | /* AMD-defined flags: level 0x80000001 */ |
636 | xlvl = cpuid_eax(0x80000000); | 645 | xlvl = cpuid_eax(0x80000000); |
637 | c->extended_cpuid_level = xlvl; | 646 | c->extended_cpuid_level = xlvl; |
diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index b6f794aa1693..4a8013d55947 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c | |||
@@ -38,7 +38,6 @@ void init_scattered_cpuid_features(struct cpuinfo_x86 *c) | |||
38 | { X86_FEATURE_PTS, CR_EAX, 6, 0x00000006, 0 }, | 38 | { X86_FEATURE_PTS, CR_EAX, 6, 0x00000006, 0 }, |
39 | { X86_FEATURE_APERFMPERF, CR_ECX, 0, 0x00000006, 0 }, | 39 | { X86_FEATURE_APERFMPERF, CR_ECX, 0, 0x00000006, 0 }, |
40 | { X86_FEATURE_EPB, CR_ECX, 3, 0x00000006, 0 }, | 40 | { X86_FEATURE_EPB, CR_ECX, 3, 0x00000006, 0 }, |
41 | { X86_FEATURE_XSAVEOPT, CR_EAX, 0, 0x0000000d, 1 }, | ||
42 | { X86_FEATURE_HW_PSTATE, CR_EDX, 7, 0x80000007, 0 }, | 41 | { X86_FEATURE_HW_PSTATE, CR_EDX, 7, 0x80000007, 0 }, |
43 | { X86_FEATURE_CPB, CR_EDX, 9, 0x80000007, 0 }, | 42 | { X86_FEATURE_CPB, CR_EDX, 9, 0x80000007, 0 }, |
44 | { X86_FEATURE_PROC_FEEDBACK, CR_EDX,11, 0x80000007, 0 }, | 43 | { X86_FEATURE_PROC_FEEDBACK, CR_EDX,11, 0x80000007, 0 }, |