From aa0aaf69704fa5060b49abd578c94478c5927801 Mon Sep 17 00:00:00 2001 From: atsushi421 Date: Mon, 16 Nov 2026 11:04:51 +0900 Subject: [PATCH] fix(x86_64): send the EOI of a preemption IPI that finds no task Without the perf feature, the preemption handler returns before `eoi()` if the CPU runs no task. A preemption IPI finds no task if the task of the victim finishes before the IPI arrives. The IPI uses vector 255 with Fixed delivery, so its in-service bit stays set. Then the local APIC blocks every later interrupt, because no vector has a higher priority class. The CPU gets no more wakeup IPIs or timer interrupts and can sleep forever. Now the handler calls `eoi()` before it checks the current task. Signed-off-by: atsushi421 --- kernel/src/arch/x86_64/interrupt_handler.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/src/arch/x86_64/interrupt_handler.rs b/kernel/src/arch/x86_64/interrupt_handler.rs index ca3b3e35e..ae0729960 100644 --- a/kernel/src/arch/x86_64/interrupt_handler.rs +++ b/kernel/src/arch/x86_64/interrupt_handler.rs @@ -520,6 +520,10 @@ extern "x86-interrupt" fn preemption(_stack_frame: InterruptStackFrame) { #[cfg(feature = "perf")] let prev = awkernel_async_lib::task::perf::start_interrupt(); + // End of interrupt. It must come before the return below, because an + // in-service preemption vector blocks every later interrupt. + awkernel_lib::interrupt::eoi(); + #[cfg(not(feature = "perf"))] { if awkernel_async_lib::task::get_current_task(cpu_id()).is_none() { @@ -527,7 +531,6 @@ extern "x86-interrupt" fn preemption(_stack_frame: InterruptStackFrame) { } } - awkernel_lib::interrupt::eoi(); // End of interrupt. awkernel_lib::interrupt::handle_preemption(); #[cfg(feature = "perf")]