All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Fix RCsc store->load ordering of release stores
@ 2026-08-21  6:40 LIU Zhiwei
  2026-08-21  6:40 ` [PATCH 1/3] target/riscv: Fix RCsc ordering of Zalasr store-release LIU Zhiwei
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: LIU Zhiwei @ 2026-08-21  6:40 UTC (permalink / raw)
  To: qemu-devel, qemu-riscv, qemu-arm
  Cc: palmer, alistair.francis, liwei1518, daniel.barboza, chao.liu,
	zhiwei_liu, peter.maydell, richard.henderson

Several guest architectures give their store-release instructions RCsc
semantics, which requires the store to be ordered not only after the
memory operations that precede it, but also before any subsequent
load-acquire with RCsc semantics.  The TCG translators, however, only
emit the leading barrier before the store, so under MTTCG nothing
prevents the host CPU from executing the load-acquire that follows a
store-release before the store has left its store buffer.  On an x86
host (TSO), store-load is the only reordering the hardware may
perform, and it is exactly the ordering that is missing, so the
architecturally forbidden [0,0] outcome of the Store Buffering litmus
test is easy to observe:

    CPU 0                      CPU 1
    store-release X = 1        store-release Y = 1
    load-acquire  r0 = Y       load-acquire  r1 = X

The affected instructions are the RISC-V Zalasr store-release
instructions and the Arm STLR, STLPUR and A32/T32 STL store-release
instructions.  Neither architecture defines an RCpc store, so every
store-release is RCsc (RVWMO preserved program order Rule 7; Arm
Architecture Reference Manual DDI 0487, section B2.3.8 "Acquire and
release semantics").

Patch 1 fixes the RISC-V side and patch 2 the Arm side by emitting a
full barrier after the store as well.  Patch 3 fixes an inverted
barrier polarity found in the A32 LDA load-acquire translator while
auditing the load-acquire side.

Both fixes are verified with bare-metal Store Buffering litmus tests
under MTTCG on an x86 host:

  * RISC-V (rv64, Zalasr, 4 vCPUs): 89881 out of 100000 iterations
    produce the forbidden [0,0] result before the fix and 0 after;

  * Arm (cortex-a53, 2 vCPUs): 6 to 7 out of 100000 iterations
    produce the forbidden [0,0] result before the fix and 0 after;
    a control variant of the test that inserts a DMB ISH between the
    store and the load produces 0 out of 100000 before the fix, which
    validates the harness.

The other architectures were audited and need no change:

  * Xtensa keeps only the leading barrier for S32RI and the trailing
    one for L32AI, which exactly matches the simplified Release
    Consistency model the ISA specifies (Xtensa Instruction Set
    Architecture Reference Manual, sections 3.8.3 "Memory Access
    Ordering" and 4.3.12.3 "Inter-Processor Communication with the
    L32AI and S32RI Instructions"): the ISA orders the release store
    only after previous memory operations and the acquire load only
    before subsequent memory operations, so the Store Buffering
    litmus test is allowed there and a trailing barrier would be
    stronger than required;

  * exclusive stores and guest atomic operations are lowered to host
    atomic instructions, which are fully ordered on x86 hosts;

  * the RISC-V Ztso extension is TSO by design and explicitly allows
    store buffering.

LIU Zhiwei (3):
  target/riscv: Fix RCsc ordering of Zalasr store-release
  target/arm: Fix RCsc ordering of store-release instructions
  target/arm: Fix barrier polarity of A32 LDA load-acquire

 target/arm/tcg/translate-a64.c                   | 13 +++++++++++++
 target/arm/tcg/translate.c                       |  8 +++++++-
 target/riscv/tcg/insn_trans/trans_rvzalasr.c.inc |  8 ++++++++
 3 files changed, 28 insertions(+), 1 deletion(-)

-- 
2.43.0



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

end of thread, other threads:[~2026-11-17 10:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-21  6:40 [PATCH 0/3] Fix RCsc store->load ordering of release stores LIU Zhiwei
2026-08-21  6:40 ` [PATCH 1/3] target/riscv: Fix RCsc ordering of Zalasr store-release LIU Zhiwei
2026-08-24 12:30   ` Daniel Henrique Barboza
2026-08-21  6:40 ` [PATCH 2/3] target/arm: Fix RCsc ordering of store-release instructions LIU Zhiwei
2026-11-16 18:41   ` Alex Bennée
2026-11-16 18:53   ` Alex Bennée
2026-08-21  6:40 ` [PATCH 3/3] target/arm: Fix barrier polarity of A32 LDA load-acquire LIU Zhiwei
2026-11-16 19:31 ` [PATCH 0/3] Fix RCsc store->load ordering of release stores Peter Maydell
2026-11-17  2:31   ` Alistair Francis
2026-11-17 10:34     ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.