summaryrefslogtreecommitdiff
path: root/scripts/checkstack.pl
diff options
context:
space:
mode:
authorBradley Morgan <brads@mainlining.org>2026-09-16 18:29:56 +0000
committerAndrew Morton <akpm@linux-foundation.org>2026-10-06 19:03:10 -0700
commit9e3a9fd1f684bd59b70ced64b6709c11e13bd4c7 (patch)
treed95302fa2d33e130acb70dc625737be2e3f5897e /scripts/checkstack.pl
parent9cbe4c3344734464263ac4561fe4f639d332fc6e (diff)
downloadlinux-next-9e3a9fd1f684bd59b70ced64b6709c11e13bd4c7.tar.gz
linux-next-9e3a9fd1f684bd59b70ced64b6709c11e13bd4c7.zip
panic: allow force_cpu redirect from an NMI
nmi_panic() claims panic_cpu via panic_try_start() before calling panic(). When the panic later reaches panic_try_force_cpu(), the panic_in_progress() check sees panic_cpu set and refuses to redirect. The crash kernel runs on the CPU that took the NMI instead of the CPU requested with panic_force_cpu=: nmi_panic() panic_try_start() wins, panic_cpu = X panic("%s", msg) vpanic() panic_try_force_cpu() panic_in_progress() true, panic_cpu is X return false redirect bypassed panic_try_start() already won __crash_kexec() on X, not the requested CPU Try the redirect before claiming panic_cpu instead, as suggested by Petr Mladek. nmi_panic() now calls panic_try_force_cpu() first and claims panic_cpu only when no redirect happened. The requested CPU claims panic_cpu itself when it runs panic(), so panic_cpu does not need to be handed off. panic_try_force_cpu() copies the arguments before formatting (patch 3), so nmi_panic() can pass them to vpanic() again when no redirect happens. The redirect IPI is sent with smp_call_function_single_async(), which is not guaranteed to work from NMI context. Treat it as best effort. It is worth the risk because the redirection is only used when the crash kernel would not work on the panicking CPU anyway. Keep returning when the panic is already running on this CPU. A nested NMI, for example with unknown_nmi_panic while this CPU is inside panic(), must return and let the interrupted panic() continue instead of parking the CPU in nmi_panic_self_stop(). Mark the redirecting CPU offline before stopping it, like vpanic() does, so that panic_other_cpus_shutdown() on the target CPU does not wait for it. Link: https://lore.kernel.org/20260916182957.7788-6-brads@mainlining.org Fixes: 2e171ab29f91 ("panic: add panic_force_cpu= parameter to redirect panic to a specific CPU") Signed-off-by: Bradley Morgan <brads@mainlining.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reported-by: Sashiko <sashiko-bot@kernel.org> Closes: https://sashiko.dev/#/patchset/20260708164312.19044-1-include@grrlz.net Reviewed-by: Petr Mladek <pmladek@suse.com> Cc: Guenetr Roeck <linux@roeck-us.net> Cc: Wang Jinchao <wangjinchao600@gmail.com> Cc: Wim Van Sebroeck <wim@linux-watchdog.org> Cc: <stable@vger.kernel.org>
Diffstat (limited to 'scripts/checkstack.pl')
0 files changed, 0 insertions, 0 deletions