mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] x86/split_lock: Fix and cleanup of cpu_model_supports_sld
@ 2025-12-18  8:00 Xiaoyao Li
  2025-12-18  8:00 ` [PATCH 1/2] x86/split_lock: Fix handling in split_lock_init() Xiaoyao Li
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Xiaoyao Li @ 2025-12-18  8:00 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
  Cc: H. Peter Anvin, Tony Luck, linux-kernel, xiaoyao.li

While considering Kiryl's suggestion[1], I'm wondering why we have
cpu_model_supports_sld defined, which seems like it could be replaced by
X86_FEATURE_SPLIT_LOCK_DETECT.

Tracing through the history, I find that X86_FEATURE_SPLIT_LOCK_DETECT
originally indicated whether the kernel enabled the split lock detection
feature, rather than enumerating hardware support for the feature, at the
time when cpu_model_supports_sld was introduced.

Now, the semantics of X86_FEATURE_SPLIT_LOCK_DETECT have changed and
it enuemrates the hardware support for the feature. Therefore, patch 2
replaces cpu_model_supports_sld with X86_FEATURE_SPLIT_LOCK_DETECT.

Patch 1 fixes a potential issue where MSR_TEST_CTRL can be written when
the split lock detection feature is not available, which can cause bizarre
behavior.

[1] https://lore.kernel.org/all/lvobu4gpfsjg63syubgy2jwcja72folflrst7bu2eqv6rhaqre@ttbkykphu32f/

Xiaoyao Li (2):
  x86/split_lock: Fix handling in split_lock_init()
  x86/split_lock: Drop cpu_model_supports_sld

 arch/x86/kernel/cpu/bus_lock.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

-- 
2.43.0


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

* [PATCH 1/2] x86/split_lock: Fix handling in split_lock_init()
  2025-12-18  8:00 [PATCH 0/2] x86/split_lock: Fix and cleanup of cpu_model_supports_sld Xiaoyao Li
@ 2025-12-18  8:00 ` Xiaoyao Li
  2025-12-18  8:00 ` [PATCH 2/2] x86/split_lock: Drop cpu_model_supports_sld Xiaoyao Li
  2026-03-06  2:59 ` [PATCH 0/2] x86/split_lock: Fix and cleanup of cpu_model_supports_sld Xiaoyao Li
  2 siblings, 0 replies; 4+ messages in thread
From: Xiaoyao Li @ 2025-12-18  8:00 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
  Cc: H. Peter Anvin, Tony Luck, linux-kernel, xiaoyao.li

