From fbab2c2bed3db7d52ed0348c5c24859d1f7c505d Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Thu, 14 Nov 2024 06:33:38 -0800 Subject: [PATCH] Merge pull request #1859 from ved-rivos/issue_1857 Add missing priv qualification to prev_virt --- riscv/insns/mret.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/riscv/insns/mret.h b/riscv/insns/mret.h index 71e488d22a..479bfcaf80 100644 --- a/riscv/insns/mret.h +++ b/riscv/insns/mret.h @@ -14,7 +14,7 @@ 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 && prev_prv != PRV_M)) s = set_field(s, MSTATUS_SDT, 0); if (prev_virt && prev_prv == PRV_U) STATE.vsstatus->write(STATE.vsstatus->read() & ~SSTATUS_SDT);