stxp

Store Exclusive Pair

STXP <Ws>, <Wt1>, <Wt2>, [<Xn|SP>]

Stores two registers if exclusive monitor matches.

Details

Conditionally stores two consecutive 32-bit words from Wt1 and Wt2 to memory at addresses Xn and Xn+4 if the exclusive monitor for that address range is marked exclusive; writes the store status (0=success, 1=failure) to Ws. No condition flags are affected. AArch64-only instruction that interacts with the exclusive monitor and may generate exception faults.

Pseudocode Operation

address ← Xn
if ExclusiveMonitorMatch(address, DWORD) then
  [address, 4] ← Wt1[31:0]
  [address + 4, 4] ← Wt2[31:0]
  Ws ← 0
  ClearExclusiveMonitor(address)
else
  Ws ← 1

Example

STXP w6, w3, w4, [x1]

Encoding

Binary Layout
1
0
0010000
0
1
Rs
0
Rt2
Rn
Rt
 
Format Load/Store Excl
Opcode 0x88200000
Extension Base (Atomic)

Operands

  • Ws
    Status
  • Wt1
    First transfer 32-bit register (load/store pair)
  • Wt2
    Second transfer 32-bit register (load/store pair)
  • Xn
    First source / base 64-bit integer register

Reference (Arm A64 ISA)

Instruction Forms

Encoding Instruction ISA Bit pattern
0x88200000 STXP <Ws>, <Wt1>, <Wt2>, [<Xn|SP>{, #0}] A64 1 | 0 | 0010000 | 0 | 1 | Rs | 0 | Rt2 | Rn | Rt
0xC8200000 STXP <Ws>, <Xt1>, <Xt2>, [<Xn|SP>{, #0}] A64 1 | 1 | 0010000 | 0 | 1 | Rs | 0 | Rt2 | Rn | Rt

Description

Store Exclusive Pair of registers stores two 32-bit words or two 64-bit doublewords from two registers to a memory location if the PE has exclusive access to the memory address, and returns a status value of 0 if the store was successful, or of 1 if no store was performed. See Synchronization and semaphores. For information on single-copy atomicity and alignment requirements, see Requirements for single-copy atomicity and Alignment of data accesses. If a 64-bit pair Store-Exclusive succeeds, it causes a single-copy atomic update of the 128-bit memory location being updated. For information about memory accesses, see Load/Store addressing modes.

Operation

bits(64) address;
bits(datasize) data;
constant integer dbytes = datasize DIV 8;

AccessDescriptor accdesc = CreateAccDescExLDST(MemOp_STORE, FALSE, tagchecked);

if n == 31 then
    CheckSPAlignment();
    address = SP[];
elsif rn_unknown then
    address = bits(64) UNKNOWN;
else
    address = X[n, 64];

if rt_unknown then
    data = bits(datasize) UNKNOWN;
else
    bits(datasize DIV 2) el1 = X[t, datasize DIV 2];
    bits(datasize DIV 2) el2 = X[t2, datasize DIV 2];
    data = if BigEndian(accdesc.acctype) then el1:el2 else el2:el1;
bit status = '1';
// Check whether the Exclusives monitors are set to include the
// physical memory locations corresponding to virtual address
// range [address, address+dbytes-1].

// If AArch64.ExclusiveMonitorsPass() returns FALSE and the memory address,
// if accessed, would generate a synchronous Data Abort exception, it is
// IMPLEMENTATION DEFINED whether the exception is generated.
// It is a limitation of this model that synchronous Data Aborts are never
// generated in this case, as Mem[] is not called.
// If FEAT_SPE is implemented, it is also IMPLEMENTATION DEFINED whether or not the
// physical address packet is output when permitted and when
// AArch64.ExclusiveMonitorPass() returns FALSE for a Store Exclusive instruction.
// This behavior is not reflected here due to the previously stated limitation.
if AArch64.ExclusiveMonitorsPass(address, dbytes, accdesc) then
    // This atomic write will be rejected if it does not refer
    // to the same physical locations after address translation.
    Mem[address, dbytes, accdesc] = data;
    status = ExclusiveMonitorsStatus();
X[s, 32] = ZeroExtend(status, 32);