aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-02-20 17:37:08 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-20 17:37:08 -0500
commit8a9365a4725a4d6265a416dd63bff937e300308e (patch)
treeaf92e88d6e8d976080674d411850695f48d0f261
parent2891e8e66787a6a5dadad017d1c8a8f23d8658af (diff)
parent3bba73b1b7a88d88c3ea16b7914c13d475e4a87b (diff)
Merge branch 'x86-cpufeature-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 cpufeature updates from Ingo Molnar: "The main changes in this cycle were related to enable ring-3 MONITOR/MWAIT instructions support on supported CPUs, by Grzegorz Andrejczuk and Piotr Luc" * 'x86-cpufeature-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/cpufeature: Move RING3MWAIT feature to avoid conflicts x86/cpufeature: Enable RING3MWAIT for Knights Mill x86/cpufeature: Enable RING3MWAIT for Knights Landing x86/cpufeature: Add RING3MWAIT to CPU features x86/elf: Add HWCAP2 to expose ring 3 MONITOR/MWAIT x86/msr: Add MSR_MISC_FEATURE_ENABLES and RING3MWAIT bit x86/cpufeature: Add AVX512_VPOPCNTDQ feature
-rw-r--r--Documentation/admin-guide/kernel-parameters.txt4
-rw-r--r--arch/x86/include/asm/cpufeatures.h4
-rw-r--r--arch/x86/include/asm/elf.h9
-rw-r--r--arch/x86/include/asm/msr-index.h5
-rw-r--r--arch/x86/include/uapi/asm/hwcap2.h7
-rw-r--r--arch/x86/kernel/cpu/common.c3
-rw-r--r--arch/x86/kernel/cpu/intel.c44
-rw-r--r--arch/x86/kernel/fpu/xstate.c1
-rw-r--r--tools/arch/x86/include/asm/cpufeatures.h1
9 files changed, 76 insertions, 2 deletions
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 10d86d938a23..635d11135090 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3561,6 +3561,10 @@
3561 rhash_entries= [KNL,NET] 3561 rhash_entries= [KNL,NET]
3562 Set number of hash buckets for route cache 3562 Set number of hash buckets for route cache
3563 3563
3564 ring3mwait=disable
3565 [KNL] Disable ring 3 MONITOR/MWAIT feature on supported
3566 CPUs.
3567
3564 ro [KNL] Mount root device read-only on boot 3568 ro [KNL] Mount root device read-only on boot
3565 3569
3566 rodata= [KNL] 3570 rodata= [KNL]
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index eafee3161d1c..43c4ea9cd907 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -186,7 +186,7 @@
186 * 186 *
187 * Reuse free bits when adding new feature flags! 187 * Reuse free bits when adding new feature flags!
188 */ 188 */
189 189#define X86_FEATURE_RING3MWAIT ( 7*32+ 0) /* Ring 3 MONITOR/MWAIT */
190#define X86_FEATURE_CPB ( 7*32+ 2) /* AMD Core Performance Boost */ 190#define X86_FEATURE_CPB ( 7*32+ 2) /* AMD Core Performance Boost */
191#define X86_FEATURE_EPB ( 7*32+ 3) /* IA32_ENERGY_PERF_BIAS support */ 191#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 */ 192#define X86_FEATURE_CAT_L3 ( 7*32+ 4) /* Cache Allocation Technology L3 */
@@ -288,6 +288,7 @@
288#define X86_FEATURE_AVX512VBMI (16*32+ 1) /* AVX512 Vector Bit Manipulation instructions*/ 288#define X86_FEATURE_AVX512VBMI (16*32+ 1) /* AVX512 Vector Bit Manipulation instructions*/
289#define X86_FEATURE_PKU (16*32+ 3) /* Protection Keys for Userspace */ 289#define X86_FEATURE_PKU (16*32+ 3) /* Protection Keys for Userspace */
290#define X86_FEATURE_OSPKE (16*32+ 4) /* OS Protection Keys Enable */ 290#define X86_FEATURE_OSPKE (16*32+ 4) /* OS Protection Keys Enable */
291#define X86_FEATURE_AVX512_VPOPCNTDQ (16*32+14) /* POPCNT for vectors of DW/QW */
291#define X86_FEATURE_RDPID (16*32+ 22) /* RDPID instruction */ 292#define X86_FEATURE_RDPID (16*32+ 22) /* RDPID instruction */
292 293
293/* AMD-defined CPU features, CPUID level 0x80000007 (ebx), word 17 */ 294/* AMD-defined CPU features, CPUID level 0x80000007 (ebx), word 17 */
@@ -320,5 +321,4 @@
320#define X86_BUG_SWAPGS_FENCE X86_BUG(11) /* SWAPGS without input dep on GS */ 321#define X86_BUG_SWAPGS_FENCE X86_BUG(11) /* SWAPGS without input dep on GS */
321#define X86_BUG_MONITOR X86_BUG(12) /* IPI required to wake up remote CPU */ 322#define X86_BUG_MONITOR X86_BUG(12) /* IPI required to wake up remote CPU */
322#define X86_BUG_AMD_E400 X86_BUG(13) /* CPU is among the affected by Erratum 400 */ 323#define X86_BUG_AMD_E400 X86_BUG(13) /* CPU is among the affected by Erratum 400 */
323
324#endif /* _ASM_X86_CPUFEATURES_H */ 324#endif /* _ASM_X86_CPUFEATURES_H */
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index e7f155c3045e..9d49c18b5ea9 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -258,6 +258,15 @@ extern int force_personality32;
258 258
259#define ELF_HWCAP (boot_cpu_data.x86_capability[CPUID_1_EDX]) 259#define ELF_HWCAP (boot_cpu_data.x86_capability[CPUID_1_EDX])
260 260
261extern u32 elf_hwcap2;
262
263/*
264 * HWCAP2 supplies mask with kernel enabled CPU features, so that
265 * the application can discover that it can safely use them.
266 * The bits are defined in uapi/asm/hwcap2.h.
267 */
268#define ELF_HWCAP2 (elf_hwcap2)
269
261/* This yields a string that ld.so will use to load implementation 270/* This yields a string that ld.so will use to load implementation
262 specific libraries for optimization. This is more specific in 271 specific libraries for optimization. This is more specific in
263 intent than poking at uname or /proc/cpuinfo. 272 intent than poking at uname or /proc/cpuinfo.
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 710273c617b8..00293a94ffaf 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -543,6 +543,11 @@
543#define MSR_IA32_MISC_ENABLE_IP_PREF_DISABLE_BIT 39 543#define MSR_IA32_MISC_ENABLE_IP_PREF_DISABLE_BIT 39
544#define MSR_IA32_MISC_ENABLE_IP_PREF_DISABLE (1ULL << MSR_IA32_MISC_ENABLE_IP_PREF_DISABLE_BIT) 544#define MSR_IA32_MISC_ENABLE_IP_PREF_DISABLE (1ULL << MSR_IA32_MISC_ENABLE_IP_PREF_DISABLE_BIT)
545 545
546/* MISC_FEATURE_ENABLES non-architectural features */
547#define MSR_MISC_FEATURE_ENABLES 0x00000140
548
549#define MSR_MISC_FEATURE_ENABLES_RING3MWAIT_BIT 1
550
546#define MSR_IA32_TSC_DEADLINE 0x000006E0 551#define MSR_IA32_TSC_DEADLINE 0x000006E0
547 552
548/* P4/Xeon+ specific */ 553/* P4/Xeon+ specific */
diff --git a/arch/x86/include/uapi/asm/hwcap2.h b/arch/x86/include/uapi/asm/hwcap2.h
new file mode 100644
index 000000000000..0bd2be5c7617
--- /dev/null
+++ b/arch/x86/include/uapi/asm/hwcap2.h
@@ -0,0 +1,7 @@
1#ifndef _ASM_X86_HWCAP2_H
2#define _ASM_X86_HWCAP2_H
3
4/* MONITOR/MWAIT enabled in Ring 3 */
5#define HWCAP2_RING3MWAIT (1 << 0)
6
7#endif
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 3bcf6d880611..5200adcaaac3 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -35,6 +35,7 @@
35#include <asm/desc.h> 35#include <asm/desc.h>
36#include <asm/fpu/internal.h> 36#include <asm/fpu/internal.h>
37#include <asm/mtrr.h> 37#include <asm/mtrr.h>
38#include <asm/hwcap2.h>
38#include <linux/numa.h> 39#include <linux/numa.h>
39#include <asm/asm.h> 40#include <asm/asm.h>
40#include <asm/bugs.h> 41#include <asm/bugs.h>
@@ -51,6 +52,8 @@
51 52
52#include "cpu.h" 53#include "cpu.h"
53 54
55u32 elf_hwcap2 __read_mostly;
56
54/* all of these masks are initialized in setup_cpu_local_masks() */ 57/* all of these masks are initialized in setup_cpu_local_masks() */
55cpumask_var_t cpu_initialized_mask; 58cpumask_var_t cpu_initialized_mask;
56cpumask_var_t cpu_callout_mask; 59cpumask_var_t cpu_callout_mask;
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 026c728d6ba7..017ecd3bb553 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -15,6 +15,8 @@
15#include <asm/cpu.h> 15#include <asm/cpu.h>
16#include <asm/intel-family.h> 16#include <asm/intel-family.h>
17#include <asm/microcode_intel.h> 17#include <asm/microcode_intel.h>
18#include <asm/hwcap2.h>
19#include <asm/elf.h>
18 20
19#ifdef CONFIG_X86_64 21#ifdef CONFIG_X86_64
20#include <linux/topology.h> 22#include <linux/topology.h>
@@ -62,6 +64,46 @@ void check_mpx_erratum(struct cpuinfo_x86 *c)
62 } 64 }
63} 65}
64 66
67static bool ring3mwait_disabled __read_mostly;
68
69static int __init ring3mwait_disable(char *__unused)
70{
71 ring3mwait_disabled = true;
72 return 0;
73}
74__setup("ring3mwait=disable", ring3mwait_disable);
75
76static void probe_xeon_phi_r3mwait(struct cpuinfo_x86 *c)
77{
78 /*
79 * Ring 3 MONITOR/MWAIT feature cannot be detected without
80 * cpu model and family comparison.
81 */
82 if (c->x86 != 6)
83 return;
84 switch (c->x86_model) {
85 case INTEL_FAM6_XEON_PHI_KNL:
86 case INTEL_FAM6_XEON_PHI_KNM:
87 break;
88 default:
89 return;
90 }
91
92 if (ring3mwait_disabled) {
93 msr_clear_bit(MSR_MISC_FEATURE_ENABLES,
94 MSR_MISC_FEATURE_ENABLES_RING3MWAIT_BIT);
95 return;
96 }
97
98 msr_set_bit(MSR_MISC_FEATURE_ENABLES,
99 MSR_MISC_FEATURE_ENABLES_RING3MWAIT_BIT);
100
101 set_cpu_cap(c, X86_FEATURE_RING3MWAIT);
102
103 if (c == &boot_cpu_data)
104 ELF_HWCAP2 |= HWCAP2_RING3MWAIT;
105}
106
65static void early_init_intel(struct cpuinfo_x86 *c) 107static void early_init_intel(struct cpuinfo_x86 *c)
66{ 108{
67 u64 misc_enable; 109 u64 misc_enable;
@@ -562,6 +604,8 @@ static void init_intel(struct cpuinfo_x86 *c)
562 detect_vmx_virtcap(c); 604 detect_vmx_virtcap(c);
563 605
564 init_intel_energy_perf(c); 606 init_intel_energy_perf(c);
607
608 probe_xeon_phi_r3mwait(c);
565} 609}
566 610
567#ifdef CONFIG_X86_32 611#ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 1d7770447b3e..35f7024aace5 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -78,6 +78,7 @@ void fpu__xstate_clear_all_cpu_caps(void)
78 setup_clear_cpu_cap(X86_FEATURE_PKU); 78 setup_clear_cpu_cap(X86_FEATURE_PKU);
79 setup_clear_cpu_cap(X86_FEATURE_AVX512_4VNNIW); 79 setup_clear_cpu_cap(X86_FEATURE_AVX512_4VNNIW);
80 setup_clear_cpu_cap(X86_FEATURE_AVX512_4FMAPS); 80 setup_clear_cpu_cap(X86_FEATURE_AVX512_4FMAPS);
81 setup_clear_cpu_cap(X86_FEATURE_AVX512_VPOPCNTDQ);
81} 82}
82 83
83/* 84/*
diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h
index eafee3161d1c..293149a1c6a1 100644
--- a/tools/arch/x86/include/asm/cpufeatures.h
+++ b/tools/arch/x86/include/asm/cpufeatures.h
@@ -288,6 +288,7 @@
288#define X86_FEATURE_AVX512VBMI (16*32+ 1) /* AVX512 Vector Bit Manipulation instructions*/ 288#define X86_FEATURE_AVX512VBMI (16*32+ 1) /* AVX512 Vector Bit Manipulation instructions*/
289#define X86_FEATURE_PKU (16*32+ 3) /* Protection Keys for Userspace */ 289#define X86_FEATURE_PKU (16*32+ 3) /* Protection Keys for Userspace */
290#define X86_FEATURE_OSPKE (16*32+ 4) /* OS Protection Keys Enable */ 290#define X86_FEATURE_OSPKE (16*32+ 4) /* OS Protection Keys Enable */
291#define X86_FEATURE_AVX512_VPOPCNTDQ (16*32+14) /* POPCNT for vectors of DW/QW */
291#define X86_FEATURE_RDPID (16*32+ 22) /* RDPID instruction */ 292#define X86_FEATURE_RDPID (16*32+ 22) /* RDPID instruction */
292 293
293/* AMD-defined CPU features, CPUID level 0x80000007 (ebx), word 17 */ 294/* AMD-defined CPU features, CPUID level 0x80000007 (ebx), word 17 */