diff options
author | Kyle Huey <me@kylehuey.com> | 2017-03-20 04:16:25 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2017-03-20 11:10:34 -0400 |
commit | 90218ac77d0582eaf2d0872d8d900cbd5bf1f205 (patch) | |
tree | b06c5eadda6330f77e7ab3e47af0d3267105d3de | |
parent | 79170fda313ed5be2394f87aa2a00d597f8ed4a1 (diff) |
x86/cpufeature: Detect CPUID faulting support
Intel supports faulting on the CPUID instruction beginning with Ivy Bridge.
When enabled, the processor will fault on attempts to execute the CPUID
instruction with CPL>0. This will allow a ptracer to emulate the CPUID
instruction.
Bit 31 of MSR_PLATFORM_INFO advertises support for this feature. It is
documented in detail in Section 2.3.2 of
https://bugzilla.kernel.org/attachment.cgi?id=243991
Detect support for this feature and expose it as X86_FEATURE_CPUID_FAULT.
Signed-off-by: Kyle Huey <khuey@kylehuey.com>
Reviewed-by: Borislav Petkov <bp@suse.de>
Cc: Grzegorz Andrejczuk <grzegorz.andrejczuk@intel.com>
Cc: kvm@vger.kernel.org
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: linux-kselftest@vger.kernel.org
Cc: Nadav Amit <nadav.amit@gmail.com>
Cc: Robert O'Callahan <robert@ocallahan.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Len Brown <len.brown@intel.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: user-mode-linux-devel@lists.sourceforge.net
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: user-mode-linux-user@lists.sourceforge.net
Cc: David Matlack <dmatlack@google.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Dmitry Safonov <dsafonov@virtuozzo.com>
Cc: linux-fsdevel@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Link: http://lkml.kernel.org/r/20170320081628.18952-8-khuey@kylehuey.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | arch/x86/include/asm/cpufeatures.h | 1 | ||||
-rw-r--r-- | arch/x86/include/asm/msr-index.h | 2 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/intel.c | 24 |
3 files changed, 26 insertions, 1 deletions
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index b04bb6dfed7f..0fe00446f9ca 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h | |||
@@ -187,6 +187,7 @@ | |||
187 | * Reuse free bits when adding new feature flags! | 187 | * Reuse free bits when adding new feature flags! |
188 | */ | 188 | */ |
189 | #define X86_FEATURE_RING3MWAIT ( 7*32+ 0) /* Ring 3 MONITOR/MWAIT */ | 189 | #define X86_FEATURE_RING3MWAIT ( 7*32+ 0) /* Ring 3 MONITOR/MWAIT */ |
190 | #define X86_FEATURE_CPUID_FAULT ( 7*32+ 1) /* Intel CPUID faulting */ | ||
190 | #define X86_FEATURE_CPB ( 7*32+ 2) /* AMD Core Performance Boost */ | 191 | #define X86_FEATURE_CPB ( 7*32+ 2) /* AMD Core Performance Boost */ |
191 | #define X86_FEATURE_EPB ( 7*32+ 3) /* IA32_ENERGY_PERF_BIAS support */ | 192 | #define X86_FEATURE_EPB ( 7*32+ 3) /* IA32_ENERGY_PERF_BIAS support */ |
192 | #define X86_FEATURE_CAT_L3 ( 7*32+ 4) /* Cache Allocation Technology L3 */ | 193 | #define X86_FEATURE_CAT_L3 ( 7*32+ 4) /* Cache Allocation Technology L3 */ |
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index f429b70ebaef..b1f75daca34b 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h | |||
@@ -45,6 +45,8 @@ | |||
45 | #define MSR_IA32_PERFCTR1 0x000000c2 | 45 | #define MSR_IA32_PERFCTR1 0x000000c2 |
46 | #define MSR_FSB_FREQ 0x000000cd | 46 | #define MSR_FSB_FREQ 0x000000cd |
47 | #define MSR_PLATFORM_INFO 0x000000ce | 47 | #define MSR_PLATFORM_INFO 0x000000ce |
48 | #define MSR_PLATFORM_INFO_CPUID_FAULT_BIT 31 | ||
49 | #define MSR_PLATFORM_INFO_CPUID_FAULT BIT_ULL(MSR_PLATFORM_INFO_CPUID_FAULT_BIT) | ||
48 | 50 | ||
49 | #define MSR_PKG_CST_CONFIG_CONTROL 0x000000e2 | 51 | #define MSR_PKG_CST_CONFIG_CONTROL 0x000000e2 |
50 | #define NHM_C3_AUTO_DEMOTE (1UL << 25) | 52 | #define NHM_C3_AUTO_DEMOTE (1UL << 25) |
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index e229318d7230..a07f8295c9ed 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c | |||
@@ -488,6 +488,28 @@ static void intel_bsp_resume(struct cpuinfo_x86 *c) | |||
488 | init_intel_energy_perf(c); | 488 | init_intel_energy_perf(c); |
489 | } | 489 | } |
490 | 490 | ||
491 | static void init_cpuid_fault(struct cpuinfo_x86 *c) | ||
492 | { | ||
493 | u64 msr; | ||
494 | |||
495 | if (!rdmsrl_safe(MSR_PLATFORM_INFO, &msr)) { | ||
496 | if (msr & MSR_PLATFORM_INFO_CPUID_FAULT) | ||
497 | set_cpu_cap(c, X86_FEATURE_CPUID_FAULT); | ||
498 | } | ||
499 | } | ||
500 | |||
501 | static void init_intel_misc_features(struct cpuinfo_x86 *c) | ||
502 | { | ||
503 | u64 msr; | ||
504 | |||
505 | if (rdmsrl_safe(MSR_MISC_FEATURES_ENABLES, &msr)) | ||
506 | return; | ||
507 | |||
508 | /* Check features and update capabilities */ | ||
509 | init_cpuid_fault(c); | ||
510 | probe_xeon_phi_r3mwait(c); | ||
511 | } | ||
512 | |||
491 | static void init_intel(struct cpuinfo_x86 *c) | 513 | static void init_intel(struct cpuinfo_x86 *c) |
492 | { | 514 | { |
493 | unsigned int l2 = 0; | 515 | unsigned int l2 = 0; |
@@ -602,7 +624,7 @@ static void init_intel(struct cpuinfo_x86 *c) | |||
602 | 624 | ||
603 | init_intel_energy_perf(c); | 625 | init_intel_energy_perf(c); |
604 | 626 | ||
605 | probe_xeon_phi_r3mwait(c); | 627 | init_intel_misc_features(c); |
606 | } | 628 | } |
607 | 629 | ||
608 | #ifdef CONFIG_X86_32 | 630 | #ifdef CONFIG_X86_32 |