diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-05-26 02:08:51 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-26 02:35:25 +0200 |
commit | 6ffcee91764583d012ec50baec2088bf547c0534 (patch) | |
tree | 6fbdb61d3be1da8d39a07f53d5ef83b1fb5539f0 /Kernel | |
parent | 0fa098845f0d7d7133b1fea5cde1211aef2ec4a9 (diff) | |
download | serenity-6ffcee91764583d012ec50baec2088bf547c0534.zip |
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.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Process.cpp | 4 | ||||
-rw-r--r-- | Kernel/Process.h | 3 | ||||
-rw-r--r-- | Kernel/i386.cpp | 19 |
3 files changed, 17 insertions, 9 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 4725c3bf52..6764b6e611 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -720,14 +720,14 @@ void Process::sys$sigreturn() ASSERT_NOT_REACHED(); } -void Process::crash() +void Process::crash(int signal) { ASSERT_INTERRUPTS_DISABLED(); ASSERT(!is_dead()); dump_backtrace(); - m_termination_signal = SIGSEGV; + m_termination_signal = signal; dump_regions(); ASSERT(is_ring3()); die(); diff --git a/Kernel/Process.h b/Kernel/Process.h index ff3d4e5e5c..328cb3a788 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -13,6 +13,7 @@ #include <Kernel/UnixTypes.h> #include <Kernel/Thread.h> #include <Kernel/Lock.h> +#include <LibC/signal_numbers.h> class ELFLoader; class FileDescriptor; @@ -191,7 +192,7 @@ public: static void initialize(); - [[noreturn]] void crash(); + [[noreturn]] void crash(int signal = SIGSEGV); [[nodiscard]] static int reap(Process&); const TTY* tty() const { return m_tty; } diff --git a/Kernel/i386.cpp b/Kernel/i386.cpp index 1409da2c43..2a660cf55a 100644 --- a/Kernel/i386.cpp +++ b/Kernel/i386.cpp @@ -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()); - dump(regs); + 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); } |