From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Dave Hansen <dave.hansen@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>,
reinette.chatre@intel.com, Kiryl Shutsemau <kas@kernel.org>,
rick.p.edgecombe@intel.com, linux-kernel@vger.kernel.org,
xiaoyao.li@intel.com, chenyi.qiang@intel.com,
chao.p.peng@intel.com
Subject: [PATCH v2] x86/split_lock: Handle unexpected split lock as fatal
Date: Wed, 7 Jan 2026 21:49:55 +0800 [thread overview]
Message-ID: <20260107134955.3293885-1-xiaoyao.li@intel.com> (raw)
The kernel can receive #AC fault on split lock access even when
X86_FEATURE_SPLIT_LOCK_DETECT is not enumerated. For example, this can
occur with a TDX guest running under a Linux host with split lock
detection enabled.
The default "warning" mode of handling user split lock depends on being
able to temporarily disable detection to recover from the split lock event.
However, when X86_FEATURE_SPLIT_LOCK_DETECT is not enumerated, the MSR
or the bit that disables detection is normally not accessible. This means
the feature cannot be disabled and the "warning" mode will not work. The
"fatal" mode, however, can still work properly.
Handle split locks as fatal in such cases.
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
Changes in v2:
- handle it generally instead of special-casing TDX guest; [Kiryl]
v1: https://lore.kernel.org/all/20251126100205.1729391-1-xiaoyao.li@intel.com/
Notes:
- Kiryl suggested to check cpu_model_supports_sld in v1, while this v2
checks X86_FEATURE_SPLIT_LOCK_DETECT. Because I found the latter can
cover the purpose of the former in current kernel. I also sent a patch
separately to clean up cpu_model_supports_sld. [1]
- Patch 2 of v1 is dropped in this v2, since v2 is not TDX specific
anymore. If anyone has interest on whether to enhance sld_state_show()
to call out the potential unexpected #AC behavior for TDX guest or
for more general cases, we can discuss here.
[1] https://lore.kernel.org/all/20251218080044.2615106-1-xiaoyao.li@intel.com/
---
arch/x86/kernel/cpu/bus_lock.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/bus_lock.c b/arch/x86/kernel/cpu/bus_lock.c
index dbc99a47be45..68721f1a2cb0 100644
--- a/arch/x86/kernel/cpu/bus_lock.c
+++ b/arch/x86/kernel/cpu/bus_lock.c
@@ -316,9 +316,25 @@ void bus_lock_init(void)
wrmsrq(MSR_IA32_DEBUGCTLMSR, val);
}
+static bool split_lock_fatal(void)
+{
+ /*
+ * If #AC occurs on split lock without X86_FEATURE_SPLIT_LOCK_DETECT
+ * the kernel cannot handle it by disabling the detection. Treat it as
+ * fatal regardless of the sld_state.
+ */
+ if (!cpu_feature_enabled(X86_FEATURE_SPLIT_LOCK_DETECT))
+ return true;
+
+ if (sld_state == sld_fatal)
+ return true;
+
+ return false;
+}
+
bool handle_user_split_lock(struct pt_regs *regs, long error_code)
{
- if ((regs->flags & X86_EFLAGS_AC) || sld_state == sld_fatal)
+ if ((regs->flags & X86_EFLAGS_AC) || split_lock_fatal())
return false;
split_lock_warn(regs->ip);
return true;
--
2.43.0
next reply other threads:[~2026-01-07 14:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-07 13:49 Xiaoyao Li [this message]
2026-01-07 15:19 ` [PATCH v2] x86/split_lock: Handle unexpected split lock as fatal Dave Hansen
2026-01-07 15:24 ` Edgecombe, Rick P
2026-01-07 16:06 ` Dave Hansen
2026-01-08 2:19 ` Xiaoyao Li
2026-01-08 2:11 ` Xiaoyao Li
2026-01-07 15:20 ` Kiryl Shutsemau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260107134955.3293885-1-xiaoyao.li@intel.com \
--to=xiaoyao.li@intel.com \
--cc=bp@alien8.de \
--cc=chao.p.peng@intel.com \
--cc=chenyi.qiang@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kas@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=reinette.chatre@intel.com \
--cc=rick.p.edgecombe@intel.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox