diff options
author | Peter Zijlstra <peterz@infradead.org> | 2016-07-18 14:41:10 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-07-20 03:48:40 -0400 |
commit | 08e237fa56a1d95c1372033bc29c4a2517b3c0fa (patch) | |
tree | 516f04cfcd11fafd8d801c7ce0ed60ca660d26d0 | |
parent | 4fffe71dd913cca5532da594e2f48a0db6b494dc (diff) |
x86/cpu: Add workaround for MONITOR instruction erratum on Goldmont based CPUs
Monitored cached line may not wake up from mwait on certain
Goldmont based CPUs. This patch will avoid calling
current_set_polling_and_test() and thereby not set the TIF_ flag.
The result is that we'll always send IPIs for wakeups.
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Len Brown <lenb@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1468867270-18493-1-git-send-email-jacob.jun.pan@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/include/asm/cpufeatures.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/mwait.h | 2 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/intel.c | 5 | ||||
-rw-r--r-- | arch/x86/kernel/process.c | 2 |
4 files changed, 8 insertions, 3 deletions
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index c64b1e9c5d1a..19ecc6e11f4f 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h | |||
@@ -310,5 +310,5 @@ | |||
310 | #endif | 310 | #endif |
311 | #define X86_BUG_NULL_SEG X86_BUG(10) /* Nulling a selector preserves the base */ | 311 | #define X86_BUG_NULL_SEG X86_BUG(10) /* Nulling a selector preserves the base */ |
312 | #define X86_BUG_SWAPGS_FENCE X86_BUG(11) /* SWAPGS without input dep on GS */ | 312 | #define X86_BUG_SWAPGS_FENCE X86_BUG(11) /* SWAPGS without input dep on GS */ |
313 | 313 | #define X86_BUG_MONITOR X86_BUG(12) /* IPI required to wake up remote CPU */ | |
314 | #endif /* _ASM_X86_CPUFEATURES_H */ | 314 | #endif /* _ASM_X86_CPUFEATURES_H */ |
diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h index 0deeb2d26df7..f37f2d8a2989 100644 --- a/arch/x86/include/asm/mwait.h +++ b/arch/x86/include/asm/mwait.h | |||
@@ -97,7 +97,7 @@ static inline void __sti_mwait(unsigned long eax, unsigned long ecx) | |||
97 | */ | 97 | */ |
98 | static inline void mwait_idle_with_hints(unsigned long eax, unsigned long ecx) | 98 | static inline void mwait_idle_with_hints(unsigned long eax, unsigned long ecx) |
99 | { | 99 | { |
100 | if (!current_set_polling_and_test()) { | 100 | if (static_cpu_has_bug(X86_BUG_MONITOR) || !current_set_polling_and_test()) { |
101 | if (static_cpu_has_bug(X86_BUG_CLFLUSH_MONITOR)) { | 101 | if (static_cpu_has_bug(X86_BUG_CLFLUSH_MONITOR)) { |
102 | mb(); | 102 | mb(); |
103 | clflush((void *)¤t_thread_info()->flags); | 103 | clflush((void *)¤t_thread_info()->flags); |
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index c1a89bc026ac..abf601235b29 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <asm/msr.h> | 13 | #include <asm/msr.h> |
14 | #include <asm/bugs.h> | 14 | #include <asm/bugs.h> |
15 | #include <asm/cpu.h> | 15 | #include <asm/cpu.h> |
16 | #include <asm/intel-family.h> | ||
16 | 17 | ||
17 | #ifdef CONFIG_X86_64 | 18 | #ifdef CONFIG_X86_64 |
18 | #include <linux/topology.h> | 19 | #include <linux/topology.h> |
@@ -508,6 +509,10 @@ static void init_intel(struct cpuinfo_x86 *c) | |||
508 | (c->x86_model == 29 || c->x86_model == 46 || c->x86_model == 47)) | 509 | (c->x86_model == 29 || c->x86_model == 46 || c->x86_model == 47)) |
509 | set_cpu_bug(c, X86_BUG_CLFLUSH_MONITOR); | 510 | set_cpu_bug(c, X86_BUG_CLFLUSH_MONITOR); |
510 | 511 | ||
512 | if (c->x86 == 6 && boot_cpu_has(X86_FEATURE_MWAIT) && | ||
513 | ((c->x86_model == INTEL_FAM6_ATOM_GOLDMONT))) | ||
514 | set_cpu_bug(c, X86_BUG_MONITOR); | ||
515 | |||
511 | #ifdef CONFIG_X86_64 | 516 | #ifdef CONFIG_X86_64 |
512 | if (c->x86 == 15) | 517 | if (c->x86 == 15) |
513 | c->x86_cache_alignment = c->x86_clflush_size * 2; | 518 | c->x86_cache_alignment = c->x86_clflush_size * 2; |
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 96becbbb52e0..59f68f1d734b 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c | |||
@@ -404,7 +404,7 @@ static int prefer_mwait_c1_over_halt(const struct cpuinfo_x86 *c) | |||
404 | if (c->x86_vendor != X86_VENDOR_INTEL) | 404 | if (c->x86_vendor != X86_VENDOR_INTEL) |
405 | return 0; | 405 | return 0; |
406 | 406 | ||
407 | if (!cpu_has(c, X86_FEATURE_MWAIT)) | 407 | if (!cpu_has(c, X86_FEATURE_MWAIT) || static_cpu_has_bug(X86_BUG_MONITOR)) |
408 | return 0; | 408 | return 0; |
409 | 409 | ||
410 | return 1; | 410 | return 1; |