mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
Kernel: Make handle_crash available to aarch64
This commit is contained in:
parent
d3b6201b40
commit
6299a69253
8 changed files with 75 additions and 33 deletions
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <LibC/mallocdefs.h>
|
||||
|
||||
#include <Kernel/Arch/CPU.h>
|
||||
#include <Kernel/Arch/PageFault.h>
|
||||
#include <Kernel/Arch/Processor.h>
|
||||
#include <Kernel/Arch/RegisterState.h>
|
||||
|
@ -174,7 +175,7 @@ static EntropySource s_entropy_source_interrupts { EntropySource::Static::Interr
|
|||
|
||||
// clang-format on
|
||||
|
||||
static void dump(RegisterState const& regs)
|
||||
void dump_registers(RegisterState const& regs)
|
||||
{
|
||||
#if ARCH(I386)
|
||||
u16 ss;
|
||||
|
@ -216,35 +217,6 @@ static void dump(RegisterState const& regs)
|
|||
#endif
|
||||
}
|
||||
|
||||
void handle_crash(RegisterState const& regs, char const* description, int signal, bool out_of_memory)
|
||||
{
|
||||
auto* current_thread = Thread::current();
|
||||
if (!current_thread)
|
||||
PANIC("{} with !Thread::current()", description);
|
||||
|
||||
auto crashed_in_kernel = (regs.cs & 3) == 0;
|
||||
if (!crashed_in_kernel && current_thread->has_signal_handler(signal) && !current_thread->should_ignore_signal(signal) && !current_thread->is_signal_masked(signal)) {
|
||||
current_thread->send_urgent_signal_to_self(signal);
|
||||
return;
|
||||
}
|
||||
|
||||
auto& process = current_thread->process();
|
||||
|
||||
// If a process crashed while inspecting another process,
|
||||
// make sure we switch back to the right page tables.
|
||||
Memory::MemoryManager::enter_process_address_space(process);
|
||||
|
||||
dmesgln("CRASH: CPU #{} {} in ring {}", Processor::current_id(), description, (regs.cs & 3));
|
||||
dump(regs);
|
||||
|
||||
if (crashed_in_kernel) {
|
||||
process.address_space().dump_regions();
|
||||
PANIC("Crash in ring 0");
|
||||
}
|
||||
|
||||
process.crash(signal, regs.ip(), out_of_memory);
|
||||
}
|
||||
|
||||
EH_ENTRY_NO_CODE(6, illegal_instruction);
|
||||
void illegal_instruction_handler(TrapFrame* trap)
|
||||
{
|
||||
|
@ -295,7 +267,7 @@ void page_fault_handler(TrapFrame* trap)
|
|||
regs.exception_code & 2 ? "write" : "read",
|
||||
VirtualAddress(fault_address));
|
||||
|
||||
dump(regs);
|
||||
dump_registers(regs);
|
||||
}
|
||||
|
||||
bool faulted_in_kernel = !(regs.cs & 3);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue