mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 19:19:44 +03:00
Kernel: Make handle_crash available to aarch64
This commit is contained in:
parent
d3b6201b40
commit
6299a69253
Notes:
sideshowbarker
2024-07-17 14:35:31 +09:00
Author: https://github.com/jamesmintram Commit: https://github.com/SerenityOS/serenity/commit/6299a69253 Pull-request: https://github.com/SerenityOS/serenity/pull/13447
@ -21,4 +21,7 @@ namespace Kernel {
|
|||||||
|
|
||||||
struct RegisterState;
|
struct RegisterState;
|
||||||
|
|
||||||
|
void dump_registers(RegisterState const& regs);
|
||||||
|
void handle_crash(RegisterState const&, char const* description, int signal, bool out_of_memory = false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
16
Kernel/Arch/aarch64/CrashHandler.cpp
Normal file
16
Kernel/Arch/aarch64/CrashHandler.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Kernel/Arch/CPU.h>
|
||||||
|
#include <Kernel/Arch/RegisterState.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
|
void handle_crash(Kernel::RegisterState const&, char const*, int, bool)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -6,8 +6,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
struct RegisterState {
|
struct RegisterState {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DebugRegisterState {
|
struct DebugRegisterState {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -36,8 +36,6 @@ inline u32 get_iopl_from_eflags(u32 eflags)
|
|||||||
DescriptorTablePointer const& get_gdtr();
|
DescriptorTablePointer const& get_gdtr();
|
||||||
DescriptorTablePointer const& get_idtr();
|
DescriptorTablePointer const& get_idtr();
|
||||||
|
|
||||||
void handle_crash(RegisterState const&, char const* description, int signal, bool out_of_memory = false);
|
|
||||||
|
|
||||||
#define LSW(x) ((u32)(x)&0xFFFF)
|
#define LSW(x) ((u32)(x)&0xFFFF)
|
||||||
#define MSW(x) (((u32)(x) >> 16) & 0xFFFF)
|
#define MSW(x) (((u32)(x) >> 16) & 0xFFFF)
|
||||||
#define LSB(x) ((x)&0xFF)
|
#define LSB(x) ((x)&0xFF)
|
||||||
|
45
Kernel/Arch/x86/common/CrashHandler.cpp
Normal file
45
Kernel/Arch/x86/common/CrashHandler.cpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Kernel/Arch/CPU.h>
|
||||||
|
#include <Kernel/Arch/RegisterState.h>
|
||||||
|
|
||||||
|
#include <Kernel/Panic.h>
|
||||||
|
#include <Kernel/Process.h>
|
||||||
|
#include <Kernel/Thread.h>
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
|
void handle_crash(Kernel::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_registers(regs);
|
||||||
|
|
||||||
|
if (crashed_in_kernel) {
|
||||||
|
process.address_space().dump_regions();
|
||||||
|
PANIC("Crash in ring 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
process.crash(signal, regs.ip(), out_of_memory);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <LibC/mallocdefs.h>
|
#include <LibC/mallocdefs.h>
|
||||||
|
|
||||||
|
#include <Kernel/Arch/CPU.h>
|
||||||
#include <Kernel/Arch/PageFault.h>
|
#include <Kernel/Arch/PageFault.h>
|
||||||
#include <Kernel/Arch/Processor.h>
|
#include <Kernel/Arch/Processor.h>
|
||||||
#include <Kernel/Arch/RegisterState.h>
|
#include <Kernel/Arch/RegisterState.h>
|
||||||
@ -174,7 +175,7 @@ static EntropySource s_entropy_source_interrupts { EntropySource::Static::Interr
|
|||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
static void dump(RegisterState const& regs)
|
void dump_registers(RegisterState const& regs)
|
||||||
{
|
{
|
||||||
#if ARCH(I386)
|
#if ARCH(I386)
|
||||||
u16 ss;
|
u16 ss;
|
||||||
@ -216,35 +217,6 @@ static void dump(RegisterState const& regs)
|
|||||||
#endif
|
#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);
|
EH_ENTRY_NO_CODE(6, illegal_instruction);
|
||||||
void illegal_instruction_handler(TrapFrame* trap)
|
void illegal_instruction_handler(TrapFrame* trap)
|
||||||
{
|
{
|
||||||
@ -295,7 +267,7 @@ void page_fault_handler(TrapFrame* trap)
|
|||||||
regs.exception_code & 2 ? "write" : "read",
|
regs.exception_code & 2 ? "write" : "read",
|
||||||
VirtualAddress(fault_address));
|
VirtualAddress(fault_address));
|
||||||
|
|
||||||
dump(regs);
|
dump_registers(regs);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool faulted_in_kernel = !(regs.cs & 3);
|
bool faulted_in_kernel = !(regs.cs & 3);
|
||||||
|
@ -320,7 +320,9 @@ if ("${SERENITY_ARCH}" STREQUAL "i686" OR "${SERENITY_ARCH}" STREQUAL "x86_64")
|
|||||||
|
|
||||||
set(KERNEL_SOURCES
|
set(KERNEL_SOURCES
|
||||||
${KERNEL_SOURCES}
|
${KERNEL_SOURCES}
|
||||||
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/ASM_wrapper.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/ASM_wrapper.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/CrashHandler.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/CPU.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/CPU.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/CPUID.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/CPUID.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/Interrupts.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/Interrupts.cpp
|
||||||
@ -388,6 +390,7 @@ if (NOT "${SERENITY_ARCH}" STREQUAL "aarch64")
|
|||||||
else()
|
else()
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
Arch/aarch64/BootPPMParser.cpp
|
Arch/aarch64/BootPPMParser.cpp
|
||||||
|
Arch/aarch64/CrashHandler.cpp
|
||||||
Arch/aarch64/GPIO.cpp
|
Arch/aarch64/GPIO.cpp
|
||||||
Arch/aarch64/Framebuffer.cpp
|
Arch/aarch64/Framebuffer.cpp
|
||||||
Arch/aarch64/Mailbox.cpp
|
Arch/aarch64/Mailbox.cpp
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <AK/Assertions.h>
|
#include <AK/Assertions.h>
|
||||||
#include <AK/Memory.h>
|
#include <AK/Memory.h>
|
||||||
#include <AK/StringView.h>
|
#include <AK/StringView.h>
|
||||||
|
#include <Kernel/Arch/CPU.h>
|
||||||
#include <Kernel/Arch/PageFault.h>
|
#include <Kernel/Arch/PageFault.h>
|
||||||
#include <Kernel/BootInfo.h>
|
#include <Kernel/BootInfo.h>
|
||||||
#include <Kernel/CMOS.h>
|
#include <Kernel/CMOS.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user