[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Firmware-enabled split-lock detection causes later crashes in HVM domU [QubesOS/qubes-issues#11300]


  • To: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Fri, 27 Nov 2026 17:33:45 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jk4NSynBZFNNd62tTvzO9QUHEM2GgFOvHdAF0R6HH2I=; b=K7oST3SG32uF6jgrK/zxfacqIXYEvlNbnYeGJcHtWefReUOHTX+STIErGbWxFpc85DJ9g1wmFaPXbHqAC/2Soh/EzF8vsa8pTr3CFv3txLB2KAb7EKnS6hvJNE00Zyf4oHwkg+ARKOSpcO1wA04huWT/wJuCuhFJf6Zqd1a6woTgCKw7Py8T3C92blRuF28uHp9m0xsyCSRYlk3ZLisSAr4NKFZqR69MkWOgwoJRWb57P/ljve7bXv875ExMm9fEMbRN1GGyJAF53QgkLp4aRAGO+6LCVXsGza2pc04ZULqRRDrrnXBz6vWL6EvfpYaIZJwF0mptG1jwWL1RftU/kQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vm2kXLnuOh4GRDu/5un/+/6ZEAe3DalkaVdMCgfSvhv/WNi1tB8c0/yBR3ft3wUy3ppci76AYPiq8f++1GBawE8v+ShNLmopJZWuuIxCKr4YvD3g2wMq+JoC4ogc3LozxuDJEeZoq6AnhzYg4szqzlGthkJJpqcp04c8XOSTv4YxAmoMJSnBMOP3M5dHS08ASysYOD2uqMfDm0JOzkUzaK5BElRshgsCpvL2lvfSTkheXa4BwfH2sIdzgjYg2rd+mgdqBwKGWdoKufsXSWb3jAE5cOXBmECLvuqkaq5U++SqKBI0biqLrWwccQE8hXMnGSpMaoxgmN8RnMyzxtJSlg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Autocrypt: addr=andrew.cooper3@xxxxxxxxxx; keydata= xsFNBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i446JOa2vpCI9GcjCzi3oHV e00bzYiHMIl0FICrNJU0Kjho8pdo0m2uxkn6SYEpogAy9pnatUlO+erL4LqFUO7GXSdBRbw5 gNt25XTLdSFuZtMxkY3tq8MFss5QnjhehCVPEpE6y9ZjI4XB8ad1G4oBHVGK5LMsvg22PfMJ ISWFSHo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hBLXDiYlyJT6zOV2yZFuW47VrLsjYnHwn27hmxTC/7tvG3euCklmkn9Sl9IAKFu29RSo d5bD8kMSCYsTqtTfT6W4A3qHGvIDta3ptLYpIAOD2sY3GYq2nf3Bbzx81wZK14JdDDHUX2Rs 6+ahAA==
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, thierry.laurion@xxxxxxxxx
  • Delivery-date: Fri, 27 Nov 2026 17:35:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 27/11/2026 2:00 pm, Marek Marczykowski-Górecki wrote:
> Hi,
>
> I'm forwarding analysis I've got in qubes issues. Looks like something
> that either Xen should turn off, or handle better (as KVM and VirtualBox
> supposedly do).
>
> ----- Forwarded message -----
>
> hippalectryon-0 left a comment (QubesOS/qubes-issues#11300)
>
> @loftlifter31 Thanks for the logs. This is probably not memory corruption. 
> The three crashes with parameters (dump2, dump3 and the one in 
> hypervisor.log) all fail at the same instruction with the same second 
> parameter across separate boots, and dump2 and dump3 show 
> `nt!KiAlignmentFault` (the alignment fault handler) on the stack. dump1 has 
> the same fault code, in `KiInsertQueueDpc` (its stack is cut short). On x86, 
> normal alignment checks only apply to user mode, so an alignment fault in 
> kernel mode points to split-lock detection: the CPU traps a locked access 
> that crosses a cache line. Xen passes that trap into the guest, and Windows 
> crashes. KVM (in its default mode) handles it on the host instead, and 
> VirtualBox seems to as well, which would explain why Windows runs fine in 
> VirtualBox on Debian.
>
> Xen never turns split-lock detection off, so whatever turned it on before Xen 
> started stays in effect. My guess is Heads: it boots Linux first, then kexecs 
> into Xen. Linux turns split-lock detection on by default on Tiger Lake, Alder 
> Lake and Raptor Lake, and doesn't turn it off before kexec. The 
> `split_lock_detect=off` you added goes to the dom0 kernel, which can't change 
> this setting under Xen. This would fit the forum reports (Alder/Raptor Lake 
> on Dasharo+Heads), though one of them says Dasharo UEFI crashed too, so Heads 
> may not be the only way it gets turned on.
>
> Could you try, in order:
>
> 1. In any Linux qube (no reboot needed), run:
> ```
> timeout 10 python3 -c 'import mmap,ctypes as c
> m=mmap.mmap(-1,4096,prot=7);m.write(bytes.fromhex("f0480fba2f00c3"))
> f=c.CFUNCTYPE(None,c.c_void_p)(c.addressof(c.c_char.from_buffer(m)))
> b=c.create_string_buffer(256);f((c.addressof(b)+63)//64*64+60);print("no 
> split-lock #AC")'; echo "exit: $?"
> ```
> It does one locked write across a cache line. If it prints `no split-lock 
> #AC`, split-lock detection is likely off and my theory is likely wrong. If it 
> hangs until the timeout (exit 124) or dies with a bus error, it is on; `sudo 
> dmesg | grep -i split_lock` in that qube should then show a `took a 
> split_lock trap` line.
> 2. In the Heads recovery shell, `dmesg | grep -i split` and paste whatever it 
> prints. This shows whether Heads' Linux turned it on.
> 3. If you can rebuild Heads, add `split_lock_detect=off` to the Heads kernel 
> command line (`CONFIG_LINUX_COMMAND_LINE` in your board's coreboot config), 
> reflash, and see if the BSODs stop.
>
> If this is confirmed, the imo fix probably belongs in Xen (turn split-lock 
> detection off at boot), not in Heads. The microcode difference (0xbe under 
> Xen, 0xb8 under Debian) is probably unrelated. `xl dmesg` confirms Xen is 
> started via kexec from Heads.
>

This area is far more complicated than it seems.  Some history is
necessary, and various peoples lack of precision in the past has lead to
misinformation on the subject.  (i.e. Linux's command line option, which
confuses the capabilities.)

First, some terminology:

* Bus Lock.  When a processor has to exert exclusive access across the
entire system fabric for correctness reasons.
* Split Lock.  A LOCKed RMW instruction, with the memory operand
crossing a cacheline boundary.
* UC Lock.  A LOCKed RMW instruction, with the memory operand containing
non-WriteBack memory.

For both Split lock and UC Lock, the CPU tends to handle these cases by
exerting the Bus Lock.


Second, the capabilities:

Intel have had MSR_MEMORY_CONTROL for ages and ages.  It is entirely
model specific.

One well known bit (31) in it that isn't publicly documented is "split
lock disable".  AIUI, this bit simply splitlock conditions to not exert
Bus Lock, and result in non-atomic behaviour.

Starting in around 2019, Intel introduced MSR_CORE_CAPABILITIES
(alongside MSR_ARCH_CAPABILITIES) in order to provide model specific
enumerations.  The MSR itself is architectural, but the bits in it are
not.  Model checks are required to parse MSR_CORE_CAPS because some CPUs
use the same bits to mean different things.

MSR_CORE_CAPS contains a SPLIT_LOCK_DISABLE bit (in a model specific
position), which enumerates that bit 29 in MSR_MEMORY_CONTROL exists. 
This is also called SPLIT_LOCK_DETECT, and is documented in the SDM.  It
causes a splitlock condition to yield an #AC exception instead of
exerting a Bus Lock.

A related enumeration is UC_LOCK_DISABLE (again in a model specific
position), which enumerates that bit 28 in MSR_MEMORY_CONTROL exists. 
This turns a UC Lock condition into a #GP fault rather than exerting Bus
Lock.

Both are faults, so they break software which encounter them.  It's fine
for debugging your own code, but it isn't fine for running anyone else's
code.


Intel were told this wasn't good enough, so they went and made the Bus
Lock Detect feature.  Bus Lock Detect is fully architectural, and AMD
has picked up the feature too.

For the non-virt case, it causes userspace bus lock conditions to
trigger a #DB Trap (i.e. after the Bus Lock occurred).  Importantly,
this means that the kernel can ratelimit problem userspace[1] without
breaking it.  Linux prints out a message and deschedules for a while.

For the virt case, both Intel and AMD offer a way of getting a VMExit on
Bus Lock.  This applies irrespective of CPL, and lets the hypervisor
ratelimit problem VMs, whether it's a problem kernel or problem userspace.

On systems without Bus Lock Detect, it is possible to use performance
counters for the same purpose.  Xen doesn't, but other hypervisors do.


Third, the interactions:

One problem is that MSR_MEMORY_CONTROL is defined as a Core-scope MSR,
not Thread-scope.  i.e. we cannot context switch these settings because
latest-takes-precedent and clobbers the sibling hyperthread.  On Hybrid
system, this clobbering only occurs on P-cores, because the E-cores
aren't threaded.  So in practice, the choice to use the DISABLE controls
must be system-wide.

The next problem is that Xen doesn't intercept #AC and #GP, so the
faults end up getting serviced by a kernel which isn't aware of their
cause, and doesn't have the controls available even if it would like
them.  We could intercept and emulate, but that's opening several
security cans of worms we successfully closed previously, so isn't a
viable option.

If the DISABLE controls are used at the same time the DETECT controls,
the DISABLE win.  They're faults and block the memory access, meaning
there's nothing to trigger the DETECT for ratelimiting purposes.


Anyway, to the bug as reported.

IMO is a Heads bug.

Thierry, you said "but Heads tries to override unsafe defaults from
firmware", and while I appreciate that point of view, splitlocks are
purely a performance concern, not a correctness concern.

It's not reasonable to ask OS or VMM to turn this stuff off.  It's very
model specific to even locate, meaning that we'd have to keep on
backporting new model information to existing releases for them to know
how to turn it off on new hardware.

It is great that Heads has an option, and I even recommend people trying
it out.  I even have a patch to Xen to let an admin try this stuff out
too, but people need to be aware that it's invasive into all software
including VMs.

i.e. Use of the DISABLE options needs to be opt-in, by people aware of
the consequences.  Xen does use of the DETECT options when they're
available.

~Andrew

[1] It being userspace-only is my "fault".  I had to remind Intel that
there were security vulnerabilities to be had to do with re-entrant
#DB's because of how SYSCALL works.   This has now been fixed in FRED,
but Bus Lock Detect didn't change behaviour.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.