target/arm: STLR followed by LDAR to another address is not ordered on x86 hosts (store-release then load-acquire can be reordered under MTTCG)

Host environment

  • Operating system: Debian 13

  • OS/kernel version: Linux snaplab 6.12.116+deb13-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.116-1 (2026-11-07) x86_64 GNU/Linux

  • Architecture: x86_64

  • QEMU flavor: qemu-system-aarch64

  • QEMU version: 11.1.90 (v11.2.0-rc0), built from master at 29760efa, unmodified

  • QEMU command line:

    qemu-system-aarch64 -machine virt -cpu max -smp 2 -accel tcg -m 1G -nographic -monitor none -serial stdio -kernel litmus.elf

Emulated/Virtualized environment

  • Operating system: none, bare-metal test program at EL1
  • OS/kernel version: N/A
  • Architecture: aarch64

Description of problem

Disclosure: I found this while debugging with the help of an AI assistant. I wrote the test myself and ran it on current master.

The Arm architecture orders a store-release before a later load-acquire (RCsc): STLR to [x] followed by LDAR from [y] cannot be reordered. On an x86 host under MTTCG QEMU does not keep that order, so the classic store-buffering outcome that the architecture forbids shows up.

In target/arm/tcg/translate-a64.c, trans_STLR() emits tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL) before the store (line 3683) and trans_LDAR() emits tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ) after the load (line 3711). Nothing sits between the store of an STLR and the load of a following LDAR, so the x86 backend has no reason to emit a fence there and the store can still be in the store buffer when the load executes.

Impact: guest lock-free code that relies on release/acquire ordering of this kind, for example Dekker style locks, can break under MTTCG on x86 hosts.

Steps to reproduce

  1. Bare-metal AArch64 test, MMU off, 2 vCPUs, 2,000,000 rounds. Each round uses its own pair of variables x and y (separate cache lines), both zero.
  2. Both CPUs synchronise at the start of each round with a release/acquire handshake.
  3. CPU 0 does: STLR 1 to [x]; LDAR r0 from [y]. CPU 1 does: STLR 1 to [y]; LDAR r1 from [x]. Each stores its result with a plain store.
  4. After all rounds, count the rounds where r0 == 0 and r1 == 0. The Arm architecture forbids that outcome.

Additional information

Result on master, four runs of 2,000,000 rounds: 101,806, 85,779, 80,634 and 73,030 rounds with the forbidden outcome (about 4 percent).

Control: the same program with a DMB ISH between the STLR and the LDAR on both CPUs gives 0 forbidden outcomes in three runs of 2,000,000 rounds.

Another project hit the same thing: the vphone-linux QEMU fork (YahiaAngelo, commit 108e1421d2) added a fence for it behind a VPHONE_FENCE flag.

I am not proposing an implementation. Whether the barrier belongs after the STLR store or at the LDAR is a call for the maintainers, and so is the cost on x86 hosts.