Skip to content

Commit 08e237f

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
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>
1 parent 4fffe71 commit 08e237f

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

arch/x86/include/asm/cpufeatures.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,5 +310,5 @@
310310
#endif
311311
#define X86_BUG_NULL_SEG X86_BUG(10) /* Nulling a selector preserves the base */
312312
#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 */
314314
#endif /* _ASM_X86_CPUFEATURES_H */

arch/x86/include/asm/mwait.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static inline void __sti_mwait(unsigned long eax, unsigned long ecx)
9797
*/
9898
static inline void mwait_idle_with_hints(unsigned long eax, unsigned long ecx)
9999
{
100-
if (!current_set_polling_and_test()) {
100+
if (static_cpu_has_bug(X86_BUG_MONITOR) || !current_set_polling_and_test()) {
101101
if (static_cpu_has_bug(X86_BUG_CLFLUSH_MONITOR)) {
102102
mb();
103103
clflush((void *)&current_thread_info()->flags);

arch/x86/kernel/cpu/intel.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <asm/msr.h>
1414
#include <asm/bugs.h>
1515
#include <asm/cpu.h>
16+
#include <asm/intel-family.h>
1617

1718
#ifdef CONFIG_X86_64
1819
#include <linux/topology.h>
@@ -508,6 +509,10 @@ static void init_intel(struct cpuinfo_x86 *c)
508509
(c->x86_model == 29 || c->x86_model == 46 || c->x86_model == 47))
509510
set_cpu_bug(c, X86_BUG_CLFLUSH_MONITOR);
510511

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+
511516
#ifdef CONFIG_X86_64
512517
if (c->x86 == 15)
513518
c->x86_cache_alignment = c->x86_clflush_size * 2;

arch/x86/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ static int prefer_mwait_c1_over_halt(const struct cpuinfo_x86 *c)
404404
if (c->x86_vendor != X86_VENDOR_INTEL)
405405
return 0;
406406

407-
if (!cpu_has(c, X86_FEATURE_MWAIT))
407+
if (!cpu_has(c, X86_FEATURE_MWAIT) || static_cpu_has_bug(X86_BUG_MONITOR))
408408
return 0;
409409

410410
return 1;

0 commit comments

Comments
 (0)