From f00223b5cc99a8f3f1b6a15658d8c854c177932a Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 4 Sep 2026 20:25:14 +0200 Subject: x86_64/cpu: handle #DF inside the arch code A double fault is a very x86-64 specific type of exception and not recoverable in a generalized way. Thus we should handle it internally, with handling currently being triggering a panic, and not forward it to the architecture-independent kernel layer. --- arch/x86_64/arch/cpu/interrupts.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/x86_64/arch/cpu/interrupts.cpp b/arch/x86_64/arch/cpu/interrupts.cpp index cf225a90..94806621 100644 --- a/arch/x86_64/arch/cpu/interrupts.cpp +++ b/arch/x86_64/arch/cpu/interrupts.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include @@ -124,6 +125,12 @@ namespace arch::cpu } pic_master_control_port::write(pic_end_of_interrupt); } + + auto handle_double_fault(interrupt_frame * frame) -> void + { + kapi::system::panic("[ARCH:CPU] Double fault! Possible kernel stack corruption! rsp was {}", + frame->cpu_saved.rsp); + } } // namespace extern "C" @@ -134,7 +141,11 @@ namespace arch::cpu { auto [number, code] = frame->interrupt; - if (number < number_of_exception_vectors) + if (number == static_cast(exception::double_fault)) + { + handle_double_fault(frame); + } + else if (number < number_of_exception_vectors) { if (!dispatch_exception(frame)) { -- cgit v1.2.3