Skip to content

Aarch64 Implementation

Robert O'Callahan edited this page Jul 20, 2026 · 3 revisions

Exclusive Stores

Aarch64 supports exclusive stores as an atomicity mechanism: an exclusive load (LDREX or LDX*) followed by some logic and a conditional store (STREX or STX*) where the conditional store only happens if there was no concurrent modification. This doesn't work with rr because when the conditional store fails (which is unpredictable/uncontrollable), extra conditional branches are taken to repeat the atomic operation, which makes the conditional branch counter nondeterministic.

Most Aarch64 code has moved on the the LSE atomic instructions, which don't have this problem, but some exclusive-store instructions are still present in system libraries. We have workarounds that try to make sure they're never used, but still, sometimes they crop up.

Diagnosing the problem

One way to find the execution of these instructions:

  • create a recording using rr record -F ...
  • rr replay ** In gdb, run
set logging file /tmp/trace
set logging enabled on
set pagination off
python
while True:
  gdb.execute('stepi')
  gdb.execute('disass $pc,$pc+4')

Because during the replay we're watching the PMU counter STREX_SPEC, this will actually stop the first time one of these instructions is executed, with the message 1 (speculatively) executed strex instructions detected. Actually LDXR and probably other instructions trigger this too.

Clone this wiki locally