From 64972b7d9fb8c3fa98f96f4bac9cfb49f0ec0c51 Mon Sep 17 00:00:00 2001 From: Ved Shanbhogue Date: Thu, 14 Nov 2024 06:37:24 -0600 Subject: [PATCH] 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);