Are CSR instructions memory atomics?
No. Atomic here means the CSR read-modify-write is one instruction, not an AMO to memory.
Read CSR into rd, then atomically set bits in the CSR where the 5-bit immediate has 1s
CSRRSI uses opcode 1110011 (0x73), funct3 110. The rs1 field selects the source register, the 12-bit immediate provides the second operand, and rd selects the destination.
CSRRSI is the immediate variant of CSRRS: reads the current CSR value (zero-extended to XLEN bits) into rd, then uses the 5-bit unsigned immediate (uimm[4:0]) as a bit mask to set the corresponding bits to 1. If uimm=0, the instruction writes nothing to the CSR and causes no write side effects, enabling safe read-only access. Due to the 5-bit limit, only CSR bits 0–4 can be affected. Commonly used to configure privilege-mode fields in mstatus (e.g., MPP, MPIE) that reside in the lower bits. The assembler pseudo-instruction CSRSI(csr, uimm) is encoded as CSRRSI x0, csr, uimm (set bits, discard old value).
CSRRSI is a Zicsr atomic CSR read-modify-write instruction. CSR addresses are 12 bits, and whether read/write side effects occur depends on rd and on rs1 or uimm being x0/0.
Understand this scenario with real code like «csrrsi x5, mstatus, 1 # x5 = old mstatus; set bit 0 in mstatus».
Understand this scenario with real code like «csrrsi x5, mstatus, 1 # x5 = old mstatus; set bit 0 in mstatus».
No. Atomic here means the CSR read-modify-write is one instruction, not an AMO to memory.
For CSRRW it suppresses the CSR read and read side effects; CSRRS/CSRRC still read the CSR.