diff options
author | Weiwei Li <liweiwei@iscas.ac.cn> | 2022-07-08 10:00:00 +0800 |
---|---|---|
committer | Weiwei Li <liweiwei@iscas.ac.cn> | 2022-07-21 08:50:26 +0800 |
commit | eff4011f24390017e4582cb8556ebc6e5ce41d61 (patch) | |
tree | beeb3ca5c891894ea893f37b14ff55ceb06ccdff | |
parent | 3ff1b5f1c6c6e13777be1c677abc2340f3dabd1a (diff) | |
download | riscv-isa-sim-eff4011f24390017e4582cb8556ebc6e5ce41d61.zip riscv-isa-sim-eff4011f24390017e4582cb8556ebc6e5ce41d61.tar.gz riscv-isa-sim-eff4011f24390017e4582cb8556ebc6e5ce41d61.tar.bz2 |
add base verify_permission in counter_proxy_csr_t::verify_permissions
Normally, csrs will reuse the checks in verify_permissions of its base csr type
This modification will not cause any functional change, just reuse the check
in csr_t class to check whether it writes to read-only csr instead of checking
writes to counter_proxy_csr_t by itself.
-rw-r--r-- | riscv/csrs.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/riscv/csrs.cc b/riscv/csrs.cc index 8cb9953..27bef5e 100644 --- a/riscv/csrs.cc +++ b/riscv/csrs.cc @@ -1001,11 +1001,13 @@ bool counter_proxy_csr_t::myenable(csr_t_p counteren) const noexcept { } void counter_proxy_csr_t::verify_permissions(insn_t insn, bool write) const { + proxy_csr_t::verify_permissions(insn, write); + const bool mctr_ok = (state->prv < PRV_M) ? myenable(state->mcounteren) : true; const bool hctr_ok = state->v ? myenable(state->hcounteren) : true; const bool sctr_ok = (proc->extension_enabled('S') && state->prv < PRV_S) ? myenable(state->scounteren) : true; - if (write || !mctr_ok) + if (!mctr_ok) throw trap_illegal_instruction(insn.bits()); if (!hctr_ok) throw trap_virtual_instruction(insn.bits()); |