Skip to content

Commit 89820b0

Browse files
committed
AIA: check H extension before reading hvictl
1 parent 0090dcc commit 89820b0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

riscv/csrs.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ mip_proxy_csr_t::mip_proxy_csr_t(processor_t* const proc, const reg_t addr, gene
890890

891891
void mip_proxy_csr_t::verify_permissions(insn_t insn, bool write) const {
892892
csr_t::verify_permissions(insn, write);
893-
if ((state->csrmap[CSR_HVICTL]->read() & HVICTL_VTI) &&
893+
if (proc->extension_enabled('H') && (state->csrmap[CSR_HVICTL]->read() & HVICTL_VTI) &&
894894
proc->extension_enabled('S') && state->v)
895895
throw trap_virtual_instruction(insn.bits()); // VS-mode attempts to access sip when hvictl.VTI=1
896896
}
@@ -912,7 +912,7 @@ mie_proxy_csr_t::mie_proxy_csr_t(processor_t* const proc, const reg_t addr, gene
912912

913913
void mie_proxy_csr_t::verify_permissions(insn_t insn, bool write) const {
914914
csr_t::verify_permissions(insn, write);
915-
if ((state->csrmap[CSR_HVICTL]->read() & HVICTL_VTI) &&
915+
if (proc->extension_enabled('H') && (state->csrmap[CSR_HVICTL]->read() & HVICTL_VTI) &&
916916
proc->extension_enabled('S') && state->v)
917917
throw trap_virtual_instruction(insn.bits()); // VS-mode attempts to access sie when hvictl.VTI=1
918918
}
@@ -1731,7 +1731,7 @@ void stimecmp_csr_t::verify_permissions(insn_t insn, bool write) const {
17311731

17321732
basic_csr_t::verify_permissions(insn, write);
17331733

1734-
if ((state->csrmap[CSR_HVICTL]->read() & HVICTL_VTI) && state->v && write)
1734+
if (proc->extension_enabled('H') && (state->csrmap[CSR_HVICTL]->read() & HVICTL_VTI) && state->v && write)
17351735
throw trap_virtual_instruction(insn.bits());
17361736
}
17371737

0 commit comments

Comments
 (0)