From b0ff2392a15e1d222e51247cfc3ce0350c9ceeb3 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 3 Jan 2024 02:08:01 +0200 Subject: [PATCH] Kernel: Add some helpful debug prints Log RIP when stack pointer is out of bounds. Log all syscalls that return ENOTSUP --- kernel/arch/x86_64/IDT.cpp | 1 + kernel/kernel/Syscall.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/kernel/arch/x86_64/IDT.cpp b/kernel/arch/x86_64/IDT.cpp index 0139c90496..aad574a585 100644 --- a/kernel/arch/x86_64/IDT.cpp +++ b/kernel/arch/x86_64/IDT.cpp @@ -189,6 +189,7 @@ namespace Kernel::IDT else { derrorln("Stack pointer out of bounds!"); + derrorln("rip {H}", interrupt_stack.rip); derrorln("rsp {H}, stack {H}->{H}, istack {H}->{H}", interrupt_stack.rsp, stack.vaddr(), stack.vaddr() + stack.size(), diff --git a/kernel/kernel/Syscall.cpp b/kernel/kernel/Syscall.cpp index 2b5f266847..3a9454c0bb 100644 --- a/kernel/kernel/Syscall.cpp +++ b/kernel/kernel/Syscall.cpp @@ -217,6 +217,9 @@ namespace Kernel asm volatile("cli"); + if (ret.is_error() && ret.error().get_error_code() == ENOTSUP) + dprintln("ENOTSUP {}", syscall); + if (ret.is_error() && ret.error().is_kernel_error()) Kernel::panic("Kernel error while returning to userspace {}", ret.error());