diff --git a/kernel/src/arch/x86_64/CPU.cpp b/kernel/src/arch/x86_64/CPU.cpp index 73ffbafd..fa1b86b8 100644 --- a/kernel/src/arch/x86_64/CPU.cpp +++ b/kernel/src/arch/x86_64/CPU.cpp @@ -293,7 +293,15 @@ static void setup_idt() kerrorln("FIXME(interrupt): %s", name); \ CPU::efficient_halt(); -extern "C" void handle_x86_exception([[maybe_unused]] Registers* regs) +[[noreturn]] void handle_page_fault(Registers* regs) +{ + u64 cr2; + asm volatile("mov %%cr2, %0" : "=r"(cr2)); + kerrorln("Page fault at RIP %lx while accessing %lx!", regs->rip, cr2); + CPU::efficient_halt(); +} + +extern "C" void handle_x86_exception(Registers* regs) { switch (regs->isr) { @@ -309,7 +317,7 @@ extern "C" void handle_x86_exception([[maybe_unused]] Registers* regs) case 11: FIXME_UNHANDLED_INTERRUPT("Segment not present"); case 12: FIXME_UNHANDLED_INTERRUPT("Stack-segment fault"); case 13: FIXME_UNHANDLED_INTERRUPT("General protection fault"); - case 14: FIXME_UNHANDLED_INTERRUPT("Page fault"); + case 14: handle_page_fault(regs); case 16: FIXME_UNHANDLED_INTERRUPT("x87 floating-point exception"); case 17: FIXME_UNHANDLED_INTERRUPT("Alignment check"); case 19: FIXME_UNHANDLED_INTERRUPT("SIMD floating-point exception");