[PATCH 2/2] firmware: arm_sdei_nmi: Send the backtrace IPI to CPUs with SDEI masked

Kiryl Shutsemau (Meta) kas at kernel.org
Tue Nov 24 11:47:05 PST 2026


sdei_event_signal() refuses a CPU that has SDEI masked. An NMI
backtrace then gets nothing from such a CPU and, after 10 seconds,
reports it as not responding.

The CPU is in a power-down idle state or going offline, and the regular
backtrace IPI wakes it. Send that IPI to the CPUs SDEI refused; every
other CPU still gets event 0.

A stop needs nothing extra: smp_send_stop() has sent its IPIs before it
signals SDEI, and a CPU still online after that is reported as not
stopped.

Fixes: 0c2c56598cc1 ("drivers/firmware: add SDEI cross-CPU NMI service for arm64")
Cc: stable at vger.kernel.org
Signed-off-by: Kiryl Shutsemau (Meta) <kas at kernel.org>
---
 arch/arm64/include/asm/nmi.h    |  7 +++++++
 arch/arm64/kernel/smp.c         |  2 +-
 drivers/firmware/arm_sdei_nmi.c | 21 ++++++++++++++++++---
 3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/include/asm/nmi.h b/arch/arm64/include/asm/nmi.h
index 2e8974ff8d63..447d681a5475 100644
--- a/arch/arm64/include/asm/nmi.h
+++ b/arch/arm64/include/asm/nmi.h
@@ -45,4 +45,11 @@ static inline void sdei_nmi_stop_cpus(const cpumask_t *mask) { }
  */
 void __noreturn arm64_nmi_cpu_stop(struct pt_regs *regs, bool die_on_crash);
 
+/*
+ * Send the regular backtrace IPI (an NMI with pseudo-NMI) to @mask. The
+ * SDEI provider uses it for the CPUs it cannot signal. Defined in
+ * arch/arm64/kernel/smp.c.
+ */
+void arm64_backtrace_ipi(cpumask_t *mask);
+
 #endif /* __ASM_NMI_H */
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 014b163ce658..8369a4cd3e32 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -946,7 +946,7 @@ static void arm64_send_ipi(const cpumask_t *mask, unsigned int nr)
 			__ipi_send_single(get_ipi_desc(cpu, nr), cpu);
 }
 
-static void arm64_backtrace_ipi(cpumask_t *mask)
+void arm64_backtrace_ipi(cpumask_t *mask)
 {
 	arm64_send_ipi(mask, IPI_CPU_BACKTRACE);
 }
diff --git a/drivers/firmware/arm_sdei_nmi.c b/drivers/firmware/arm_sdei_nmi.c
index edea68ef881e..b8ebb97caf18 100644
--- a/drivers/firmware/arm_sdei_nmi.c
+++ b/drivers/firmware/arm_sdei_nmi.c
@@ -124,7 +124,7 @@ static int sdei_nmi_handler(u32 event, struct pt_regs *regs, void *arg)
 }
 NOKPROBE_SYMBOL(sdei_nmi_handler);
 
-static void sdei_nmi_fire(unsigned int target_cpu)
+static int sdei_nmi_fire(unsigned int target_cpu)
 {
 	int err = sdei_event_signal(SDEI_NMI_EVENT, target_cpu);
 
@@ -133,8 +133,13 @@ static void sdei_nmi_fire(unsigned int target_cpu)
 		pr_warn("SDEI_EVENT_SIGNAL to CPU %u failed: %d\n",
 			target_cpu, err);
 	}
+
+	return err;
 }
 
+/* CPUs to IPI instead; nmi_trigger_cpumask_backtrace() serialises its users */
+static cpumask_t sdei_nmi_ipi_mask;
+
 /*
  * Raise callback for nmi_trigger_cpumask_backtrace(): signal event 0
  * at every CPU still pending in @mask. The framework excludes the local
@@ -151,8 +156,18 @@ static void sdei_nmi_raise_backtrace(cpumask_t *mask)
 	 */
 	dsb(ishst);
 
-	for_each_cpu(cpu, mask)
-		sdei_nmi_fire(cpu);
+	cpumask_clear(&sdei_nmi_ipi_mask);
+	for_each_cpu(cpu, mask) {
+		if (sdei_nmi_fire(cpu) == -EAGAIN)
+			cpumask_set_cpu(cpu, &sdei_nmi_ipi_mask);
+	}
+
+	/*
+	 * A CPU with SDEI masked is in a power-down idle state or going
+	 * offline. The IPI wakes it and it reports like any other.
+	 */
+	if (!cpumask_empty(&sdei_nmi_ipi_mask))
+		arm64_backtrace_ipi(&sdei_nmi_ipi_mask);
 }
 
 /*
-- 
2.54.0




More information about the linux-arm-kernel mailing list