Visible to Intel only — GUID: awq1741139317034
Ixiasoft
Visible to Intel only — GUID: awq1741139317034
Ixiasoft
4.3.11.1.3.5. Machine Scratch Swap for Interrupt-Level Register (mscratchcswl)
A new mscratchcswl CSR is added to support conditional swapping of the stack pointer between interrupt and non-interrupt code running in the same privilege mode.
Common use case – csrrw sp, mscratchswl, sp
- Execute swap when accepting an interrupt from non-interrupt code, or returning to non-interrupt code from an interrupt.
- Only one of both mcause.mpil and mintstatus.mil is the application level 0.
- Otherwise, no action is taken.
- The CSR instruction is used once at the entry to a handler routine and once at handler exit, so only adds two instructions to the interrupt code path.
The mscratchcswl CSR is designed to be used with the csrrw instruction with neither rd nor rs1 set to x0. Refrain from accessing the mscratchcswl CSR with:
- The csrrw instruction with either rd or rs1 set to x0, or
- Using any other CSR instruction (CSRRWI/CSRRS/CSRRC/CSRRSI/CSRRCI).