Skip to content

Commit

Permalink
Merge pull request #1511 from YenHaoChen/pr-stimecmp
Browse files Browse the repository at this point in the history
stimecmp: perform menvcfg.STCE permission check when accessing vstimecmp in HS-mode
  • Loading branch information
aswaterman authored Nov 25, 2023
2 parents 4841ad0 + 6e6885f commit 90aa49f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions riscv/csrs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,7 @@ virtualized_stimecmp_csr_t::virtualized_stimecmp_csr_t(processor_t* const proc,
virtualized_csr_t(proc, orig, virt) {
}

void virtualized_stimecmp_csr_t::verify_permissions(insn_t insn, bool write) const {
void stimecmp_csr_t::verify_permissions(insn_t insn, bool write) const {
if (!(state->menvcfg->read() & MENVCFG_STCE)) {
// access to (v)stimecmp with MENVCFG.STCE = 0
if (state->prv < PRV_M)
Expand All @@ -1549,7 +1549,11 @@ void virtualized_stimecmp_csr_t::verify_permissions(insn_t insn, bool write) con
throw trap_virtual_instruction(insn.bits());
}

virtualized_csr_t::verify_permissions(insn, write);
basic_csr_t::verify_permissions(insn, write);
}

void virtualized_stimecmp_csr_t::verify_permissions(insn_t insn, bool write) const {
orig_csr->verify_permissions(insn, write);
}

scountovf_csr_t::scountovf_csr_t(processor_t* const proc, const reg_t addr):
Expand Down
1 change: 1 addition & 0 deletions riscv/csrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ class senvcfg_csr_t final: public envcfg_csr_t {
class stimecmp_csr_t: public basic_csr_t {
public:
stimecmp_csr_t(processor_t* const proc, const reg_t addr, const reg_t imask);
virtual void verify_permissions(insn_t insn, bool write) const override;
protected:
virtual bool unlogged_write(const reg_t val) noexcept override;
private:
Expand Down

0 comments on commit 90aa49f

Please sign in to comment.