From dbc536e91773c0083c9acd3908490daf851e5c4d Mon Sep 17 00:00:00 2001 From: Liav A Date: Sat, 14 Mar 2020 20:19:38 +0200 Subject: [PATCH] Interrupts: Assert if trying to install an handler on syscall vector Installing an interrupt handler on the syscall IDT vector can lead to fatal results, so we must assert if that happens. --- Kernel/Interrupts/InterruptManagement.cpp | 3 +++ Kernel/Syscall.cpp | 2 +- Kernel/Syscall.h | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Kernel/Interrupts/InterruptManagement.cpp b/Kernel/Interrupts/InterruptManagement.cpp index 905551457a..11eb9745b2 100644 --- a/Kernel/Interrupts/InterruptManagement.cpp +++ b/Kernel/Interrupts/InterruptManagement.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -99,6 +100,8 @@ u8 InterruptManagement::acquire_irq_number(u8 mapped_interrupt_vector) u8 InterruptManagement::get_mapped_interrupt_vector(u8 original_irq) { // FIXME: For SMP configuration (with IOAPICs) use a better routing scheme to make redirections more efficient. + // FIXME: Find a better way to handle conflict with Syscall interrupt gate. + ASSERT((original_irq + IRQ_VECTOR_BASE) != syscall_vector); return original_irq; } diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp index f3eb90ef02..a3f7d45dca 100644 --- a/Kernel/Syscall.cpp +++ b/Kernel/Syscall.cpp @@ -69,7 +69,7 @@ static int handle(RegisterState&, u32 function, u32 arg1, u32 arg2, u32 arg3); void initialize() { - register_user_callable_interrupt_handler(0x82, syscall_asm_entry); + register_user_callable_interrupt_handler(syscall_vector, syscall_asm_entry); klog() << "Syscall: int 0x82 handler installed"; } diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h index aa97af37e4..238ee73140 100644 --- a/Kernel/Syscall.h +++ b/Kernel/Syscall.h @@ -32,6 +32,8 @@ # include #endif +constexpr int syscall_vector = 0x82; + extern "C" { struct timeval; struct timespec;