← Home

medeleg

Machine Exception Delegation

Address: 0x302 (770) · Privilege: M · Length: 64 · Writable · Defined by: S

Controls exception delegation from M-mode to (H)S-mode

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 `medeleg` is set. * The current privilege level is not M-mode.

* The same field in `hedeleg` is clear.

An exception cause is delegated to VS-mode when all of the following hold:

* The corresponding field in `medeleg` is set. * The corresponding field in `hedeleg` is set. * The current privilege level is not M-mode or HS-mode.

Otherwise, an exception cause is handled by M-mode.

See xref:prose:interrupts.adoc[interrupt documentation] for more details.

Fields

63:5655:4847:4039:3231:2423:1615:87:0
—SGPFVILGPFIGPF—SPF—LPFIPFEMEVSESEUSAFSAMLAFLAMBIIIAFIAM
BitsFieldAliasDescriptionTypeReset
[0]IAM*Instruction Address Misaligned* Delegates Instruction Address Misaligned exceptions to (H)S-mode. Instruction Address Misaligned exceptions may be further delegated to VS-mode if `hedeleg.IAM` is also set. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. The handling mode is determined as follows: .2+! [.rotate]#`medeleg.IAM`# .2+! [.rotate]#`hedeleg.IAM`# 4+^.>! Current Mode .>h! `M-mode` .>h! `HS-mode` .>h! `VS-mode` .>h! `VU-mode` ! 0 ! 0 ! M ! M ! M ! M ! 0 ! 1 ! M ! M ! M ! M ! 1 ! 0 ! M ! HS ! HS ! HS ! 1 ! 1 ! M ! HS ! VS ! VS .2+! [.rotate]#`medeleg.IAM`# 2+^.>! Current Mode .>h! `M-mode` .>h! `S-mode` ! 0 ! M ! M ! 1 ! M ! S
return MEDELEG_DELEGATABLE[0] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[0] ? UNDEFINED_LEGAL : 0;
[1]IAF*Instruction Access Fault* Delegates Instruction Access Fault exceptions to (H)S-mode. Instruction Access Fault exceptions may be further delegated to VS-mode if `hedeleg.IAM` is also set. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. The handling mode is determined as follows: .2+! [.rotate]#`medeleg.IAF`# .2+! [.rotate]#`hedeleg.IAF`# 4+^.>! Current Mode .>h! `M-mode` .>h! `HS-mode` .>h! `VS-mode` .>h! `VU-mode` ! 0 ! 0 ! M ! M ! M ! M ! 0 ! 1 ! M ! M ! M ! M ! 1 ! 0 ! M ! HS ! HS ! HS ! 1 ! 1 ! M ! HS ! VS ! VS .2+! [.rotate]#`medeleg.IAF`# 2+^.>! Current Mode .>h! `M-mode` .>h! `S-mode` ! 0 ! M ! M ! 1 ! M ! S
return MEDELEG_DELEGATABLE[1] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[1] ? UNDEFINED_LEGAL : 0;
[2]II*Illegal Instruction* Delegates Illegal Instruction exceptions to (H)S-mode. Illegal Instruction exceptions may be further delegated to VS-mode if `hedeleg.II` is also set. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. The handling mode is determined as follows: .2+! [.rotate]#`medeleg.II`# .2+! [.rotate]#`hedeleg.II`# 4+^.>! Current Mode .>h! `M-mode` .>h! `HS-mode` .>h! `VS-mode` .>h! `VU-mode` ! 0 ! 0 ! M ! M ! M ! M ! 0 ! 1 ! M ! M ! M ! M ! 1 ! 0 ! M ! HS ! HS ! HS ! 1 ! 1 ! M ! HS ! VS ! VS .2+! [.rotate]#`medeleg.II`# 2+^.>! Current Mode .>h! `M-mode` .>h! `S-mode` ! 0 ! M ! M ! 1 ! M ! S
return MEDELEG_DELEGATABLE[2] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[2] ? UNDEFINED_LEGAL : 0;
[3]B*Breakpoint* Delegates Breakpoint exceptions to (H)S-mode. Breakpoint exceptions may be further delegated to VS-mode if `hedeleg.B` is also set. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. The handling mode is determined as follows: .2+! [.rotate]#`medeleg.B`# .2+! [.rotate]#`hedeleg.B`# 4+^.>! Current Mode .>h! `M-mode` .>h! `HS-mode` .>h! `VS-mode` .>h! `VU-mode` ! 0 ! 0 ! M ! M ! M ! M ! 0 ! 1 ! M ! M ! M ! M ! 1 ! 0 ! M ! HS ! HS ! HS ! 1 ! 1 ! M ! HS ! VS ! VS .2+! [.rotate]#`medeleg.B`# 2+^.>! Current Mode .>h! `M-mode` .>h! `S-mode` ! 0 ! M ! M ! 1 ! M ! S
return MEDELEG_DELEGATABLE[3] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[3] ? UNDEFINED_LEGAL : 0;
[4]LAM*Load Address Misaligned* Delegates Load Address Misaligned exceptions to (H)S-mode. Load Address Misaligned exceptions may be further delegated to VS-mode if `hedeleg.LAM` is also set. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. 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: .2+! [.rotate]#`medeleg.LAM`# .2+! [.rotate]#`hedeleg.LAM`# 4+^.>! Current Mode .>h! `M-mode` .>h! `HS-mode` .>h! `VS-mode` .>h! `VU-mode` ! 0 ! 0 ! M ! M ! M ! M ! 0 ! 1 ! M ! M ! M ! M ! 1 ! 0 ! M ! HS ! HS ! HS ! 1 ! 1 ! M ! HS ! VS ! VS .2+! [.rotate]#`medeleg.LAM`# 2+^.>! Current Mode .>h! `M-mode` .>h! `S-mode` ! 0 ! M ! M ! 1 ! M ! S
return MEDELEG_DELEGATABLE[4] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[4] ? UNDEFINED_LEGAL : 0;
[5]LAF*Load Access Fault* Delegates Load Access Fault exceptions to (H)S-mode. Load Access Fault exceptions may be further delegated to VS-mode if `hedeleg.LAF` is also set. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. The handling mode is determined as follows: .2+! [.rotate]#`medeleg.LAF`# .2+! [.rotate]#`hedeleg.LAF`# 4+^.>! Current Mode .>h! `M-mode` .>h! `HS-mode` .>h! `VS-mode` .>h! `VU-mode` ! 0 ! 0 ! M ! M ! M ! M ! 0 ! 1 ! M ! M ! M ! M ! 1 ! 0 ! M ! HS ! HS ! HS ! 1 ! 1 ! M ! HS ! VS ! VS .2+! [.rotate]#`medeleg.LAF`# 2+^.>! Current Mode .>h! `M-mode` .>h! `S-mode` ! 0 ! M ! M ! 1 ! M ! S
return MEDELEG_DELEGATABLE[5] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[5] ? UNDEFINED_LEGAL : 0;
[6]SAM*Store/AMO Address Misaligned* Delegates Store/AMO Address Misaligned exceptions to (H)S-mode. Store/AMO Address Misaligned exceptions may be further delegated to VS-mode if `hedeleg.SAM` is also set. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. 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: .2+! [.rotate]#`medeleg.SAM`# .2+! [.rotate]#`hedeleg.SAM`# 4+^.>! Current Mode .>h! `M-mode` .>h! `HS-mode` .>h! `VS-mode` .>h! `VU-mode` ! 0 ! 0 ! M ! M ! M ! M ! 0 ! 1 ! M ! M ! M ! M ! 1 ! 0 ! M ! HS ! HS ! HS ! 1 ! 1 ! M ! HS ! VS ! VS .2+! [.rotate]#`medeleg.SAM`# 2+^.>! Current Mode .>h! `M-mode` .>h! `S-mode` ! 0 ! M ! M ! 1 ! M ! S
return MEDELEG_DELEGATABLE[6] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[6] ? UNDEFINED_LEGAL : 0;
[7]SAF*Store/AMO Access Fault* Delegates Store/AMO Access Fault exceptions to (H)S-mode. Store/AMO Access Fault exceptions may be further delegated to VS-mode if `hedeleg.SAM` is also set. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. The handling mode is determined as follows: .2+! [.rotate]#`medeleg.SAF`# .2+! [.rotate]#`hedeleg.SAF`# 4+^.>! Current Mode .>h! `M-mode` .>h! `HS-mode` .>h! `VS-mode` .>h! `VU-mode` ! 0 ! 0 ! M ! M ! M ! M ! 0 ! 1 ! M ! M ! M ! M ! 1 ! 0 ! M ! HS ! HS ! HS ! 1 ! 1 ! M ! HS ! VS ! VS .2+! [.rotate]#`medeleg.SAF`# 2+^.>! Current Mode .>h! `M-mode` .>h! `S-mode` ! 0 ! M ! M ! 1 ! M ! S
return MEDELEG_DELEGATABLE[7] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[7] ? UNDEFINED_LEGAL : 0;
[8]EU*Environment Call from U-Mode* Delegates Environment Call from U-mode exceptions to (H)S-mode. Environment Call from U-mode exceptions may be further delegated to VS-mode if `hedeleg.EU` is also set. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. The handling mode is determined as follows: .2+! [.rotate]#`medeleg.EU`# .2+! [.rotate]#`hedeleg.EU`# 4+^.>! Current Mode .>h! `M-mode` .>h! `HS-mode` .>h! `VS-mode` .>h! `VU-mode` ! 0 ! 0 ! M ! M ! M ! M ! 0 ! 1 ! M ! M ! M ! M ! 1 ! 0 ! M ! HS ! HS ! HS ! 1 ! 1 ! M ! HS ! VS ! VS .2+! [.rotate]#`medeleg.EU`# 2+^.>! Current Mode .>h! `M-mode` .>h! `S-mode` ! 0 ! M ! M ! 1 ! M ! S
return MEDELEG_DELEGATABLE[8] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[8] ? UNDEFINED_LEGAL : 0;
[9]ES*Environment Call from S-Mode* Delegates Environment Call from S-mode exceptions to (H)S-mode. Environment Call from S-mode exceptions _cannot be delegated to VS-mode_. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. The handling mode is determined as follows: .2+! [.rotate]#`medeleg.ES`# 2+^.>! Current Mode .>h! `M-mode` .>h! `(H)S-mode` ! 0 ! M ! M ! 1 ! M ! (H)S
return MEDELEG_DELEGATABLE[9] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[9] ? UNDEFINED_LEGAL : 0;
[10]EVS*Environment Call from VS-Mode* Delegates Environment Call from VS-mode exceptions to (H)S-mode. Environment Call from S-mode exceptions _cannot be delegated to VS-mode_. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. The handling mode is determined as follows: .2+! [.rotate]#`medeleg.EVS`# 2+^.>! Current Mode .>h! `M-mode` .>h! `(H)S-mode` ! 0 ! M ! M ! 1 ! M ! (H)S
return MEDELEG_DELEGATABLE[10] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[10] ? UNDEFINED_LEGAL : 0;
[11]EM*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.RO0
[12]IPF*Instruction Page Fault* Delegates Instruction Page Fault exceptions to (H)S-mode. Instruction Page Fault exceptions may be further delegated to VS-mode if `hedeleg.IPF` is also set. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. The handling mode is determined as follows: .2+! [.rotate]#`medeleg.IPF`# .2+! [.rotate]#`hedeleg.IPF`# 4+^.>! Current Mode .>h! `M-mode` .>h! `HS-mode` .>h! `VS-mode` .>h! `VU-mode` ! 0 ! 0 ! M ! M ! M ! M ! 0 ! 1 ! M ! M ! M ! M ! 1 ! 0 ! M ! HS ! HS ! HS ! 1 ! 1 ! M ! HS ! VS ! VS .2+! [.rotate]#`medeleg.IPF`# 2+^.>! Current Mode .>h! `M-mode` .>h! `S-mode` ! 0 ! M ! M ! 1 ! M ! S
return MEDELEG_DELEGATABLE[12] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[12] ? UNDEFINED_LEGAL : 0;
[13]LPF*Load Page Fault* Delegates Load Page Fault exceptions to (H)S-mode. Load Page Fault exceptions may be further delegated to VS-mode if `hedeleg.LPF` is also set. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. The handling mode is determined as follows: .2+! [.rotate]#`medeleg.LPF`# .2+! [.rotate]#`hedeleg.LPF`# 4+^.>! Current Mode .>h! `M-mode` .>h! `HS-mode` .>h! `VS-mode` .>h! `VU-mode` ! 0 ! 0 ! M ! M ! M ! M ! 0 ! 1 ! M ! M ! M ! M ! 1 ! 0 ! M ! HS ! HS ! HS ! 1 ! 1 ! M ! HS ! VS ! VS .2+! [.rotate]#`medeleg.LPF`# 2+^.>! Current Mode .>h! `M-mode` .>h! `S-mode` ! 0 ! M ! M ! 1 ! M ! S
return MEDELEG_DELEGATABLE[13] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[13] ? UNDEFINED_LEGAL : 0;
[15]SPF*Store/AMO Page Fault* Delegates Store/AMO Page Fault exceptions to (H)S-mode. Store/AMO Page Fault exceptions may be further delegated to VS-mode if `hedeleg.SPF` is also set. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. The handling mode is determined as follows: .2+! [.rotate]#`medeleg.SPF`# .2+! [.rotate]#`hedeleg.SPF`# 4+^.>! Current Mode .>h! `M-mode` .>h! `HS-mode` .>h! `VS-mode` .>h! `VU-mode` ! 0 ! 0 ! M ! M ! M ! M ! 0 ! 1 ! M ! M ! M ! M ! 1 ! 0 ! M ! HS ! HS ! HS ! 1 ! 1 ! M ! HS ! VS ! VS .2+! [.rotate]#`medeleg.LPF`# 2+^.>! Current Mode .>h! `M-mode` .>h! `S-mode` ! 0 ! M ! M ! 1 ! M ! S
return MEDELEG_DELEGATABLE[15] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[15] ? UNDEFINED_LEGAL : 0;
[20]IGPF*Instruction Guest Page Fault* Delegates Instruction Guest Page Fault exceptions to (H)S-mode. Instruction Guest Page Fault exceptions _cannot be delegated to VS-mode_. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. The handling mode is determined as follows: .2+! [.rotate]#`medeleg.IGPF`# 2+^.>! Current Mode .>h! `M-mode` .>h! `(H)S-mode` ! 0 ! M ! M ! 1 ! M ! HS
return MEDELEG_DELEGATABLE[20] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[20] ? UNDEFINED_LEGAL : 0;
[21]LGPF*Load Guest Page Fault* Delegates Load Guest Page Fault exceptions to (H)S-mode. Load Guest Page Fault exceptions _cannot be delegated to VS-mode_. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. The handling mode is determined as follows: .2+! [.rotate]#`medeleg.LGPF`# 2+^.>! Current Mode .>h! `M-mode` .>h! `(H)S-mode` ! 0 ! M ! M ! 1 ! M ! HS
return MEDELEG_DELEGATABLE[21] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[21] ? UNDEFINED_LEGAL : 0;
[22]VI*Virtual Instruction* Delegates Virtual Instruction exceptions to (H)S-mode. Virtual Instruction exceptions _cannot be delegated to VS-mode_. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. The handling mode is determined as follows: .2+! [.rotate]#`medeleg.VI`# 2+^.>! Current Mode .>h! `M-mode` .>h! `(H)S-mode` ! 0 ! M ! M ! 1 ! M ! HS
return MEDELEG_DELEGATABLE[22] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[22] ? UNDEFINED_LEGAL : 0;
[23]SGPF*Store/AMO Guest Page Fault* Delegates Store/AMO Guest Page Fault exceptions to (H)S-mode. Store/AMO Guest Page Fault exceptions _cannot be delegated to VS-mode_. Exceptions are never taken into a less-privileged mode, regardless of `medeleg`. The handling mode is determined as follows: .2+! [.rotate]#`medeleg.SGPF`# 2+^.>! Current Mode .>h! `M-mode` .>h! `(H)S-mode` ! 0 ! M ! M ! 1 ! M ! HS
return MEDELEG_DELEGATABLE[23] ? CsrFieldType::RW : CsrFieldType::RO;
return MEDELEG_DELEGATABLE[23] ? UNDEFINED_LEGAL : 0;

Version af3eaf9+cheriot.f635218

Data from the RISC-V Unified Database, copyright RISC-V International and contributors.

CHERIoT extensions from the CHERIoT specification and Sail model, copyright Microsoft and the CHERIoT Platform contributors.

This site is provided as a community resource and is NOT affiliated with nor endorsed by RISC-V International.