diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-09-04 20:25:14 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-09-04 20:25:14 +0200 |
| commit | f00223b5cc99a8f3f1b6a15658d8c854c177932a (patch) | |
| tree | 4b90b707b4331c7956a098864da7ea1e5e657ad0 /arch | |
| parent | a5848c037e6e681d586312ddddddd200b9f7a5b0 (diff) | |
| download | kernel-f00223b5cc99a8f3f1b6a15658d8c854c177932a.tar.xz kernel-f00223b5cc99a8f3f1b6a15658d8c854c177932a.zip | |
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.
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/x86_64/arch/cpu/interrupts.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
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 <kapi/cpu.hpp> #include <kapi/interrupts.hpp> #include <kapi/memory.hpp> +#include <kapi/system.hpp> #include <kstd/print.hpp> @@ -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<std::uint64_t>(exception::double_fault)) + { + handle_double_fault(frame); + } + else if (number < number_of_exception_vectors) { if (!dispatch_exception(frame)) { |
