Skip to content

Commit

Permalink
Fix interrupt handling priority inconsistent with specs
Browse files Browse the repository at this point in the history
According to the specs. at 4.1.3
> Multiple simultaneous interrupts destined for supervisor mode are
> handled in the following decreasing priority order: SEI, SSI, STI.

In this commit, I switched the interrupt priority back to SEI at
the highest priority, which is the original implementation.
  • Loading branch information
ranvd committed Jul 3, 2024
1 parent 97bb66e commit 83c29eb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ static bool mmu_store(hart_t *vm,
if (vm->error)
return false;

if (unlikely(cond)){
if (unlikely(cond)) {
if ((vm->lr_reservation != (addr | 1)))
return false;
}
Expand Down Expand Up @@ -805,7 +805,7 @@ void vm_step(hart_t *vm)
vm->current_pc = vm->pc;
if ((vm->sstatus_sie || !vm->s_mode) && (vm->sip & vm->sie)) {
uint32_t applicable = (vm->sip & vm->sie);
uint8_t idx = ffs(applicable) - 1;
uint8_t idx = ilog2(applicable);
if (idx == 1) {
emu_state_t *data = PRIV(vm);
data->clint.msip[vm->mhartid] = 0;
Expand Down

0 comments on commit 83c29eb

Please sign in to comment.