medeleg
Machine exception delegation register
- Address
0x302- Group
- Machine-level CSRs
- Privilege
MRW(privileged spec CSR listing, Machine Trap Setup)- Access
- read/write; lowest privilege M (machine)
- Address range
- Standard read/write
- Name in riscv-unified-db
- Machine Exception Delegation
Privileged spec: Machine exception delegation register
Description
Controls exception delegation from M-mode to (H)S-mode
When H is implemented:
or, in conjunction with hedeleg, to VS-mode
.
An exception cause is delegated to (H)S-mode when all of the following hold:
- The corresponding field in
medelegis set. - The current privilege level is not M-mode.
When H is implemented:
- The same field in
hedelegis clear.
When H is implemented:
An exception cause is delegated to VS-mode when all of the following hold:
- The corresponding field in
medelegis set. - The corresponding field in
hedelegis set. - The current privilege level is not M-mode or HS-mode.
Otherwise, an exception cause is handled by M-mode.
See interrupt documentation for more details.
From riscv-unified-db, reformatted.
Fields
| Field | Bits | Type | Description | |||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
IAM | 0 | Instruction Address Misaligned Delegates Instruction Address Misaligned exceptions to (H)S-mode. When H is implemented: Instruction Address Misaligned exceptions may be further delegated to VS-mode if Exceptions are never taken into a less-privileged mode, regardless of The handling mode is determined as follows: When H is implemented:
Otherwise:
| ||||||||||||||||||||||||||||||||||||||||||
IAF | 1 | Instruction Access Fault Delegates Instruction Access Fault exceptions to (H)S-mode. When H is implemented: Instruction Access Fault exceptions may be further delegated to VS-mode if Exceptions are never taken into a less-privileged mode, regardless of The handling mode is determined as follows: When H is implemented:
Otherwise:
| ||||||||||||||||||||||||||||||||||||||||||
II | 2 | Illegal Instruction Delegates Illegal Instruction exceptions to (H)S-mode. When H is implemented: Illegal Instruction exceptions may be further delegated to VS-mode if Exceptions are never taken into a less-privileged mode, regardless of The handling mode is determined as follows: When H is implemented:
Otherwise:
| ||||||||||||||||||||||||||||||||||||||||||
B | 3 | Breakpoint Delegates Breakpoint exceptions to (H)S-mode. When H is implemented: Breakpoint exceptions may be further delegated to VS-mode if Exceptions are never taken into a less-privileged mode, regardless of The handling mode is determined as follows: When H is implemented:
Otherwise:
| ||||||||||||||||||||||||||||||||||||||||||
LAM | 4 | Load Address Misaligned Delegates Load Address Misaligned exceptions to (H)S-mode. When H is implemented: Load Address Misaligned exceptions may be further delegated to VS-mode if Exceptions are never taken into a less-privileged mode, regardless of Note that because this implementation supports misaligned loads, this exception will never occur. However, the writable bit should be presented anyway. The handling mode is determined as follows: When H is implemented:
Otherwise:
| ||||||||||||||||||||||||||||||||||||||||||
LAF | 5 | Load Access Fault Delegates Load Access Fault exceptions to (H)S-mode. When H is implemented: Load Access Fault exceptions may be further delegated to VS-mode if Exceptions are never taken into a less-privileged mode, regardless of The handling mode is determined as follows: When H is implemented:
Otherwise:
| ||||||||||||||||||||||||||||||||||||||||||
SAM | 6 | Store/AMO Address Misaligned Delegates Store/AMO Address Misaligned exceptions to (H)S-mode. When H is implemented: Store/AMO Address Misaligned exceptions may be further delegated to VS-mode if Exceptions are never taken into a less-privileged mode, regardless of Note that because the implementation supports misaligned stores and misaligned AMOs (or no AMOs), this exception will never occur. Even so, the writable bit should be presented anyway. The handling mode is determined as follows: When H is implemented:
Otherwise:
| ||||||||||||||||||||||||||||||||||||||||||
SAF | 7 | Store/AMO Access Fault Delegates Store/AMO Access Fault exceptions to (H)S-mode. When H is implemented: Store/AMO Access Fault exceptions may be further delegated to VS-mode if Exceptions are never taken into a less-privileged mode, regardless of The handling mode is determined as follows: When H is implemented:
Otherwise:
| ||||||||||||||||||||||||||||||||||||||||||
EU | 8 | Environment Call from U-Mode Delegates Environment Call from U-mode exceptions to (H)S-mode. When H is implemented: Environment Call from U-mode exceptions may be further delegated to VS-mode if Exceptions are never taken into a less-privileged mode, regardless of The handling mode is determined as follows: When H is implemented:
Otherwise:
| ||||||||||||||||||||||||||||||||||||||||||
ES | 9 | Environment Call from S-Mode Delegates Environment Call from S-mode exceptions to (H)S-mode. When H is implemented: Environment Call from S-mode exceptions cannot be delegated to VS-mode. Exceptions are never taken into a less-privileged mode, regardless of The handling mode is determined as follows:
| ||||||||||||||||||||||||||||||||||||||||||
EVS | 10 | Environment Call from VS-Mode Delegates Environment Call from VS-mode exceptions to (H)S-mode. When H is implemented: Environment Call from S-mode exceptions cannot be delegated to VS-mode. Exceptions are never taken into a less-privileged mode, regardless of The handling mode is determined as follows:
| ||||||||||||||||||||||||||||||||||||||||||
EM | 11 | RO | Environment Call from M-Mode An Environment Call from M-mode cannot be delegated, so this is a read-only field. All Environment Call from M-mode exceptions are taken by M-mode. | |||||||||||||||||||||||||||||||||||||||||
IPF | 12 | Instruction Page Fault Delegates Instruction Page Fault exceptions to (H)S-mode. When H is implemented: Instruction Page Fault exceptions may be further delegated to VS-mode if Exceptions are never taken into a less-privileged mode, regardless of The handling mode is determined as follows: When H is implemented:
Otherwise:
| ||||||||||||||||||||||||||||||||||||||||||
LPF | 13 | Load Page Fault Delegates Load Page Fault exceptions to (H)S-mode. When H is implemented: Load Page Fault exceptions may be further delegated to VS-mode if Exceptions are never taken into a less-privileged mode, regardless of The handling mode is determined as follows: When H is implemented:
Otherwise:
| ||||||||||||||||||||||||||||||||||||||||||
SPF | 15 | Store/AMO Page Fault Delegates Store/AMO Page Fault exceptions to (H)S-mode. When H is implemented: Store/AMO Page Fault exceptions may be further delegated to VS-mode if Exceptions are never taken into a less-privileged mode, regardless of The handling mode is determined as follows: When H is implemented:
Otherwise:
| ||||||||||||||||||||||||||||||||||||||||||
IGPF | 20 | Instruction Guest Page Fault Delegates Instruction Guest Page Fault exceptions to (H)S-mode. When H is implemented: Instruction Guest Page Fault exceptions cannot be delegated to VS-mode. Exceptions are never taken into a less-privileged mode, regardless of The handling mode is determined as follows:
| ||||||||||||||||||||||||||||||||||||||||||
LGPF | 21 | Load Guest Page Fault Delegates Load Guest Page Fault exceptions to (H)S-mode. When H is implemented: Load Guest Page Fault exceptions cannot be delegated to VS-mode. Exceptions are never taken into a less-privileged mode, regardless of The handling mode is determined as follows:
| ||||||||||||||||||||||||||||||||||||||||||
VI | 22 | Virtual Instruction Delegates Virtual Instruction exceptions to (H)S-mode. When H is implemented: Virtual Instruction exceptions cannot be delegated to VS-mode. Exceptions are never taken into a less-privileged mode, regardless of The handling mode is determined as follows:
| ||||||||||||||||||||||||||||||||||||||||||
SGPF | 23 | Store/AMO Guest Page Fault Delegates Store/AMO Guest Page Fault exceptions to (H)S-mode. When H is implemented: Store/AMO Guest Page Fault exceptions cannot be delegated to VS-mode. Exceptions are never taken into a less-privileged mode, regardless of The handling mode is determined as follows:
|
Fields from riscv-unified-db; field types computed by IDL functions there are not shown.
Specification and related pages
- The RISC-V Instruction Set Manual, Volume II: CSR listing (src/priv/csrs.adoc)
- riscv-opcodes csrs.csv
- riscv-unified-db: spec/std/isa/csr/medeleg.yaml
- csrrw, csrrs, csrrc (Zicsr instructions that access CSRs)