diff options
author | Weiwei Li <liweiwei@iscas.ac.cn> | 2022-08-03 22:10:17 +0800 |
---|---|---|
committer | Weiwei Li <liweiwei@iscas.ac.cn> | 2022-08-03 22:19:27 +0800 |
commit | a7de776de66a1c1caea8d896e6ff51503b0a46bf (patch) | |
tree | 99c00399d3aa1fcd734caa6c31078f91b1ed5036 /riscv/csrs.cc | |
parent | eb2cce0c99075f89e77b0c1db92108f9c49ccab0 (diff) | |
download | riscv-isa-sim-a7de776de66a1c1caea8d896e6ff51503b0a46bf.zip riscv-isa-sim-a7de776de66a1c1caea8d896e6ff51503b0a46bf.tar.gz riscv-isa-sim-a7de776de66a1c1caea8d896e6ff51503b0a46bf.tar.bz2 |
Fix exception type for accessing senvcfg/henvcfg/hstateen
Illegal instruciton trap should be raised when accessing senvcfg/
henvcfg/hstateen if related bit of mstateen is zero in VU mode
Diffstat (limited to 'riscv/csrs.cc')
-rw-r--r-- | riscv/csrs.cc | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/riscv/csrs.cc b/riscv/csrs.cc index 4ec404b..875461a 100644 --- a/riscv/csrs.cc +++ b/riscv/csrs.cc @@ -1324,10 +1324,9 @@ bool hstateen_csr_t::unlogged_write(const reg_t val) noexcept { } void hstateen_csr_t::verify_permissions(insn_t insn, bool write) const { - masked_csr_t::verify_permissions(insn, write); - if ((state->prv < PRV_M) && !(state->mstateen[index]->read() & MSTATEEN_HSTATEEN)) throw trap_illegal_instruction(insn.bits()); + masked_csr_t::verify_permissions(insn, write); } // implement class sstateen_csr_t @@ -1372,8 +1371,6 @@ senvcfg_csr_t::senvcfg_csr_t(processor_t* const proc, const reg_t addr, const re } void senvcfg_csr_t::verify_permissions(insn_t insn, bool write) const { - masked_csr_t::verify_permissions(insn, write); - if (proc->extension_enabled(EXT_SMSTATEEN)) { if ((state->prv < PRV_M) && !(state->mstateen[0]->read() & MSTATEEN0_HENVCFG)) throw trap_illegal_instruction(insn.bits()); @@ -1381,13 +1378,15 @@ void senvcfg_csr_t::verify_permissions(insn_t insn, bool write) const { if (state->v && !(state->hstateen[0]->read() & HSTATEEN0_SENVCFG)) throw trap_virtual_instruction(insn.bits()); } -} -void henvcfg_csr_t::verify_permissions(insn_t insn, bool write) const { masked_csr_t::verify_permissions(insn, write); +} +void henvcfg_csr_t::verify_permissions(insn_t insn, bool write) const { if (proc->extension_enabled(EXT_SMSTATEEN)) { if ((state->prv < PRV_M) && !(state->mstateen[0]->read() & MSTATEEN0_HENVCFG)) throw trap_illegal_instruction(insn.bits()); } + + masked_csr_t::verify_permissions(insn, write); } |