Skip to contentSkip to conversation

x86/smp: ignore stale reboot IPI in crash kernel

PATCH New Yipeng Zou 1 participant 1 message Aug 16, 2025 x86

lore
Share & tools
lore

Yipeng Zou

author
#0 lore raw

PATCH 1/1 x86/smp: ignore stale reboot IPI in crash kernel

Recently, A issue has been reported that CPU hang in x86 VM.

The CPU halted during Kdump likely due to IPI issues when one CPU was rebooting and another was in Kdump:

CPU0 CPU2
======================== ======================
reboot Panic
machine shutdown Kdump
... machine_crash_shutdown
local_irq_disable local_irq_disable
stop other cpus ...
... nmi_shootdown_cpus

send_IPIs(REBOOT)  ---->  [IPI pending]
Halt,NMI context   <----  send_IPIs(NMI)

...
second kernel start
...
local irq enable
Halt, IPI context

In simple terms, when the Kdump jump to the second kernel, the IPI that was pending in the first kernel remains and is responded to by the second kernel.

For a detailed, please refer to:

[1] https://lore.kernel.org/all/[email protected]/

This scenario can be detected when stopping_cpu contains the bootup value.

---
 arch/x86/kernel/smp.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
arch/x86/kernel/smp.c +22 -0
index b014e6d229f9..66144f686436 100644
@@ -136,6 +136,28 @@ static int smp_stop_nmi_callback(unsigned int val, struct pt_regs *regs)
 DEFINE_IDTENTRY_SYSVEC(sysvec_reboot)
 {
 	apic_eoi();
+
+	/*
+	 * Handle the case where a reboot IPI is stale in the IRR. This
+	 * happens when:
+	 *
+	 *   a CPU crashes with interrupts disabled before handling the
+	 *   reboot IPI and jumps into a crash kernel. The reboot IPI
+	 *   vector is kept set in the APIC IRR across the APIC soft
+	 *   disabled phase and as there is no way to clear a pending IRR
+	 *   bit, it is delivered to the crash kernel immediately when
+	 *   interrupts are enabled.
+	 *
+	 * As the reboot IPI can only be sent after acquiring @stopping_cpu
+	 * by storing the CPU number, this case can be detected when
+	 * @stopping_cpu contains the bootup value -1. Just return and
+	 * ignore it.
+	 */
+	if (atomic_read(&stopping_cpu) == -1) {
+		pr_info("Ignoring stale reboot IPI\n");
+		return;
+	}
+
 	cpu_emergency_disable_virtualization();
 	stop_this_cpu(NULL);
 }
Signature · 1 line
2.34.1