arch/x86_64: Nicer display for page faults that shows a human-readable version of the error code
This commit is contained in:
parent
a01b56ed39
commit
87a4bc91d8
@ -29,6 +29,19 @@ extern void setup_idt();
|
|||||||
kerrorln("FIXME(interrupt): %s", name); \
|
kerrorln("FIXME(interrupt): %s", name); \
|
||||||
CPU::efficient_halt();
|
CPU::efficient_halt();
|
||||||
|
|
||||||
|
#define PF_PRESENT 1 << 0
|
||||||
|
#define PF_WRITE 1 << 1
|
||||||
|
#define PF_USER 1 << 2
|
||||||
|
#define PF_RESERVED 1 << 3
|
||||||
|
#define PF_NX_VIOLATION 1 << 4
|
||||||
|
|
||||||
|
void decode_page_fault_error_code(u64 code)
|
||||||
|
{
|
||||||
|
kwarnln("Fault details: %s | %s | %s%s%s", (code & PF_PRESENT) ? "Present" : "Not present",
|
||||||
|
(code & PF_WRITE) ? "Write access" : "Read access", (code & PF_USER) ? "User mode" : "Kernel mode",
|
||||||
|
(code & PF_RESERVED) ? " | Reserved bits set" : "", (code & PF_NX_VIOLATION) ? " | NX violation" : "");
|
||||||
|
}
|
||||||
|
|
||||||
[[noreturn]] void handle_page_fault(Registers* regs)
|
[[noreturn]] void handle_page_fault(Registers* regs)
|
||||||
{
|
{
|
||||||
CPU::disable_interrupts();
|
CPU::disable_interrupts();
|
||||||
@ -37,6 +50,8 @@ extern void setup_idt();
|
|||||||
asm volatile("mov %%cr2, %0" : "=r"(cr2));
|
asm volatile("mov %%cr2, %0" : "=r"(cr2));
|
||||||
kerrorln("Page fault at RIP %lx while accessing %lx!", regs->rip, cr2);
|
kerrorln("Page fault at RIP %lx while accessing %lx!", regs->rip, cr2);
|
||||||
|
|
||||||
|
decode_page_fault_error_code(regs->error);
|
||||||
|
|
||||||
CPU::print_stack_trace_at(regs);
|
CPU::print_stack_trace_at(regs);
|
||||||
|
|
||||||
CPU::efficient_halt();
|
CPU::efficient_halt();
|
||||||
|
Loading…
Reference in New Issue
Block a user