linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/tsx: Use MSR_TSX_CTRL to clear CPUID bits
@ 2022-02-09 21:04 Pawan Gupta
  2022-02-14 17:38 ` Borislav Petkov
  0 siblings, 1 reply; 18+ messages in thread
From: Pawan Gupta @ 2022-02-09 21:04 UTC (permalink / raw)
  To: Thomas Gleixner, Borislav Petkov
  Cc: Ingo Molnar, Dave Hansen, x86, H. Peter Anvin, Andi Kleen,
	Tony Luck, linux-kernel, antonio.gomez.iglesias,
	neelima.krishnan

tsx_clear_cpuid() uses MSR_TSX_FORCE_ABORT to clear CPUID.RTM and
CPUID.HLE. Not all CPUs support MSR_TSX_FORCE_ABORT, alternatively use
MSR_IA32_TSX_CTRL when supported.

Fixes: 293649307ef9 ("x86/tsx: Clear CPUID bits when TSX always force aborts")
Reported-by: kernel test robot <lkp@intel.com>
Tested-by: Neelima Krishnan <neelima.krishnan@intel.com>
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
---
 arch/x86/kernel/cpu/tsx.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/cpu/tsx.c b/arch/x86/kernel/cpu/tsx.c
index 9c7a5f049292..c2343ea911e8 100644
--- a/arch/x86/kernel/cpu/tsx.c
+++ b/arch/x86/kernel/cpu/tsx.c
@@ -58,7 +58,7 @@ void tsx_enable(void)
 	wrmsrl(MSR_IA32_TSX_CTRL, tsx);
 }
 
-static bool __init tsx_ctrl_is_supported(void)
+static bool tsx_ctrl_is_supported(void)
 {
 	u64 ia32_cap = x86_read_arch_cap_msr();
 
@@ -97,6 +97,10 @@ void tsx_clear_cpuid(void)
 		rdmsrl(MSR_TSX_FORCE_ABORT, msr);
 		msr |= MSR_TFA_TSX_CPUID_CLEAR;
 		wrmsrl(MSR_TSX_FORCE_ABORT, msr);
+	} else if (tsx_ctrl_is_supported()) {
+		rdmsrl(MSR_IA32_TSX_CTRL, msr);
+		msr |= TSX_CTRL_CPUID_CLEAR;
+		wrmsrl(MSR_IA32_TSX_CTRL, msr);
 	}
 }
 
@@ -106,13 +110,11 @@ void __init tsx_init(void)
 	int ret;
 
 	/*
-	 * Hardware will always abort a TSX transaction if both CPUID bits
-	 * RTM_ALWAYS_ABORT and TSX_FORCE_ABORT are set. In this case, it is
-	 * better not to enumerate CPUID.RTM and CPUID.HLE bits. Clear them
-	 * here.
+	 * Hardware will always abort a TSX transaction when CPUID
+	 * RTM_ALWAYS_ABORT is set. In this case, it is better not to enumerate
+	 * CPUID.RTM and CPUID.HLE bits. Clear them here.
 	 */
-	if (boot_cpu_has(X86_FEATURE_RTM_ALWAYS_ABORT) &&
-	    boot_cpu_has(X86_FEATURE_TSX_FORCE_ABORT)) {
+	if (boot_cpu_has(X86_FEATURE_RTM_ALWAYS_ABORT)) {
 		tsx_ctrl_state = TSX_CTRL_RTM_ALWAYS_ABORT;
 		tsx_clear_cpuid();
 		setup_clear_cpu_cap(X86_FEATURE_RTM);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2022-02-16 19:03 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09 21:04 [PATCH] x86/tsx: Use MSR_TSX_CTRL to clear CPUID bits Pawan Gupta
2022-02-14 17:38 ` Borislav Petkov
2022-02-14 22:41   ` Pawan Gupta
2022-02-14 23:28     ` Borislav Petkov
2022-02-15  0:20       ` Pawan Gupta
2022-02-15 10:24         ` Borislav Petkov
2022-02-15 12:11           ` Pawan Gupta
2022-02-15 16:31             ` Borislav Petkov
2022-02-15 18:19               ` Pawan Gupta
2022-02-15 19:33                 ` Borislav Petkov
2022-02-16  0:39                   ` Pawan Gupta
2022-02-16  0:49                     ` Andrew Cooper
2022-02-16  1:28                       ` Pawan Gupta
2022-02-16  6:08                         ` Pawan Gupta
2022-02-16 10:30                           ` Borislav Petkov
2022-02-16 19:03                             ` Pawan Gupta
2022-02-16 11:46                         ` Andrew Cooper
2022-02-16 18:59                           ` Pawan Gupta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).