Skip to content

Commit 4b215f1

Browse files
rmn30nwf-msr
authored andcommitted
Fix handling of msatus.MIE in M-mode only case.
Previously if neither user or supervisor mode are present dispatchInterrupt ignored mstatus.MIE leading to an infinite interrupt loop.
1 parent 64eadbb commit 4b215f1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

model/riscv_sys_control.sail

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,14 @@ function dispatchInterrupt(priv : Privilege) -> option((InterruptType, Privilege
268268
*/
269269
if not(haveUsrMode()) | (not(haveSupMode()) & not(haveNExt())) then {
270270
assert(priv == Machine, "invalid current privilege");
271-
let enabled_pending = mip.bits & mie.bits;
272-
match findPendingInterrupt(enabled_pending) {
273-
Some(i) => let r = (i, Machine) in Some(r),
274-
None() => None()
271+
if mstatus[MIE] == 0b1 then {
272+
let enabled_pending = mip.bits & mie.bits;
273+
match findPendingInterrupt(enabled_pending) {
274+
Some(i) => let r = (i, Machine) in Some(r),
275+
None() => None()
276+
}
277+
} else {
278+
None()
275279
}
276280
} else {
277281
match getPendingSet(priv) {

0 commit comments

Comments
 (0)