From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754029AbcGTKmD (ORCPT ); Wed, 20 Jul 2016 06:42:03 -0400 Received: from terminus.zytor.com ([198.137.202.10]:50280 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753972AbcGTKly (ORCPT ); Wed, 20 Jul 2016 06:41:54 -0400 Date: Wed, 20 Jul 2016 03:40:56 -0700 From: tip-bot for Peter Zijlstra Message-ID: Cc: lenb@kernel.org, hpa@zytor.com, brgerst@gmail.com, torvalds@linux-foundation.org, dvlasenk@redhat.com, luto@kernel.org, peterz@infradead.org, bp@alien8.de, mingo@kernel.org, jpoimboe@redhat.com, arjan@linux.intel.com, tglx@linutronix.de, jacob.jun.pan@linux.intel.com, linux-kernel@vger.kernel.org Reply-To: mingo@kernel.org, bp@alien8.de, brgerst@gmail.com, hpa@zytor.com, lenb@kernel.org, torvalds@linux-foundation.org, luto@kernel.org, dvlasenk@redhat.com, peterz@infradead.org, jacob.jun.pan@linux.intel.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, arjan@linux.intel.com, jpoimboe@redhat.com In-Reply-To: <1468867270-18493-1-git-send-email-jacob.jun.pan@linux.intel.com> References: <1468867270-18493-1-git-send-email-jacob.jun.pan@linux.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cpu] x86/cpu: Add workaround for MONITOR instruction erratum on Goldmont based CPUs Git-Commit-ID: 08e237fa56a1d95c1372033bc29c4a2517b3c0fa X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 08e237fa56a1d95c1372033bc29c4a2517b3c0fa Gitweb: http://git.kernel.org/tip/08e237fa56a1d95c1372033bc29c4a2517b3c0fa Author: Peter Zijlstra AuthorDate: Mon, 18 Jul 2016 11:41:10 -0700 Committer: Ingo Molnar CommitDate: Wed, 20 Jul 2016 09:48:40 +0200 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 Signed-off-by: Jacob Pan Cc: Andy Lutomirski Cc: Arjan van de Ven Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Josh Poimboeuf Cc: Len Brown Cc: Linus Torvalds Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1468867270-18493-1-git-send-email-jacob.jun.pan@linux.intel.com Signed-off-by: Ingo Molnar --- arch/x86/include/asm/cpufeatures.h | 2 +- arch/x86/include/asm/mwait.h | 2 +- arch/x86/kernel/cpu/intel.c | 5 +++++ 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 c64b1e9..19ecc6e 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -310,5 +310,5 @@ #endif #define X86_BUG_NULL_SEG X86_BUG(10) /* Nulling a selector preserves the base */ #define X86_BUG_SWAPGS_FENCE X86_BUG(11) /* SWAPGS without input dep on GS */ - +#define X86_BUG_MONITOR X86_BUG(12) /* IPI required to wake up remote CPU */ #endif /* _ASM_X86_CPUFEATURES_H */ diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h index 0deeb2d..f37f2d8 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) */ static inline void mwait_idle_with_hints(unsigned long eax, unsigned long ecx) { - if (!current_set_polling_and_test()) { + if (static_cpu_has_bug(X86_BUG_MONITOR) || !current_set_polling_and_test()) { if (static_cpu_has_bug(X86_BUG_CLFLUSH_MONITOR)) { mb(); clflush((void *)¤t_thread_info()->flags); diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index c1a89bc..abf6012 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -13,6 +13,7 @@ #include #include #include +#include #ifdef CONFIG_X86_64 #include @@ -508,6 +509,10 @@ static void init_intel(struct cpuinfo_x86 *c) (c->x86_model == 29 || c->x86_model == 46 || c->x86_model == 47)) set_cpu_bug(c, X86_BUG_CLFLUSH_MONITOR); + if (c->x86 == 6 && boot_cpu_has(X86_FEATURE_MWAIT) && + ((c->x86_model == INTEL_FAM6_ATOM_GOLDMONT))) + set_cpu_bug(c, X86_BUG_MONITOR); + #ifdef CONFIG_X86_64 if (c->x86 == 15) c->x86_cache_alignment = c->x86_clflush_size * 2; diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index 96becbb..59f68f1 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) if (c->x86_vendor != X86_VENDOR_INTEL) return 0; - if (!cpu_has(c, X86_FEATURE_MWAIT)) + if (!cpu_has(c, X86_FEATURE_MWAIT) || static_cpu_has_bug(X86_BUG_MONITOR)) return 0; return 1;