diff options
author | Borislav Petkov <bp@suse.de> | 2014-06-17 18:06:23 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2014-06-18 18:27:04 -0400 |
commit | 9b13a93df267af681a66a6a738bf1af10102da7d (patch) | |
tree | 7270414ed60ddcb699f9e154371ce28550c60d30 | |
parent | 03ab3da3b215bac4ebb093c808d54596e03e3225 (diff) |
x86, cpufeature: Convert more "features" to bugs
X86_FEATURE_FXSAVE_LEAK, X86_FEATURE_11AP and
X86_FEATURE_CLFLUSH_MONITOR are not really features but synthetic bits
we use for applying different bug workarounds. Call them what they
really are, and make sure they get the proper cross-CPU behavior (OR
rather than AND).
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: http://lkml.kernel.org/r/1403042783-23278-1-git-send-email-bp@alien8.de
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r-- | arch/x86/include/asm/apic.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/cpufeature.h | 31 | ||||
-rw-r--r-- | arch/x86/include/asm/fpu-internal.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/mwait.h | 2 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/amd.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/intel.c | 4 |
6 files changed, 23 insertions, 20 deletions
diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h index 19b0ebafcd3e..79752f2bdec5 100644 --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h | |||
@@ -99,7 +99,7 @@ static inline void native_apic_mem_write(u32 reg, u32 v) | |||
99 | { | 99 | { |
100 | volatile u32 *addr = (volatile u32 *)(APIC_BASE + reg); | 100 | volatile u32 *addr = (volatile u32 *)(APIC_BASE + reg); |
101 | 101 | ||
102 | alternative_io("movl %0, %1", "xchgl %0, %1", X86_FEATURE_11AP, | 102 | alternative_io("movl %0, %1", "xchgl %0, %1", X86_BUG_11AP, |
103 | ASM_OUTPUT2("=r" (v), "=m" (*addr)), | 103 | ASM_OUTPUT2("=r" (v), "=m" (*addr)), |
104 | ASM_OUTPUT2("0" (v), "m" (*addr))); | 104 | ASM_OUTPUT2("0" (v), "m" (*addr))); |
105 | } | 105 | } |
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index b82f95144a05..52df22bde0dd 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h | |||
@@ -81,7 +81,7 @@ | |||
81 | #define X86_FEATURE_P4 ( 3*32+ 7) /* "" P4 */ | 81 | #define X86_FEATURE_P4 ( 3*32+ 7) /* "" P4 */ |
82 | #define X86_FEATURE_CONSTANT_TSC ( 3*32+ 8) /* TSC ticks at a constant rate */ | 82 | #define X86_FEATURE_CONSTANT_TSC ( 3*32+ 8) /* TSC ticks at a constant rate */ |
83 | #define X86_FEATURE_UP ( 3*32+ 9) /* smp kernel running on up */ | 83 | #define X86_FEATURE_UP ( 3*32+ 9) /* smp kernel running on up */ |
84 | #define X86_FEATURE_FXSAVE_LEAK ( 3*32+10) /* "" FXSAVE leaks FOP/FIP/FOP */ | 84 | /* free, was #define X86_FEATURE_FXSAVE_LEAK ( 3*32+10) * "" FXSAVE leaks FOP/FIP/FOP */ |
85 | #define X86_FEATURE_ARCH_PERFMON ( 3*32+11) /* Intel Architectural PerfMon */ | 85 | #define X86_FEATURE_ARCH_PERFMON ( 3*32+11) /* Intel Architectural PerfMon */ |
86 | #define X86_FEATURE_PEBS ( 3*32+12) /* Precise-Event Based Sampling */ | 86 | #define X86_FEATURE_PEBS ( 3*32+12) /* Precise-Event Based Sampling */ |
87 | #define X86_FEATURE_BTS ( 3*32+13) /* Branch Trace Store */ | 87 | #define X86_FEATURE_BTS ( 3*32+13) /* Branch Trace Store */ |
@@ -90,13 +90,13 @@ | |||
90 | #define X86_FEATURE_REP_GOOD ( 3*32+16) /* rep microcode works well */ | 90 | #define X86_FEATURE_REP_GOOD ( 3*32+16) /* rep microcode works well */ |
91 | #define X86_FEATURE_MFENCE_RDTSC ( 3*32+17) /* "" Mfence synchronizes RDTSC */ | 91 | #define X86_FEATURE_MFENCE_RDTSC ( 3*32+17) /* "" Mfence synchronizes RDTSC */ |
92 | #define X86_FEATURE_LFENCE_RDTSC ( 3*32+18) /* "" Lfence synchronizes RDTSC */ | 92 | #define X86_FEATURE_LFENCE_RDTSC ( 3*32+18) /* "" Lfence synchronizes RDTSC */ |
93 | #define X86_FEATURE_11AP ( 3*32+19) /* "" Bad local APIC aka 11AP */ | 93 | /* free, was #define X86_FEATURE_11AP ( 3*32+19) * "" Bad local APIC aka 11AP */ |
94 | #define X86_FEATURE_NOPL ( 3*32+20) /* The NOPL (0F 1F) instructions */ | 94 | #define X86_FEATURE_NOPL ( 3*32+20) /* The NOPL (0F 1F) instructions */ |
95 | #define X86_FEATURE_ALWAYS ( 3*32+21) /* "" Always-present feature */ | 95 | #define X86_FEATURE_ALWAYS ( 3*32+21) /* "" Always-present feature */ |
96 | #define X86_FEATURE_XTOPOLOGY ( 3*32+22) /* cpu topology enum extensions */ | 96 | #define X86_FEATURE_XTOPOLOGY ( 3*32+22) /* cpu topology enum extensions */ |
97 | #define X86_FEATURE_TSC_RELIABLE ( 3*32+23) /* TSC is known to be reliable */ | 97 | #define X86_FEATURE_TSC_RELIABLE ( 3*32+23) /* TSC is known to be reliable */ |
98 | #define X86_FEATURE_NONSTOP_TSC ( 3*32+24) /* TSC does not stop in C states */ | 98 | #define X86_FEATURE_NONSTOP_TSC ( 3*32+24) /* TSC does not stop in C states */ |
99 | #define X86_FEATURE_CLFLUSH_MONITOR ( 3*32+25) /* "" clflush reqd with monitor */ | 99 | /* free, was #define X86_FEATURE_CLFLUSH_MONITOR ( 3*32+25) * "" clflush reqd with monitor */ |
100 | #define X86_FEATURE_EXTD_APICID ( 3*32+26) /* has extended APICID (8 bits) */ | 100 | #define X86_FEATURE_EXTD_APICID ( 3*32+26) /* has extended APICID (8 bits) */ |
101 | #define X86_FEATURE_AMD_DCM ( 3*32+27) /* multi-node processor */ | 101 | #define X86_FEATURE_AMD_DCM ( 3*32+27) /* multi-node processor */ |
102 | #define X86_FEATURE_APERFMPERF ( 3*32+28) /* APERFMPERF */ | 102 | #define X86_FEATURE_APERFMPERF ( 3*32+28) /* APERFMPERF */ |
@@ -241,6 +241,9 @@ | |||
241 | #define X86_BUG_COMA X86_BUG(2) /* Cyrix 6x86 coma */ | 241 | #define X86_BUG_COMA X86_BUG(2) /* Cyrix 6x86 coma */ |
242 | #define X86_BUG_AMD_TLB_MMATCH X86_BUG(3) /* AMD Erratum 383 */ | 242 | #define X86_BUG_AMD_TLB_MMATCH X86_BUG(3) /* AMD Erratum 383 */ |
243 | #define X86_BUG_AMD_APIC_C1E X86_BUG(4) /* AMD Erratum 400 */ | 243 | #define X86_BUG_AMD_APIC_C1E X86_BUG(4) /* AMD Erratum 400 */ |
244 | #define X86_BUG_11AP X86_BUG(5) /* Bad local APIC aka 11AP */ | ||
245 | #define X86_BUG_FXSAVE_LEAK X86_BUG(6) /* FXSAVE leaks FOP/FIP/FOP */ | ||
246 | #define X86_BUG_CLFLUSH_MONITOR X86_BUG(7) /* AAI65, CLFLUSH required before MONITOR */ | ||
244 | 247 | ||
245 | #if defined(__KERNEL__) && !defined(__ASSEMBLY__) | 248 | #if defined(__KERNEL__) && !defined(__ASSEMBLY__) |
246 | 249 | ||
@@ -545,20 +548,20 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit) | |||
545 | #define static_cpu_has_safe(bit) boot_cpu_has(bit) | 548 | #define static_cpu_has_safe(bit) boot_cpu_has(bit) |
546 | #endif | 549 | #endif |
547 | 550 | ||
548 | #define cpu_has_bug(c, bit) cpu_has(c, (bit)) | 551 | #define cpu_has_bug(c, bit) cpu_has(c, (bit)) |
549 | #define set_cpu_bug(c, bit) set_cpu_cap(c, (bit)) | 552 | #define set_cpu_bug(c, bit) set_cpu_cap(c, (bit)) |
550 | #define clear_cpu_bug(c, bit) clear_cpu_cap(c, (bit)); | 553 | #define clear_cpu_bug(c, bit) clear_cpu_cap(c, (bit)) |
551 | 554 | ||
552 | #define static_cpu_has_bug(bit) static_cpu_has((bit)) | 555 | #define static_cpu_has_bug(bit) static_cpu_has((bit)) |
553 | #define boot_cpu_has_bug(bit) cpu_has_bug(&boot_cpu_data, (bit)) | 556 | #define static_cpu_has_bug_safe(bit) static_cpu_has_safe((bit)) |
557 | #define boot_cpu_has_bug(bit) cpu_has_bug(&boot_cpu_data, (bit)) | ||
554 | 558 | ||
555 | #define MAX_CPU_FEATURES (NCAPINTS * 32) | 559 | #define MAX_CPU_FEATURES (NCAPINTS * 32) |
556 | #define cpu_have_feature boot_cpu_has | 560 | #define cpu_have_feature boot_cpu_has |
557 | 561 | ||
558 | #define CPU_FEATURE_TYPEFMT "x86,ven%04Xfam%04Xmod%04X" | 562 | #define CPU_FEATURE_TYPEFMT "x86,ven%04Xfam%04Xmod%04X" |
559 | #define CPU_FEATURE_TYPEVAL boot_cpu_data.x86_vendor, boot_cpu_data.x86, \ | 563 | #define CPU_FEATURE_TYPEVAL boot_cpu_data.x86_vendor, boot_cpu_data.x86, \ |
560 | boot_cpu_data.x86_model | 564 | boot_cpu_data.x86_model |
561 | 565 | ||
562 | #endif /* defined(__KERNEL__) && !defined(__ASSEMBLY__) */ | 566 | #endif /* defined(__KERNEL__) && !defined(__ASSEMBLY__) */ |
563 | |||
564 | #endif /* _ASM_X86_CPUFEATURE_H */ | 567 | #endif /* _ASM_X86_CPUFEATURE_H */ |
diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h index 115e3689cd53..e3b85422cf12 100644 --- a/arch/x86/include/asm/fpu-internal.h +++ b/arch/x86/include/asm/fpu-internal.h | |||
@@ -293,7 +293,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk) | |||
293 | /* AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception | 293 | /* AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception |
294 | is pending. Clear the x87 state here by setting it to fixed | 294 | is pending. Clear the x87 state here by setting it to fixed |
295 | values. "m" is a random variable that should be in L1 */ | 295 | values. "m" is a random variable that should be in L1 */ |
296 | if (unlikely(static_cpu_has_safe(X86_FEATURE_FXSAVE_LEAK))) { | 296 | if (unlikely(static_cpu_has_bug_safe(X86_BUG_FXSAVE_LEAK))) { |
297 | asm volatile( | 297 | asm volatile( |
298 | "fnclex\n\t" | 298 | "fnclex\n\t" |
299 | "emms\n\t" | 299 | "emms\n\t" |
diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h index 1da25a5f96f9..a1410db38a1a 100644 --- a/arch/x86/include/asm/mwait.h +++ b/arch/x86/include/asm/mwait.h | |||
@@ -43,7 +43,7 @@ static inline void __mwait(unsigned long eax, unsigned long ecx) | |||
43 | static inline void mwait_idle_with_hints(unsigned long eax, unsigned long ecx) | 43 | static inline void mwait_idle_with_hints(unsigned long eax, unsigned long ecx) |
44 | { | 44 | { |
45 | if (!current_set_polling_and_test()) { | 45 | if (!current_set_polling_and_test()) { |
46 | if (static_cpu_has(X86_FEATURE_CLFLUSH_MONITOR)) { | 46 | if (static_cpu_has_bug(X86_BUG_CLFLUSH_MONITOR)) { |
47 | mb(); | 47 | mb(); |
48 | clflush((void *)¤t_thread_info()->flags); | 48 | clflush((void *)¤t_thread_info()->flags); |
49 | mb(); | 49 | mb(); |
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index ce8b8ff0e0ef..8714a78414bf 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c | |||
@@ -595,7 +595,7 @@ static void init_amd(struct cpuinfo_x86 *c) | |||
595 | 595 | ||
596 | /* Enable workaround for FXSAVE leak */ | 596 | /* Enable workaround for FXSAVE leak */ |
597 | if (c->x86 >= 6) | 597 | if (c->x86 >= 6) |
598 | set_cpu_cap(c, X86_FEATURE_FXSAVE_LEAK); | 598 | set_cpu_bug(c, X86_BUG_FXSAVE_LEAK); |
599 | 599 | ||
600 | if (!c->x86_model_id[0]) { | 600 | if (!c->x86_model_id[0]) { |
601 | switch (c->x86) { | 601 | switch (c->x86) { |
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index a80029035bf2..0fd955778f35 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c | |||
@@ -253,7 +253,7 @@ static void intel_workarounds(struct cpuinfo_x86 *c) | |||
253 | */ | 253 | */ |
254 | if (cpu_has_apic && (c->x86<<8 | c->x86_model<<4) == 0x520 && | 254 | if (cpu_has_apic && (c->x86<<8 | c->x86_model<<4) == 0x520 && |
255 | (c->x86_mask < 0x6 || c->x86_mask == 0xb)) | 255 | (c->x86_mask < 0x6 || c->x86_mask == 0xb)) |
256 | set_cpu_cap(c, X86_FEATURE_11AP); | 256 | set_cpu_bug(c, X86_BUG_11AP); |
257 | 257 | ||
258 | 258 | ||
259 | #ifdef CONFIG_X86_INTEL_USERCOPY | 259 | #ifdef CONFIG_X86_INTEL_USERCOPY |
@@ -391,7 +391,7 @@ static void init_intel(struct cpuinfo_x86 *c) | |||
391 | 391 | ||
392 | if (c->x86 == 6 && cpu_has_clflush && | 392 | if (c->x86 == 6 && cpu_has_clflush && |
393 | (c->x86_model == 29 || c->x86_model == 46 || c->x86_model == 47)) | 393 | (c->x86_model == 29 || c->x86_model == 46 || c->x86_model == 47)) |
394 | set_cpu_cap(c, X86_FEATURE_CLFLUSH_MONITOR); | 394 | set_cpu_bug(c, X86_BUG_CLFLUSH_MONITOR); |
395 | 395 | ||
396 | #ifdef CONFIG_X86_64 | 396 | #ifdef CONFIG_X86_64 |
397 | if (c->x86 == 15) | 397 | if (c->x86 == 15) |