From nobody Sun Feb 8 10:33:06 2026 Received: from esa1.hc555-34.eu.iphmx.com (esa1.hc555-34.eu.iphmx.com [23.90.104.144]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A95C423E325 for ; Thu, 1 Jan 2026 12:33:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=23.90.104.144 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767270837; cv=none; b=PMV+ib9A8jLvUlzzp/kwANxGqrSWr6UvR/8D2S+ZB6oB/wp9SJe/1CO21PcIIQ58PbdxluylZrFGq5iVEZIXKiNKNfhRSLpfOLGMfCi6qiltd/5Rd7kGsz7ZlVMAYPQKyCZCt32DuPpXLbh4EiSadD3JIRbgJtaM1F+H1u4Lkbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767270837; c=relaxed/simple; bh=9bliHGm4BMyktj2JdGWxo0fIU0dkWBSK1lc1sBjh4bs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=UtY5YgaGWyXdzI/2pOHCsev4g06nktiKJB9sc6iZuXPqM8xVPvVUfDidbP2o7lTo40/g7H/2Dj6i1+8r5Y6iN6EEAEu3sleGbGKrIs0iUC29TuI7GlwIvwn6jNiC2YWdk4tSrS38Y4MgiBhrNofv0hPl4Wl9rt/6t58yfMq7glc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mobileye.com; spf=pass smtp.mailfrom=mobileye.com; dkim=fail (0-bit key) header.d=mobileye.com header.i=@mobileye.com header.b=TrpqHb2+ reason="key not found in DNS"; arc=none smtp.client-ip=23.90.104.144 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mobileye.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mobileye.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=mobileye.com header.i=@mobileye.com header.b="TrpqHb2+" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mobileye.com; i=@mobileye.com; q=dns/txt; s=MoEyIP; t=1767270831; x=1798806831; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=9bliHGm4BMyktj2JdGWxo0fIU0dkWBSK1lc1sBjh4bs=; b=TrpqHb2+JdLl3cur+/gPXmCEPpDY2VAqr0JsqJ165hdV4pDXOfcmd/sy /pgsqIT8YKpOetHQYLYXlcPeORkIBrxGlAvKfrw+TH6cXNtmTYYlyNBdZ q6Ta0FYYxVVcdTi+9c+GOW7cOAH4q3j9Wly8i9SojCwPEaURuBPShg+GB mfLCBKpgjqk+XdEuk/WNsrx0+L+sxGo7xCBeErLPZDN8RoymM6nFGaztc u7oI3N96r+L9JsW7Zi0NTQxPlcYw3A63/PYuGRm4n8NgQPreXcQL/xS8k wTbjwN7DYNbBDsD5d8x+PLryW/Yry7gChrrLC7s31QEwx00XfCOI/3L3Z A==; X-CSE-ConnectionGUID: 0FPzqWl+QCi05MLcm+VjFg== X-CSE-MsgGUID: ceMKISRRSrWtW6TriWgjjg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from unknown (HELO ces02_data.me-corp.lan) ([146.255.191.134]) by esa1.hc555-34.eu.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jan 2026 14:32:40 +0200 X-CSE-ConnectionGUID: sM9ViSTkRh6EwaCuv1behg== X-CSE-MsgGUID: 6uiyNXlcR8GA3DrGo8W9xg== Received: from unknown (HELO epgd034.me-corp.lan) ([10.154.54.2]) by ces02_data.me-corp.lan with SMTP; 01 Jan 2026 14:34:14 +0200 Received: by epgd034.me-corp.lan (sSMTP sendmail emulation); Thu, 01 Jan 2026 14:32:40 +0200 From: Pnina Feder To: Andrew Morton Cc: Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, Pnina Feder Subject: [PATCH] panic/kexec: Allow forcing panic execution on a specific CPU Date: Thu, 1 Jan 2026 14:32:37 +0200 Message-ID: <20260101123237.277411-1-pnina.feder@mobileye.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Some platforms require panic handling to execute on a specific CPU for crash dump to work reliably. This may be due to firmware, interrupt routing, or platform-specific constraints where only one CPU is able to safely enter the crash kernel. Add an optional configuration that allows redirecting panic execution to a designated target CPU before invoking kexec into the crash kernel. When CONFIG_PANIC_FORCE_CPU is enabled, the initial panic CPU will forward the panic to the configured CPU using smp_call_function_single(). If a panic is already in progress on another CPU, redirection is skipped and a warning is printed. There is no functional change when the option is disabled. Signed-off-by: Pnina Feder --- kernel/Kconfig.kexec | 17 ++++++++++++ kernel/panic.c | 66 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/kernel/Kconfig.kexec b/kernel/Kconfig.kexec index 15632358bcf7..4ba08888cc4a 100644 --- a/kernel/Kconfig.kexec +++ b/kernel/Kconfig.kexec @@ -179,4 +179,21 @@ config CRASH_MAX_MEMORY_RANGES the computation behind the value provided through the /sys/kernel/crash_elfcorehdr_size attribute. =20 +config PANIC_FORCE_CPU + bool "Force panic to execute on a specific CPU" + depends on SMP && CRASH_DUMP + help + Some platforms require panic handling to occur on a specific CPU + for the crash kernel to function correctly. This option forces + panic handling to be redirected to the specified CPU before kexec + into the crash kernel. + +config PANIC_FORCE_CPU_ID + int "CPU number for panic execution" + depends on PANIC_FORCE_CPU + default 0 + help + The CPU number that should handle panic when PANIC_FORCE_CPU is + enabled. + endmenu diff --git a/kernel/panic.c b/kernel/panic.c index 0d52210a9e2b..c3fe254292c0 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -300,6 +300,65 @@ void __weak crash_smp_send_stop(void) =20 atomic_t panic_cpu =3D ATOMIC_INIT(PANIC_CPU_INVALID); =20 +#ifdef CONFIG_PANIC_FORCE_CPU +static void do_panic_on_target_cpu(void *info) +{ + panic("%s", (char *)info); +} + +/** + * panic_force_target_cpu - Redirect panic to a specific CPU for crash ker= nel + * @fmt: panic message format string + * @args: arguments for format string + * + * Some platforms require panic handling to occur on a specific CPU + * for the crash kernel to function correctly. This function redirects + * panic handling to CONFIG_PANIC_FORCE_CPU_ID before kexec. + * + * Returns true if panic should proceed on current CPU. + * Returns false (never returns) if panic was redirected. + */ +static bool panic_force_target_cpu(const char *fmt, va_list args) +{ + static char panic_redirect_msg[1024]; + int cpu =3D raw_smp_processor_id(); + int target_cpu =3D CONFIG_PANIC_FORCE_CPU_ID; + + /* Already on target CPU - proceed normally */ + if (cpu =3D=3D target_cpu) + return true; + + /* Target CPU is offline, can't redirect */ + if (!cpu_online(target_cpu)) { + pr_warn("panic: CPU %d is offline, cannot redirect panic. " + "Crash kernel interrupts may be unavailable.\n", target_cpu); + return true; + } + + /* Another panic already in progress */ + if (panic_in_progress()) { + pr_warn("panic: Another panic in progress on CPU %d, cannot redirect to = CPU %d. " + "Crash kernel interrupts may be unavailable.\n", + atomic_read(&panic_cpu), target_cpu); + return true; + } + + pr_info("panic: Redirecting from CPU %d to CPU %d for crash kernel\n", + cpu, target_cpu); + + vsnprintf(panic_redirect_msg, sizeof(panic_redirect_msg), fmt, args); + + smp_call_function_single(target_cpu, do_panic_on_target_cpu, panic_redire= ct_msg, false); + + return false; +} +#else +static inline bool panic_force_target_cpu(const char *fmt, va_list args) +{ + return true; +} +#endif /* CONFIG_PANIC_FORCE_CPU */ + bool panic_try_start(void) { int old_cpu, this_cpu; @@ -451,6 +510,13 @@ void vpanic(const char *fmt, va_list args) local_irq_disable(); preempt_disable_notrace(); =20 + /* + * Redirect panic to target CPU if configured (CONFIG_PANIC_FORCE_CPU). + * Returns false and never returns if panic was redirected. + */ + if (!panic_force_target_cpu(fmt, args)) + panic_smp_self_stop(); + /* * It's possible to come here directly from a panic-assertion and * not have preempt disabled. Some functions called from here want --=20 2.43.0