panic: add panic_force_cpu= parameter to redirect panic to a specific CPU

Some platforms require panic handling to execute on a specific CPU for
crash dump to work reliably.  This can be due to firmware limitations,
interrupt routing constraints, or platform-specific requirements where
only a single CPU is able to safely enter the crash kernel.

Add the panic_force_cpu= kernel command-line parameter to redirect panic
execution to a designated CPU.  When the parameter is provided, the CPU
that initially triggers panic forwards the panic context to the target CPU
via IPI, which then proceeds with the normal panic and kexec flow.

The IPI delivery is implemented as a weak function
(panic_smp_redirect_cpu) so architectures with NMI support can override it
for more reliable delivery.

If the specified CPU is invalid, offline, or a panic is already in
progress on another CPU, the redirection is skipped and panic continues on
the current CPU.

[pnina.feder@mobileye.com: fix unused variable warning]
  Link: https://lkml.kernel.org/r/20260126122618.2967950-1-pnina.feder@mobileye.com
Link: https://lkml.kernel.org/r/20260122102457.1154599-1-pnina.feder@mobileye.com
Signed-off-by: Pnina Feder <pnina.feder@mobileye.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Pnina Feder
2026-01-22 12:24:57 +02:00
committed by Andrew Morton
parent f3951e93d4
commit 2e171ab29f
4 changed files with 186 additions and 2 deletions

View File

@@ -4788,6 +4788,21 @@ Kernel parameters
panic_on_warn=1 panic() instead of WARN(). Useful to cause kdump
on a WARN().
panic_force_cpu=
[KNL,SMP] Force panic handling to execute on a specific CPU.
Format: <cpu number>
Some platforms require panic handling to occur on a
specific CPU for the crash kernel to function correctly.
This can be due to firmware limitations, interrupt routing
constraints, or platform-specific requirements where only
a particular CPU can safely enter the crash kernel.
When set, panic() will redirect execution to the specified
CPU before proceeding with the normal panic and kexec flow.
If the target CPU is offline or unavailable, panic proceeds
on the current CPU.
This option should only be used for systems with the above
constraints as it might cause the panic operation to be less reliable.
panic_print= Bitmask for printing system info when panic happens.
User can chose combination of the following bits:
bit 0: print all tasks info