diff options
author | YenHaoChen <howard25336284@gmail.com> | 2023-05-22 15:02:56 +0800 |
---|---|---|
committer | YenHaoChen <howard25336284@gmail.com> | 2023-05-23 10:24:40 +0800 |
commit | 4dfdf00f13333ae9f59f2c98a1e56bfc33572701 (patch) | |
tree | d39bed99244746f1d2fe1fc97da1339132b898fe /riscv | |
parent | 8780656d5aed11a9102bde440e3d9434bae28b7d (diff) | |
download | riscv-isa-sim-4dfdf00f13333ae9f59f2c98a1e56bfc33572701.zip riscv-isa-sim-4dfdf00f13333ae9f59f2c98a1e56bfc33572701.tar.gz riscv-isa-sim-4dfdf00f13333ae9f59f2c98a1e56bfc33572701.tar.bz2 |
Let mstatus.MPP initially be M-mode if unsupporting U-mode
This commit lets the mstatus.MPP be a valid value if unsupporting
U-mode. Without this commit, the mret may result in a corrupted state
without properly setting the MPP to M-mode (if unsupporting U-mode).
Diffstat (limited to 'riscv')
-rw-r--r-- | riscv/csrs.cc | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/riscv/csrs.cc b/riscv/csrs.cc index 2e01983..396f42f 100644 --- a/riscv/csrs.cc +++ b/riscv/csrs.cc @@ -510,6 +510,7 @@ reg_t mstatus_csr_t::compute_mstatus_initial_value() const noexcept { | (proc->extension_enabled_const('S') ? MSTATUS_SBE : 0) | MSTATUS_MBE; return 0 + | set_field((reg_t)0, MSTATUS_MPP, proc->extension_enabled_const('U') ? PRV_U : PRV_M) | (proc->extension_enabled_const('U') && (proc->get_const_xlen() != 32) ? set_field((reg_t)0, MSTATUS_UXL, xlen_to_uxl(proc->get_const_xlen())) : 0) | (proc->extension_enabled_const('S') && (proc->get_const_xlen() != 32) ? set_field((reg_t)0, MSTATUS_SXL, xlen_to_uxl(proc->get_const_xlen())) : 0) | (proc->get_mmu()->is_target_big_endian() ? big_endian_bits : 0) |