From: Luke Kenneth Casson Leighton Date: Thu, 27 Jun 2019 20:57:47 +0000 (+0100) Subject: restore svstate on exit from trap (mret, sret) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a8c6b7f224660bdf5e867968ed17e7ae4fe8b04d;p=riscv-isa-sim.git restore svstate on exit from trap (mret, sret) --- diff --git a/riscv/insns/mret.h b/riscv/insns/mret.h index 96933cf..2e2e811 100644 --- a/riscv/insns/mret.h +++ b/riscv/insns/mret.h @@ -1,9 +1,11 @@ require_privilege(PRV_M); set_pc_and_serialize(p->get_state()->mepc); reg_t s = STATE.mstatus; +reg_t svstate = STATE.mesvstate; reg_t prev_prv = get_field(s, MSTATUS_MPP); 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); p->set_privilege(prev_prv); p->set_csr(CSR_MSTATUS, s); +p->set_csr(CSR_SV_STATE, svstate); diff --git a/riscv/insns/sret.h b/riscv/insns/sret.h index ae841de..0437bf9 100644 --- a/riscv/insns/sret.h +++ b/riscv/insns/sret.h @@ -1,9 +1,11 @@ require_privilege(get_field(STATE.mstatus, MSTATUS_TSR) ? PRV_M : PRV_S); set_pc_and_serialize(p->get_state()->sepc); reg_t s = STATE.mstatus; +reg_t svstate = STATE.sesvstate; reg_t prev_prv = get_field(s, MSTATUS_SPP); s = set_field(s, MSTATUS_SIE, get_field(s, MSTATUS_SPIE)); s = set_field(s, MSTATUS_SPIE, 1); s = set_field(s, MSTATUS_SPP, PRV_U); p->set_privilege(prev_prv); p->set_csr(CSR_MSTATUS, s); +p->set_csr(CSR_SV_STATE, svstate);