Kernel: Print a helpful panic message for READONLY_AFTER_INIT crashes

This commit is contained in:
Andreas Kling 2021-02-14 17:38:04 +01:00
parent d8013c60bb
commit a10accd48c
Notes: sideshowbarker 2024-07-18 22:19:07 +09:00

View file

@ -53,6 +53,9 @@
#include <Kernel/VM/ProcessPagingScope.h>
#include <LibC/mallocdefs.h>
extern FlatPtr start_of_ro_after_init;
extern FlatPtr end_of_ro_after_init;
namespace Kernel {
static DescriptorTablePointer s_idtr;
@ -265,6 +268,11 @@ void page_fault_handler(TrapFrame* trap)
handle_crash(regs, "Bad stack on page fault", SIGSTKFLT);
}
if (fault_address >= (FlatPtr)&start_of_ro_after_init && fault_address < (FlatPtr)&end_of_ro_after_init) {
dump(regs);
PANIC("Attempt to write into READONLY_AFTER_INIT section");
}
auto response = MM.handle_page_fault(PageFault(regs.exception_code, VirtualAddress(fault_address)));
if (response == PageFaultResponse::ShouldCrash || response == PageFaultResponse::OutOfMemory) {