From 0270192eece46e5c0ee0338117c5dc6174982363 Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Sun, 10 Mar 2024 22:51:09 +0200 Subject: [PATCH] Add more page fault details --- core/panic/ui.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/panic/ui.cpp b/core/panic/ui.cpp index 630b039..b016490 100644 --- a/core/panic/ui.cpp +++ b/core/panic/ui.cpp @@ -417,10 +417,23 @@ nsa void DisplayDetailsScreen(CPU::ExceptionFrame *Frame) case CPU::x86::PageFault: { CPU::x64::PageFaultErrorCode pfCode = {.raw = (uint32_t)Frame->ErrorCode}; - ExPrint("P:%d W:%d U:%d R:%d I:%d PK:%d SS:%d SGX:%d\n", + ExPrint("PFEC: P:%d W:%d U:%d R:%d I:%d PK:%d SS:%d SGX:%d\n", pfCode.P, pfCode.W, pfCode.U, pfCode.R, pfCode.I, pfCode.PK, pfCode.SS, pfCode.SGX); + { + Memory::Virtual vmm((Memory::PageTable *)Frame->cr3); + if (vmm.GetMapType((void *)Frame->cr2) != Memory::Virtual::FourKiB) + ExPrint("Can't display page at address %#lx\n", Frame->cr2); + else + { + Memory::PageTableEntry *pte = vmm.GetPTE((void *)Frame->cr2); + ExPrint("Page %#lx: P:%d W:%d U:%d G:%d NX:%d\n", + ALIGN_DOWN(Frame->cr2, 0x1000), pte->Present, pte->ReadWrite, + pte->UserSupervisor, pte->Global, pte->ExecuteDisable); + } + } + ExPrint("%s", x86PageFaultDescriptions[Frame->ErrorCode & 0b111]); if (Frame->ErrorCode & 0x8) ExPrint("%s", x86PageFaultDescriptions[8]);