From e47412d940db4e9be2d05608272e30f560a275d0 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 13 Mar 2024 21:48:02 +0100 Subject: kernel/amd64: print debugging info on NMI the vm isn't getting an NMI for any real reason anyways, so I might as well abuse it --- src/kernel/arch/amd64/interrupts/isr.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/arch/amd64/interrupts/isr.c b/src/kernel/arch/amd64/interrupts/isr.c index ff00f2f..dd97fd4 100644 --- a/src/kernel/arch/amd64/interrupts/isr.c +++ b/src/kernel/arch/amd64/interrupts/isr.c @@ -1,11 +1,18 @@ #include #include #include +#include #include #include #include #include +enum { + NMI = 0x02, + GP_FAULT = 0x0d, + PAGE_FAULT = 0x0e, +}; + void (*irq_fn[16])(void) = {0}; static void log_interrupt(int interrupt, uint64_t *stackframe) { @@ -15,7 +22,7 @@ static void log_interrupt(int interrupt, uint64_t *stackframe) { uint64_t *stack = (void*)stackframe[3]; kprintf("kernel rip = %p, *rip = %p\n", stack, *stack); } - if (interrupt == 0xe) { + if (interrupt == PAGE_FAULT) { uint64_t addr = 0x69; asm("mov %%cr2, %0" : "=r"(addr)); kprintf("addr 0x%x\n", addr); @@ -32,7 +39,13 @@ void isr_stage3(uint8_t interrupt, uint64_t *stackframe) { } } - if (interrupt == 0xe || interrupt == 0xd) { + if (interrupt == NMI) { /* print some debugging information */ + log_interrupt(interrupt, stackframe); + mem_debugprint(); + return; + } + + if (interrupt == PAGE_FAULT || interrupt == GP_FAULT) { stackframe++; } -- cgit v1.2.3