Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kernel] Add kernel and user mode divide by zero handling #1969

Merged
merged 1 commit into from
Aug 20, 2024
Merged

Conversation

ghaerr
Copy link
Owner

@ghaerr ghaerr commented Aug 20, 2024

Adds handler for divide by zero and divide overflow hardware exception thrown in DIV or IDIV instructions.

Solves problem identified in Mellvik/TLVC#71 (comment).

If the fault occurs from a user application, a SIGABRT signal (ELKS has no SIGFPE) is sent, which usually causes program termination. For kernel faults, a divide by zero panic message is shown and the kernel stops executing. Restarting any code after a DIV exception turns out to be quite complicated, as the hardware fault pushes a different CS:IP depending on whether the CPU is prior to an 80286 or not.

Also removed/rewrote "IRQ allocation" scheme used in irq.c as overly complicated, which saves ~100 bytes in kernel. It is now easy to add any other hardware trap/fault handler to the kernel should that be wanted.

Removed intr_count global from irqtab.S as unneeded, the _gint_count variable already tracks kernel reentry.

@ghaerr ghaerr merged commit 20e283b into master Aug 20, 2024
2 checks passed
@ghaerr ghaerr deleted the div0 branch August 20, 2024 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant