Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stimecmp: perform menvcfg.STCE permission check when accessing vstimecmp in HS-mode #1511

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading