From 4f2e472980d252d43124c3888284fd4098058cf6 Mon Sep 17 00:00:00 2001 From: Ved Shanbhogue Date: Fri, 5 Jul 2024 04:32:09 -0500 Subject: [PATCH] update --- riscv/insns/mret.h | 10 +++------- riscv/insns/sret.h | 16 +++++----------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/riscv/insns/mret.h b/riscv/insns/mret.h index cb3660d966..e06f05534a 100644 --- a/riscv/insns/mret.h +++ b/riscv/insns/mret.h @@ -15,14 +15,10 @@ if (ZICFILP_xLPE(prev_virt, prev_prv)) { s = set_field(s, MSTATUS_MPELP, elp_t::NO_LP_EXPECTED); s = set_field(s, MSTATUS_MDT, 0); -if (prev_prv == PRV_U || prev_virt) { +if (prev_prv == PRV_U || prev_virt) s = set_field(s, MSTATUS_SDT, 0); -} -if (prev_virt && prev_prv == PRV_U) { - reg_t vs = STATE.vsstatus->read(); - vs = set_field(vs, SSTATUS_SDT, 0); - STATE.vsstatus->write(vs); -} +if (prev_virt && prev_prv == PRV_U) + STATE.vsstatus->write(STATE.vsstatus->read() & ~SSTATUS_SDT); STATE.mstatus->write(s); if (STATE.mstatush) STATE.mstatush->write(s >> 32); // log mstatush change diff --git a/riscv/insns/sret.h b/riscv/insns/sret.h index 1dd5206995..e13c54b38c 100644 --- a/riscv/insns/sret.h +++ b/riscv/insns/sret.h @@ -28,17 +28,11 @@ if (ZICFILP_xLPE(prev_virt, prev_prv)) { } if (STATE.prv == PRV_M) { - reg_t m = STATE.mstatus->read(); - m = set_field(m, MSTATUS_MDT, 0); - if (prev_prv == PRV_U || prev_virt) { - s = set_field(s, MSTATUS_SDT, 0); - } - STATE.mstatus->write(m); - if (prev_virt && prev_prv == PRV_U) { - reg_t vs = STATE.vsstatus->read(); - vs = set_field(vs, SSTATUS_SDT, 0); - STATE.vsstatus->write(vs); - } + STATE.mstatus->write(STATE.mstatus->read() & ~MSTATUS_MDT); + if (prev_prv == PRV_U || prev_virt) + STATE.mstatus->write(STATE.mstatus->read() & ~MSTATUS_SDT); + if (prev_virt && prev_prv == PRV_U) + STATE.vsstatus->write(STATE.vsstatus->read() & ~SSTATUS_SDT); } s = set_field(s, SSTATUS_SPELP, elp_t::NO_LP_EXPECTED);