diff options
author | Chih-Min Chao <chihmin.chao@sifive.com> | 2022-02-20 23:04:29 -0800 |
---|---|---|
committer | Chih-Min Chao <chihmin.chao@sifive.com> | 2022-02-23 19:13:20 -0800 |
commit | 7fd56cfbb0301b06b3e8d45577c3487deddc9c94 (patch) | |
tree | b41e83efcd55d096c3c62e347da5a40e1295e525 /riscv | |
parent | a498c47a73aff56345d45844fe637c6edfdfdb11 (diff) | |
download | riscv-isa-sim-7fd56cfbb0301b06b3e8d45577c3487deddc9c94.zip riscv-isa-sim-7fd56cfbb0301b06b3e8d45577c3487deddc9c94.tar.gz riscv-isa-sim-7fd56cfbb0301b06b3e8d45577c3487deddc9c94.tar.bz2 |
csr: hyper: fix mstatus.mpp after mret
By spec 3.1.6.1 (original behavior)
"x PP is set to the least-privileged supported
mode (U if U-mode is implemented, else M)"
By spec 8.6.4 (h-extension)
"MRET first determines what the new privilege mode will be according to
the values of MPP and MPV in mstatus or mstatush, as encoded in Table 8.8.
MRET then in mstatus/mstatush sets MPV=0, MPP=0, MIE=MPIE, and
MPIE=1"
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
Diffstat (limited to 'riscv')
-rw-r--r-- | riscv/insns/mret.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/riscv/insns/mret.h b/riscv/insns/mret.h index be9f247..77847dd 100644 --- a/riscv/insns/mret.h +++ b/riscv/insns/mret.h @@ -7,7 +7,7 @@ if (prev_prv != PRV_M) s = set_field(s, MSTATUS_MPRV, 0); s = set_field(s, MSTATUS_MIE, get_field(s, MSTATUS_MPIE)); s = set_field(s, MSTATUS_MPIE, 1); -s = set_field(s, MSTATUS_MPP, PRV_U); +s = set_field(s, MSTATUS_MPP, p->extension_enabled('U') ? PRV_U : PRV_M); s = set_field(s, MSTATUS_MPV, 0); p->set_csr(CSR_MSTATUS, s); p->set_privilege(prev_prv); |