diff options
author | Scott Johnson <scott.johnson@arilinc.com> | 2023-05-24 14:57:21 -0700 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2023-05-25 14:35:43 -0700 |
commit | 4e509bfbc60e28eefef07f1c65aeca3b8d89615f (patch) | |
tree | 57f3776153e2d73e5ba65d5a66a191fcbf65ad53 /riscv/insns | |
parent | e7f677b57fed9f753c16b48c255a7067424d6e69 (diff) | |
download | riscv-isa-sim-4e509bfbc60e28eefef07f1c65aeca3b8d89615f.zip riscv-isa-sim-4e509bfbc60e28eefef07f1c65aeca3b8d89615f.tar.gz riscv-isa-sim-4e509bfbc60e28eefef07f1c65aeca3b8d89615f.tar.bz2 |
Redo sret to put set_virt/set_privilege together
Diffstat (limited to 'riscv/insns')
-rw-r--r-- | riscv/insns/sret.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/riscv/insns/sret.h b/riscv/insns/sret.h index 5102c15..82c238b 100644 --- a/riscv/insns/sret.h +++ b/riscv/insns/sret.h @@ -14,14 +14,15 @@ 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); STATE.sstatus->write(s); -p->set_privilege(prev_prv); +bool prev_virt = STATE.v; if (!STATE.v) { if (p->extension_enabled('H')) { - reg_t prev_virt = get_field(prev_hstatus, HSTATUS_SPV); - p->set_virt(prev_virt); + prev_virt = get_field(prev_hstatus, HSTATUS_SPV); reg_t new_hstatus = set_field(prev_hstatus, HSTATUS_SPV, 0); STATE.hstatus->write(new_hstatus); } STATE.mstatus->write(set_field(STATE.mstatus->read(), MSTATUS_MPRV, 0)); } +p->set_privilege(prev_prv); +p->set_virt(prev_virt); |