
From: Dave Hansen <dave.hansen@linux.intel.com>

#AC's come from either split lock detection or EFLAGS.AC=1.  No #AC
should be delivered unless the kernel has enabled split lock detection
or sees EFLAGS.AC=1.

Absent either of those two cases, any #AC is a serious hardware or
hypervisor bug. Spew if seen. Kernel #AC's already die() so it's OK
that this only covers #AC's generated when running userspace.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Borislav Petkov <bp@suse.de>
Cc: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: Kiryl Shutsemau <kas@kernel.org>
Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>
Cc: Reinette Chatre <reinette.chatre@intel.com>
---

 b/arch/x86/kernel/cpu/bus_lock.c |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff -puN arch/x86/kernel/cpu/bus_lock.c~warn-on-spurious-ac arch/x86/kernel/cpu/bus_lock.c
--- a/arch/x86/kernel/cpu/bus_lock.c~warn-on-spurious-ac	2026-01-08 08:23:38.975375097 -0800
+++ b/arch/x86/kernel/cpu/bus_lock.c	2026-01-08 10:31:41.955711248 -0800
@@ -318,8 +318,26 @@ void bus_lock_init(void)
 
 bool handle_user_split_lock(struct pt_regs *regs, long error_code)
 {
-	if ((regs->flags & X86_EFLAGS_AC) || sld_state == sld_fatal)
+	/*
+	 * If userspace sets EFLAGS.AC, assume the #AC came from a
+	 * normal unaligned user access, not split lock detection.
+	 */
+	if (regs->flags & X86_EFLAGS_AC)
+	       return false;
+
+	/* Fall through to the SIGBUS generation: */
+	if (sld_state == sld_fatal)
+	       return false;
+
+	/*
+	 * If split lock detection is off and EFLAGS.AC=0, the only
+	 * way to land here is buggy hardware or hypervisors.
+	 */
+	if (sld_state == sld_off) {
+		WARN_ON_ONCE(1);
 		return false;
+	}
+
 	split_lock_warn(regs->ip);
 	return true;
 }
_
