1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 00:17:46 +00:00

Kernel: Send more specific signals when crashing due to CPU exceptions.

- For division by zero, send SIGFPE.
- For illegal instruction, send SIGILL.
- For the rest, default to SIGSEGV.
This commit is contained in:
Andreas Kling 2019-05-26 02:08:51 +02:00
parent 0fa098845f
commit 6ffcee9176
3 changed files with 17 additions and 9 deletions

View file

@ -167,19 +167,22 @@ void exception_6_handler(RegisterDump& regs)
kprintf("#UD with !current\n");
hang();
}
kprintf("%s invalid opcode: %u(%s)\n", current->process().is_ring0() ? "Kernel" : "Process", current->pid(), current->process().name().characters());
kprintf("%s Illegal instruction: %s(%u)\n",
current->process().is_ring0() ? "Kernel" : "Process",
current->process().name().characters(),
current->pid()
);
dump(regs);
dump_backtrace();
if (current->process().is_ring0()) {
kprintf("Oh shit, we've crashed in ring 0 :(\n");
hang();
}
hang();
current->process().crash();
current->process().crash(SIGILL);
}
// 7: FPU not available exception
@ -216,7 +219,11 @@ void exception_7_handler(RegisterDump& regs)
EH_ENTRY_NO_CODE(0);
void exception_0_handler(RegisterDump& regs)
{
kprintf("%s DIVIDE ERROR: %u(%s)\n", current->process().is_ring0() ? "Kernel" : "User", current->pid(), current->process().name().characters());
kprintf("%s Division by zero: %s(%u)\n",
current->process().is_ring0() ? "Kernel" : "User",
current->process().name().characters(),
current->pid()
);
dump(regs);
@ -225,7 +232,7 @@ void exception_0_handler(RegisterDump& regs)
hang();
}
current->process().crash();
current->process().crash(SIGFPE);
}