diff options
author | Andrew Waterman <andrew@sifive.com> | 2020-09-24 17:34:24 -0700 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2020-09-24 17:34:24 -0700 |
commit | 14ad0d98e45c74e824592b9f2f8b65cf1c07ead1 (patch) | |
tree | 94d780b0ab94b6feb8550740b874aab12af04810 /riscv | |
parent | c6a5585849f4d446706dfcc904b9a422bd2b3067 (diff) | |
download | spike-14ad0d98e45c74e824592b9f2f8b65cf1c07ead1.zip spike-14ad0d98e45c74e824592b9f2f8b65cf1c07ead1.tar.gz spike-14ad0d98e45c74e824592b9f2f8b65cf1c07ead1.tar.bz2 |
Correctly respect mstatus.TSR
It never has effect when V=1.
Diffstat (limited to 'riscv')
-rw-r--r-- | riscv/insns/sret.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/riscv/insns/sret.h b/riscv/insns/sret.h index 4423506..315f4f0 100644 --- a/riscv/insns/sret.h +++ b/riscv/insns/sret.h @@ -1,7 +1,10 @@ require_extension('S'); -if (STATE.v && (STATE.prv == PRV_U || get_field(STATE.hstatus, HSTATUS_VTSR))) - require_novirt(); -require_privilege(get_field(STATE.mstatus, MSTATUS_TSR) ? PRV_M : PRV_S); +if (STATE.v) { + if (STATE.prv == PRV_U || get_field(STATE.hstatus, HSTATUS_VTSR)) + require_novirt(); +} else { + require_privilege(get_field(STATE.mstatus, MSTATUS_TSR) ? PRV_M : PRV_S); +} reg_t next_pc = (STATE.v) ? p->get_state()->vsepc : p->get_state()->sepc; set_pc_and_serialize(next_pc); reg_t s = STATE.mstatus; |