Map a `VmError` to a trap cause/tval pair. Returns `Some((cause, tval))` if the error should trigger a trap, or `None` if it is a fatal error that cannot be trapped.
(e: &VmError)
| 126 | let prev_priv = match mpp { |
| 127 | 0 => PrivilegeMode::User, |
| 128 | 1 => PrivilegeMode::Supervisor, |
| 129 | 3 => PrivilegeMode::Machine, |
| 130 | _ => PrivilegeMode::Machine, // reserved value; treat as Machine |
| 131 | }; |
| 132 | regs.priv_mode = prev_priv; |
| 133 | csrs.mstatus &= !(0x3u64 << 11); // MPP = User |
| 134 | |
| 135 | // Clear MPRV if returning below M-mode. |
| 136 | if prev_priv != PrivilegeMode::Machine { |
| 137 | csrs.mstatus &= !(1u64 << 17); |
| 138 | } |
| 139 | |
| 140 | csrs.mepc |
| 141 | } |
| 142 |
no outgoing calls