Skip to content

Commit 0f88756

Browse files
authored
Merge pull request #2013 from binno/aia_fix
Ensure AIA extension enabled when accessing hvictl
2 parents 065950a + 5d0ab7e commit 0f88756

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

riscv/csrs.cc

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -890,9 +890,11 @@ 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) &&
894-
proc->extension_enabled('S') && state->v)
895-
throw trap_virtual_instruction(insn.bits()); // VS-mode attempts to access sip when hvictl.VTI=1
893+
if (proc->extension_enabled_const(EXT_SSAIA) && proc->extension_enabled('H')) {
894+
if ((state->csrmap[CSR_HVICTL]->read() & HVICTL_VTI) &&
895+
proc->extension_enabled('S') && state->v)
896+
throw trap_virtual_instruction(insn.bits()); // VS-mode attempts to access sip when hvictl.VTI=1
897+
}
896898
}
897899

898900
reg_t mip_proxy_csr_t::read() const noexcept {
@@ -912,9 +914,11 @@ mie_proxy_csr_t::mie_proxy_csr_t(processor_t* const proc, const reg_t addr, gene
912914

913915
void mie_proxy_csr_t::verify_permissions(insn_t insn, bool write) const {
914916
csr_t::verify_permissions(insn, write);
915-
if ((state->csrmap[CSR_HVICTL]->read() & HVICTL_VTI) &&
916-
proc->extension_enabled('S') && state->v)
917-
throw trap_virtual_instruction(insn.bits()); // VS-mode attempts to access sie when hvictl.VTI=1
917+
if (proc->extension_enabled_const(EXT_SSAIA) && proc->extension_enabled('H')) {
918+
if ((state->csrmap[CSR_HVICTL]->read() & HVICTL_VTI) &&
919+
proc->extension_enabled('S') && state->v)
920+
throw trap_virtual_instruction(insn.bits()); // VS-mode attempts to access sie when hvictl.VTI=1
921+
}
918922
}
919923

920924
reg_t mie_proxy_csr_t::read() const noexcept {
@@ -1731,8 +1735,10 @@ void stimecmp_csr_t::verify_permissions(insn_t insn, bool write) const {
17311735

17321736
basic_csr_t::verify_permissions(insn, write);
17331737

1734-
if ((state->csrmap[CSR_HVICTL]->read() & HVICTL_VTI) && state->v && write)
1735-
throw trap_virtual_instruction(insn.bits());
1738+
if (proc->extension_enabled_const(EXT_SSAIA) && proc->extension_enabled('H')) {
1739+
if ((state->csrmap[CSR_HVICTL]->read() & HVICTL_VTI) && state->v && write)
1740+
throw trap_virtual_instruction(insn.bits());
1741+
}
17361742
}
17371743

17381744
virtualized_with_special_permission_csr_t::virtualized_with_special_permission_csr_t(processor_t* const proc, csr_t_p orig, csr_t_p virt):

0 commit comments

Comments
 (0)