@@ -2342,9 +2342,15 @@ reg_t aia_ireg_proxy_csr_t::read() const noexcept {
23422342}
23432343
23442344void aia_ireg_proxy_csr_t::verify_permissions (insn_t insn, bool write) const {
2345+ reg_t isel = iselect->read ();
23452346 // skip verfy_permissions chaining on a VS reg because the address is remapped
2346- if (!vs)
2347+ if (!vs) {
2348+ // If the hart has an IMSIC, then when bit 9 of mvien is one, attempts from S-mode to explicitly
2349+ // access the supervisor-level interrupt file raise an illegal instruction exception.
2350+ if (state->prv < PRV_M && (state->mvien ->read () & MIP_SEIP) && isel >= SISELECT_IMSIC && isel <= SISELECT_IMSIC_TOP)
2351+ throw trap_illegal_instruction (insn.bits ());
23472352 csr_t::verify_permissions (insn, write);
2353+ }
23482354 if (get_reg () == nullptr ) {
23492355 if (state->v )
23502356 throw trap_virtual_instruction (insn.bits ());
@@ -2353,7 +2359,6 @@ void aia_ireg_proxy_csr_t::verify_permissions(insn_t insn, bool write) const {
23532359 }
23542360 if (proc->extension_enabled (EXT_SMSTATEEN)) {
23552361 // if iselect >= IMSIC and xSTATEEN_IMSIC not set
2356- reg_t isel = iselect->read ();
23572362 if (!state->v && state->prv < PRV_M && isel >= SISELECT_IMSIC && isel <= SISELECT_IMSIC_TOP && !(state->mstateen [0 ]->read () & MSTATEEN0_IMSIC))
23582363 throw trap_illegal_instruction (insn.bits ());
23592364 if (state->v && isel >= VSISELECT_IMSIC && isel <= VSISELECT_IMSIC_TOP && !(state->hstateen [0 ]->read () & HSTATEEN0_IMSIC))
@@ -2426,6 +2431,11 @@ void nonvirtual_stopei_csr_t::verify_permissions(insn_t insn, bool write) const
24262431 throw trap_virtual_instruction (insn.bits ());
24272432 }
24282433
2434+ // If the hart has an IMSIC, then when bit 9 of mvien is one, attempts from S-mode to explicitly
2435+ // access the supervisor-level interrupt file raise an illegal instruction exception.
2436+ if (state->prv < PRV_M && (state->mvien ->read () & MIP_SEIP))
2437+ throw trap_illegal_instruction (insn.bits ());
2438+
24292439 csr_t::verify_permissions (insn, write);
24302440}
24312441
0 commit comments