From 853105c659094122ef0769780645848646a4f463 Mon Sep 17 00:00:00 2001 From: Chih-Min Chao Date: Thu, 23 May 2024 02:24:15 -0700 Subject: zicflip: fix [ms]ret behavior Based on Spec chapter 3.5 "An MRET or SRET instruction is used to return from a trap in M-mode or S-mode, respectively. When executing an xRET instruction, if xPP holds the value y, then ELP is set to the value of xPELP if yLPE is 1; otherwise, it is set to NO_LP_EXPECTED; xPELP is set to NO_LP_EXPECTED." The change follow the last statement after semicolon "xPELP is set to NO_LP_EXPECTED" Signed-off-by: Chih-Min Chao --- riscv/insns/mret.h | 2 +- riscv/insns/sret.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'riscv') diff --git a/riscv/insns/mret.h b/riscv/insns/mret.h index 1133e86..6d4d59f 100644 --- a/riscv/insns/mret.h +++ b/riscv/insns/mret.h @@ -11,8 +11,8 @@ s = set_field(s, MSTATUS_MPP, p->extension_enabled('U') ? PRV_U : PRV_M); s = set_field(s, MSTATUS_MPV, 0); if (ZICFILP_xLPE(prev_virt, prev_prv)) { STATE.elp = static_cast(get_field(s, MSTATUS_MPELP)); - s = set_field(s, MSTATUS_MPELP, elp_t::NO_LP_EXPECTED); } +s = set_field(s, MSTATUS_MPELP, elp_t::NO_LP_EXPECTED); STATE.mstatus->write(s); if (STATE.mstatush) STATE.mstatush->write(s >> 32); // log mstatush change p->set_privilege(prev_prv, prev_virt); diff --git a/riscv/insns/sret.h b/riscv/insns/sret.h index aeaf087..23a13b5 100644 --- a/riscv/insns/sret.h +++ b/riscv/insns/sret.h @@ -25,7 +25,7 @@ if (!STATE.v) { } if (ZICFILP_xLPE(prev_virt, prev_prv)) { STATE.elp = static_cast(get_field(s, SSTATUS_SPELP)); - s = set_field(s, SSTATUS_SPELP, elp_t::NO_LP_EXPECTED); } +s = set_field(s, SSTATUS_SPELP, elp_t::NO_LP_EXPECTED); STATE.sstatus->write(s); p->set_privilege(prev_prv, prev_virt); -- cgit v1.1