mstatus
riscv_unified_db)RV32 / RV64 (Ratified & Standard Extensions)
main
MSmSummary
The mstatus register tracks and controls the hart's current operating state.
Syntax / Encoding
CSR 0x300 (M-mode, RW)
Bitfields (26)
| Bits | Field | Description |
|---|---|---|
63 | SD | Read-only bit that summarizes whether either the FS, XS, or VS fields signal the presence of some dirty state. [RV32: 31, RV64: 63] |
42 | MDT | Written to 1 when entering M-mode from an exception/interrupt. When returning via an MRET instruction, the bit is written to 0. On reset in set to 1, and software should write it to 0 when boot sequence is done. When mstatus.MDT=1, direct write by CSR instruction cannot set mstatus.MIE to 1, if not written together. |
41 | MPELP | Holds the previous Expected Landing Pad (ELP) state when entering M-mode from a trap, and is restored to ELP on MRET. Defined by the Zicfilp extension. Encoded as: * 0 - NO_LP_EXPECTED - no landing pad instruction expected. * 1 - LP_EXPECTED - a landing pad instruction is expected. |
39 | MPV | Written with the prior virtualization mode when entering M-mode from an exception/interrupt. When returning via an MRET instruction, the virtualization mode becomes the value of MPV unless MPP=3, in which case the virtualization mode is always 0. Can also be written by software. |
38 | GVA | When a trap is taken and a guest virtual address is written into mtval, GVA is set. GVA is written by the implementation whenever a trap is taken into HS mode. For any trap (breakpoint, address misaligned, access fault, page fault, or guest-page fault) that writes a guest virtual address to stval, GVA is set to 1. For |
37 | MBE | Controls the endianness of data M-mode (0 = little, 1 = big). Instructions are always little endian, regardless of the data setting. [when,"M_MODE_ENDIANNESS == little"] Since the CPU does not support big endian, this is hardwired to 0. [when,"M_MODE_ENDIANNESS == big"] Since the CPU does not support little endian, t |
36 | SBE | Controls the endianness of S-mode (0 = little, 1 = big). Instructions are always little endian, regardless of the data setting. [when,"S_MODE_ENDIANNESS == little"] Since the CPU does not support big endian, this is hardwired to 0. [when,"S_MODE_ENDIANNESS == big"] Since the CPU does not support little endian, this i |
35:34 | SXL | Sets the effective XLEN for S-mode (0 = 32-bit, 1 = 64-bit, 2 = 128-bit [reserved]). [when,"SXLEN==32"] Since the CPU only supports SXLEN==32, this is hardwired to 1. [when,"SXLEN==64"] Since the CPU only supports SXLEN==64, this is hardwired to 2. [when,"SXLEN=3264"] -- It is not valid to have SXLEN less than UXLEN |
33:32 | UXL | U-mode XLEN. Sets the effective XLEN for U-mode (1 = 32-bit, 2 = 64-bit, 3 = 128-bit [reserved]). [when,"UXLEN == 32"] Since the CPU only supports UXLEN==32, this is hardwired to 1. [when,"UXLEN == 64"] Since the CPU only supports UXLEN==64, this is hardwired to 2. [when,"UXLEN == 3264"] -- It is not valid to have |
23 | SPELP | Holds the previous Expected Landing Pad (ELP) state when entering (H)S-mode from a trap, and is restored to ELP on SRET. Defined by the Zicfilp extension. Encoded as: * 0 - NO_LP_EXPECTED - no landing pad instruction expected. * 1 - LP_EXPECTED - a landing pad instruction is expected. |
22 | TSR | When 1, attempts to execute the sret instruction while executing in HS/S-mode will raise an Illegal Instruction exception. [when,"ext?(:H)"] Does not affect the behavior of sret in VS_mode (see hstatus.VTSR). |
21 | TW | When 1, the WFI instruction will raise an Illegal Instruction trap after an implementaion-defined wait period when executed in a mode other than M-mode. When 0, the wfi instruction is permitted to wait forever in (H)S-mode but must trap after an implementation-defined wait period in U-mode. |
20 | TVM | When 1, an Illegal Instruction trap occurs when * writing the satp CSR, executing an sfence.vma, or executing an sinval.vma while in (H)S-mode (but not VS-mode) * writing the hgtap CSR, executing an hfence.gvma, or executing an hinval.gvma while in HS-mode Notably, mstatus.TVM does *not* cause *hfence.vvma, sfence.w |
19 | MXR | When 1, loads from pages marked readable *or executable* are allowed. When 0, loads from pages marked executable raise a Page Fault exception. |
18 | SUM | When 0, an S-mode read or an M-mode read with mstatus.MPRV=1 and mstatus.MPP=01 to a 'U' (user) page will cause an ILLEGAL INSTRUCTION exception. |
17 | MPRV | When 1, loads and stores behave as if the current virtualization mode:privilege level was mstatus.MPV:mstatus.MPP. mstatus.MPRV is cleared on any exception return (mret or sret instruction, regardless of the trap handler privilege mode). |
16:15 | XS | Summarizes the current state of any custom extension state. Either 0 - Off, 1 - Initial, 2 - Clean, 3 - Dirty. Since there are no custom extensions in the base spec, this field is read-only 0. |
14:13 | FS | When 0, floating point instructions (from F and D extensions) are disabled, and cause ILLEGAL INSTRUCTION exceptions. When a floating point register, or the fCSR register is written, FS obtains the value 3. Values 1 and 2 are valid write values for software, but are not interpreted by hardware other than to possibly en |
12:11 | MPP | Written by hardware in two cases: * Written with the prior nominal privilege level when entering M-mode from an exception/interrupt. * Written with 0 when executing an mret instruction to return from an exception in M-mode. Can also be written by software without immediate side-effect. Affects execution in two cases |
10:9 | VS | When 0, vector instructions (from the V extension) are disabled, and cause ILLEGAL INSTRUCTION exceptions. When a vector register or vector CSR is written, VS obtains the value 3. Values 1 and 2 are valid write values for software, but are not interpreted by hardware other than to possibly enable a previously-disabled |
8 | SPP | Written by hardware in two cases: * Written with the prior nominal privilege level when entering (H)S-mode from an exception/interrupt. * Written with 0 when executing an sret instruction to return from an exception in (H)S-mode or (unlikely) M-mode. Can also be written by software without immediate side-effect. Aff |
7 | MPIE | Written by hardware in two cases: * Written with prior value of mstatus.MIE when entering M-mode from an exception/interrupt. * Written with the value 1 when returning from an exception in M-mode (via the mret instruction). Can also be written by software without immediate side effect. Other than serving as a record |
6 | UBE | Controls the endianness of U-mode (0 = little, 1 = big). Instructions are always little endian, regardless of the data setting. [when,"U_MODE_ENDIANNESS == 'little'"] Since the CPU does not support big endian in U-mode, this is hardwired to 0. [when,"U_MODE_ENDIANNESS == 'big'"] Since the CPU does not support little |
5 | SPIE | Written by hardware in two cases: * Written with prior value of mstatus.SIE when entering (H)S-mode from an exception/interrupt. * Written with the value 1 when returning from an exception via the sret instruction in (H)S-mode or (unlikely) M-mode. Can also be written by software without immediate side effect. Other |
3 | MIE | Written by hardware in two cases: * Written with the value 0 when entering M-mode from an exception/interrupt. * Written with the prior value of mstatus.MPIE when returning from an exception in M-mode (via mret). Affects execution by: * When 0, all interrupts are disabled when the current privilege level is M. * Whe |
1 | SIE | Written by hardware in two cases: * Written with the value 0 when entering (H)S-mode from an exception/interrupt. * Written with the prior value of mstatus.SPIE when returning from an exception via sret in (H)S-mode or (unlikely) M-mode. Affects execution by: * When 0, all (H)S-mode interrupts are disabled when the |