Sm Extension
- Implemented Version
-
1.12.0
Versions
| Version 1.11.0 | |
|---|---|
State |
ratified |
Ratification date |
2019-12 |
Changes |
|
| Version 1.12.0 | |
|---|---|
State |
ratified |
Ratification date |
2021-12 |
Changes |
|
| Version 1.13.0 | |
|---|---|
State |
frozen |
Changes |
|
Synopsis
This chapter describes the machine-level operations available in machine-mode (M-mode), which is the highest privilege mode in a RISC-V hart. M-mode is used for low-level access to a hardware platform and is the first mode entered at reset. M-mode can also be used to implement features that are too difficult or expensive to implement in hardware directly. The RISC-V machine-level ISA contains a common core that is extended depending on which other privilege levels are supported and other details of the hardware implementation. This chapter describes the RISC-V machine-level architecture, which contains a common core that is used with various supervisor-level address translation and protection schemes.
Parameters
This extension has the following implementation options:
- HPM_COUNTER_EN
-
Whether each HPM counter is implemented in hardware.
HPM_COUNTER_EN[n]beingfalsemeanshpmcounter<n>/mhpmcounter<n>and the correspondingmhpmevent<n>are not implemented and are hardwired read-only zero. (It does not mean the counter is implemented but currently stopped from counting; that is a separate, run-time concept controlled by mcountinhibit.)There is one entry for each hpmcounter, indexed 0-31.
Indices 0-2 must be false: they are placeholders for the three counters (cycle/mcycle (CY), time ™, and instret/minstret (IR)) whose implementation this parameter does not control. These counters are associated with indexes 0, 1, and 2. The rest of the HPM counters logically follow at indexes 3-31. Index 3 in HPM_COUNTER_EN corresponds to mhpmcounter3. Index 31 in HPM_COUNTER_EN corresponds to mhpmcounter31.
- MARCHID_IMPLEMENTED
- MCOUNTENABLE_EN
-
Indicates which counters can be delegated via mcounteren.
An unimplemented counter cannot be specified, i.e., if HPM_COUNTER_EN[3] is false, it would be illegal to set MCOUNTENABLE_EN[3] to true.
- MCOUNTINHIBIT_IMPLEMENTED
-
Options:
- true
-
The mcountinhibit CSR is implemented and can be accessed in M-mode.
- false
-
The mcountinhibit CSR is not implemented. Accessing the CSR will cause an IllegalInstruction trap or enter an unpredictable state, depending on TRAP_ON_UNIMPLEMENTED_CSR.
- MIMPID_IMPLEMENTED
- MISALIGNED_LDST
-
Does the implementation perform non-atomic misaligned loads and stores to main memory (does not affect misaligned support to device memory)? If not, the implementation always throws a misaligned exception.
- MISALIGNED_LDST_EXCEPTION_PRIORITY
-
The relative priority of a load/store/AMO exception vs. load/store/AMO page-fault or access-fault exceptions.
May be one of:
low
Misaligned load/store/AMO exceptions are always lower priority than load/store/AMO page-fault and access-fault exceptions.
high
Misaligned load/store/AMO exceptions are always higher priority than load/store/AMO page-fault and access-fault exceptions.
MISALIGNED_LDST_EXCEPTION_PRIORITY cannot be "high" when MISALIGNED_MAX_ATOMICITY_GRANULE_SIZE is non-zero, since the atomicity of an access cannot be determined in that case until after address translation.
- MISA_CSR_IMPLEMENTED
- MTVAL_WIDTH
-
The number of implemented bits in the mtval CSR. This is the CSR that may be written when a trap is taken into M-mode with exception-specific information to assist software in handling the trap (e.g., address associated with exception).
Must be greater than or equal to max(
PHYS_ADDR_WIDTH,VA_SIZE) - MTVEC_ACCESS
- MTVEC_ILLEGAL_WRITE_BEHAVIOR
-
Options:
- retain
-
When either mtvec.MODE or mtvec.BASE is illegal, mtvec will retain its current value
- custom
-
When either mtvec.MODE or mtvec.BASE is illegal, mtvec will obtain an unpredictable value
Other values may be added over time once other common behaviors are identified.
- MTVEC_MODES
-
Options:
- 0
-
Direct; All traps set
pcto mtvec.BASE - 1
-
Vectored; Asynchronous interrupts set
pcto mtvec.BASE + 4 x cause.
If only one mode is given, mtvec.MODE is assumed to be read-only with that value. Otherwise, mtvec.MODE is read-write.
- MXLEN
-
XLEN in machine mode, specified in bits
- M_MODE_ENDIANNESS
-
Options:
little
M-mode data is always little endian
big
M-mode data is always big endian
dynamic
M-mode data can be either little or big endian, depending on the CSR field mstatus.MBE
- NUM_PMP_ENTRIES
-
Number of implemented PMP entries.
The architecture mandates that the number of implemented PMP registers must appear to be 0, 16, or 64, so NUM_PMP_ENTRIES must be one of those values. It directly determines which PMP registers exist: pmpaddr0-
pmpaddr<N-1>and their correspondingpmpNcfgfields are implemented, and the rest are not. Accessing an unimplemented PMP register causes anIllegalInstructionwhen TRAP_ON_UNIMPLEMENTED_CSR is true.pmpcfgNfor an odd N never exists when XLEN == 64.An implemented entry may still be read-only zero (but will never cause an exception). The number of entries that are actually usable is given by NUM_USABLE_PMP_ENTRIES.
- PHYS_ADDR_WIDTH
-
Implementation-defined size of the physical address space.
- PMA_GRANULARITY
-
Generally, for systems with an MMU, should not be smaller than 12, as that would preclude caching PMA results in the TLB along with virtual memory translations
- PRECISE_SYNCHRONOUS_EXCEPTIONS
-
If false, any exception not otherwise mandated to precise (e.g., PMP violation) will cause execution to enter an unpredictable state.
- REPORT_ENCODING_IN_MTVAL_ON_ILLEGAL_INSTRUCTION
- REPORT_VA_IN_MTVAL_ON_BREAKPOINT
- REPORT_VA_IN_MTVAL_ON_INSTRUCTION_ACCESS_FAULT
- REPORT_VA_IN_MTVAL_ON_INSTRUCTION_MISALIGNED
- REPORT_VA_IN_MTVAL_ON_LOAD_ACCESS_FAULT
- REPORT_VA_IN_MTVAL_ON_LOAD_MISALIGNED
- REPORT_VA_IN_MTVAL_ON_STORE_AMO_ACCESS_FAULT
- REPORT_VA_IN_MTVAL_ON_STORE_AMO_MISALIGNED
- TRAP_ON_EBREAK
-
The spec states that implementations may handle EBREAKs transparently without raising a trap, in which case the EEI must provide a builtin.
- TRAP_ON_ECALL_FROM_M
-
The spec states that implementations may handle ECALLs transparently without raising a trap, in which case the EEI must provide a builtin.
- TRAP_ON_ILLEGAL_WLRL
-
Options:
-
true: Writing an illegal value to a WLRL CSR field will cause an IllegalInstruction exception.
-
false: Writing an illegal value to a WLRL CSR field causes unpredictable behavior.
-
- TRAP_ON_RESERVED_INSTRUCTION
-
Options:
-
true: Fetching an unimplemented and/or undefined instruction from the standard/reserved opcode space will cause an IllegalInstruction exception.
-
false: Fetching an unimplemented and/or undefined instruction from the standard/reserved opcose space causes unpredictable behavior.
TRAP_ON_RESERVED_INSTRUCTION may be false while TRAP_ON_UNIMPLEMENTED_INSTRUCTION is true when a custom instruction is implemented in the standard/reserved opcode space.
-
- TRAP_ON_UNIMPLEMENTED_CSR
- TRAP_ON_UNIMPLEMENTED_INSTRUCTION
-
Options:
-
true: Fetching an unimplemented instruction will cause an IllegalInstruction exception.
-
false: Fetching an unimplemented instruction causes unpredictable behavior.
An unimplemented instruction is any instruction encoding that is not defined by the implementation. Custom instructions are considered implemented.
-
- VENDOR_ID_BANK
-
Encodes the number of one-byte continuation codes in the Bank field of mvendorid.
iN JEDEC’s parlance, the bank number is one greater than the number of continuation codes; hence, the mvendorid Bank field encodes a value that is one less than the JEDEC bank number.
- VENDOR_ID_OFFSET
-
Encodes the final byte of a JEDEC manufactor ID, discarding the parity bit.