Skip to content

Commit

Permalink
entry: use IMR to try detect GPF [fixes #237]
Browse files Browse the repository at this point in the history
Using ISR is unsafe because programs can legally chain to the prev
inthandler after EOI. We can rely on the fact that IRQ5 is masked
in IMR by default. If this is the case, then its most certainly a
GPF, so we can terminate the process. But if its not masked, always
pass to prev inthandler.
  • Loading branch information
stsp committed Nov 21, 2023
1 parent 2a33eb2 commit 7dd4d20
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions kernel/entry.asm
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,10 @@ rst0d:
retf
hdlr0d:
push ax
mov al, 0Bh ; request In-Service Register (ISR)
out 20h, al ; from primary PIC
in al, 20h ; read the ISR
test al, 10_0000b ; IRQ #5 occurred ?
in al, 21h ; read the IMR
test al, 10_0000b ; IRQ #5 masked ?
pop ax
jnz @2 ; yes, (likely) not a GPF
jz @2 ; no, (likely) not a GPF
mov si,gpf_message
jmp zero_message_loop
@2:
Expand Down

0 comments on commit 7dd4d20

Please sign in to comment.