Per commit 009bce1df0bb ("x86/split_lock: Don't write MSR_TEST_CTRL on
CPUs that aren't whitelisted"), cpu_model_supports_sld was introduced to
guard writes on MSR_TEST_CTRL in split_lock_init(). However, the
sld_ratelimit case handling added later was not covered by the
cpu_model_supports_sld check.

Fix this by checking cpu_model_supports_sld at the beginning of
split_lock_init().

Fixes: ef4ae6e44131 ("x86/bus_lock: Set rate limit for bus lock")
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
 arch/x86/kernel/cpu/bus_lock.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/bus_lock.c b/arch/x86/kernel/cpu/bus_lock.c
index dbc99a47be45..28bf208b92cb 100644
--- a/arch/x86/kernel/cpu/bus_lock.c
+++ b/arch/x86/kernel/cpu/bus_lock.c
@@ -169,6 +169,9 @@ static void sld_update_msr(bool on)
 
 void split_lock_init(void)
 {
+	if (!cpu_model_supports_sld)
+		return;
+
 	/*
 	 * #DB for bus lock handles ratelimit and #AC for split lock is
 	 * disabled.
@@ -178,8 +181,7 @@ void split_lock_init(void)
 		return;
 	}
 
-	if (cpu_model_supports_sld)
-		split_lock_verify_msr(sld_state != sld_off);
+	split_lock_verify_msr(sld_state != sld_off);
 }
 
 static void __split_lock_reenable_unlock(struct work_struct *work)
-- 
2.43.0


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

* [PATCH 2/2] x86/split_lock: Drop cpu_model_supports_sld
  2025-12-18  8:00 [PATCH 0/2] x86/split_lock: Fix and cleanup of cpu_model_supports_sld Xiaoyao Li
  2025-12-18  8:00 ` [PATCH 1/2] x86/split_lock: Fix handling in split_lock_init() Xiaoyao Li
@ 2025-12-18  8:00 ` Xiaoyao Li
  2026-03-06  2:59 ` [PATCH 0/2] x86/split_lock: Fix and cleanup of cpu_model_supports_sld Xiaoyao Li
  2 siblings, 0 replies; 4+ messages in thread
From: Xiaoyao Li @ 2025-12-18  8:00 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
  Cc: H. Peter Anvin, Tony Luck, linux-kernel, xiaoyao.li

cpu_model_supports_sld was introduced to indicate whether the CPU on
which the kernel runs supports split lock detection, because at that
time X86_FEATURE_SPLIT_LOCK_DETECT was inadequate since it was set only
when sld_state was sld_warn or sld_fatal.

Now, the semantics of X86_FEATURE_SPLIT_LOCK_DETECT have changed and it
can serve exactly the same purpose of cpu_model_supports_sld.

Drop cpu_model_supports_sld and use X86_FEATURE_SPLIT_LOCK_DETECT
instead.

Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
 arch/x86/kernel/cpu/bus_lock.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/arch/x86/kernel/cpu/bus_lock.c b/arch/x86/kernel/cpu/bus_lock.c
index 28bf208b92cb..b072405b9a72 100644
--- a/arch/x86/kernel/cpu/bus_lock.c
+++ b/arch/x86/kernel/cpu/bus_lock.c
@@ -28,13 +28,6 @@ enum split_lock_detect_state {
 static enum split_lock_detect_state sld_state __ro_after_init = sld_off;
 static u64 msr_test_ctrl_cache __ro_after_init;
 
-/*
- * With a name like MSR_TEST_CTL it should go without saying, but don't touch
- * MSR_TEST_CTL unless the CPU is one of the whitelisted models.  Writing it
- * on CPUs that do not support SLD can cause fireworks, even when writing '0'.
- */
-static bool cpu_model_supports_sld __ro_after_init;
-
 static const struct {
 	const char			*option;
 	enum split_lock_detect_state	state;
@@ -169,7 +162,7 @@ static void sld_update_msr(bool on)
 
 void split_lock_init(void)
 {
-	if (!cpu_model_supports_sld)
+	if (!boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT))
 		return;
 
 	/*
@@ -387,7 +380,6 @@ static void __init split_lock_setup(struct cpuinfo_x86 *c)
 	return;
 
 supported:
-	cpu_model_supports_sld = true;
 	__split_lock_setup();
 }
 
-- 
2.43.0


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

* Re: [PATCH 0/2] x86/split_lock: Fix and cleanup of cpu_model_supports_sld
  2025-12-18  8:00 [PATCH 0/2] x86/split_lock: Fix and cleanup of cpu_model_supports_sld Xiaoyao Li
  2025-12-18  8:00 ` [PATCH 1/2] x86/split_lock: Fix handling in split_lock_init() Xiaoyao Li
  2025-12-18  8:00 ` [PATCH 2/2] x86/split_lock: Drop cpu_model_supports_sld Xiaoyao Li
@ 2026-03-06  2:59 ` Xiaoyao Li
  2 siblings, 0 replies; 4+ messages in thread
From: Xiaoyao Li @ 2026-03-06  2:59 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
  Cc: H. Peter Anvin, Tony Luck, linux-kernel

On 12/18/2025 4:00 PM, Xiaoyao Li wrote:
> While considering Kiryl's suggestion[1], I'm wondering why we have
> cpu_model_supports_sld defined, which seems like it could be replaced by
> X86_FEATURE_SPLIT_LOCK_DETECT.
> 
> Tracing through the history, I find that X86_FEATURE_SPLIT_LOCK_DETECT
> originally indicated whether the kernel enabled the split lock detection
> feature, rather than enumerating hardware support for the feature, at the
> time when cpu_model_supports_sld was introduced.
> 
> Now, the semantics of X86_FEATURE_SPLIT_LOCK_DETECT have changed and
> it enuemrates the hardware support for the feature. Therefore, patch 2
> replaces cpu_model_supports_sld with X86_FEATURE_SPLIT_LOCK_DETECT.
> 
> Patch 1 fixes a potential issue where MSR_TEST_CTRL can be written when
> the split lock detection feature is not available, which can cause bizarre
> behavior.

Ping on this series.

(It applies cleanly on v7.0-rc2)

> [1] https://lore.kernel.org/all/lvobu4gpfsjg63syubgy2jwcja72folflrst7bu2eqv6rhaqre@ttbkykphu32f/
> 
> Xiaoyao Li (2):
>    x86/split_lock: Fix handling in split_lock_init()
>    x86/split_lock: Drop cpu_model_supports_sld
> 
>   arch/x86/kernel/cpu/bus_lock.c | 14 ++++----------
>   1 file changed, 4 insertions(+), 10 deletions(-)
> 


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

end of thread, other threads:[~2026-03-06  2:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-18  8:00 [PATCH 0/2] x86/split_lock: Fix and cleanup of cpu_model_supports_sld Xiaoyao Li
2025-12-18  8:00 ` [PATCH 1/2] x86/split_lock: Fix handling in split_lock_init() Xiaoyao Li
2025-12-18  8:00 ` [PATCH 2/2] x86/split_lock: Drop cpu_model_supports_sld Xiaoyao Li
2026-03-06  2:59 ` [PATCH 0/2] x86/split_lock: Fix and cleanup of cpu_model_supports_sld Xiaoyao Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®