* [PATCH v4 1/3] panic: Introduce arch_do_panic
2026-08-05 9:48 [PATCH v4 0/3] Introduce arch_do_panic Mete Durlu
@ 2026-08-05 9:48 ` Mete Durlu
2026-08-05 10:00 ` sashiko-bot
2026-08-05 9:48 ` [PATCH v4 2/3] s390: Implement arch_do_panic() Mete Durlu
2026-08-05 9:48 ` [PATCH v4 3/3] sparc: Implement arch_do_panic Mete Durlu
2 siblings, 1 reply; 9+ messages in thread
From: Mete Durlu @ 2026-08-05 9:48 UTC (permalink / raw)
To: Andrew Morton, Petr Mladek, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
David S. Miller, Andreas Larsson, Bradley Morgan
Cc: linux-kernel, linux-s390, sparclinux, Mete Durlu
Introduce a hook for architectures to put their specific panic handlers.
s390 and sparc already has ifdef preprocessor checks to execute
architecture specific code. Pave the way for vpanic() cleanup.
Reviewed-by: Bradley Morgan <include@grrlz.net>
Suggested-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
---
include/linux/panic.h | 2 ++
kernel/panic.c | 3 +++
2 files changed, 5 insertions(+)
diff --git a/include/linux/panic.h b/include/linux/panic.h
index f1dd417e54b2..98dd7dfd27de 100644
--- a/include/linux/panic.h
+++ b/include/linux/panic.h
@@ -110,4 +110,6 @@ extern void add_taint(unsigned flag, enum lockdep_ok);
extern int test_taint(unsigned flag);
extern unsigned long get_taint(void);
+void arch_do_panic(void);
+
#endif /* _LINUX_PANIC_H */
diff --git a/kernel/panic.c b/kernel/panic.c
index 213725b612aa..726a97842232 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -567,6 +567,8 @@ static void panic_other_cpus_shutdown(bool crash_kexec)
crash_smp_send_stop();
}
+void __weak arch_do_panic(void) {}
+
/**
* vpanic - halt the system
* @fmt: The text string to print
@@ -756,6 +758,7 @@ void vpanic(const char *fmt, va_list args)
#endif
pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
+ arch_do_panic();
/* Do not scroll important messages printed above */
suppress_printk = 1;
--
2.55.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v4 1/3] panic: Introduce arch_do_panic
2026-08-05 9:48 ` [PATCH v4 1/3] panic: " Mete Durlu
@ 2026-08-05 10:00 ` sashiko-bot
0 siblings, 0 replies; 9+ messages in thread
From: sashiko-bot @ 2026-08-05 10:00 UTC (permalink / raw)
To: Mete Durlu; +Cc: linux-s390, Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The newly introduced `arch_do_panic()` hook is placed before the explicit console flushes. On architectures that halt indefinitely within this hook (e.g., s390), the final 'end Kernel panic' message and any deferred NMI logs will be lost because the required explicit flush is never executed.
--
--- Patch [1]: [PATCH v4 1/3] panic: Introduce arch_do_panic ---
commit 6fe8c46d4a07969ba51a615fab55e7ba7120f254
Author: Mete Durlu <meted@linux.ibm.com>
panic: Introduce arch_do_panic
This patch introduces a weak hook for architectures to provide their
specific panic handlers. This aims to help clean up architecture specific
ifdef checks in the panic path.
> diff --git a/kernel/panic.c b/kernel/panic.c
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
[ ... ]
> @@ -756,6 +758,7 @@ void vpanic(const char *fmt, va_list args)
> #endif
> pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
>
> + arch_do_panic();
[Severity: Medium]
If an architecture implements this hook and halts indefinitely, will this
bypass the final explicit console flushes?
The final explicit flush happens shortly after this addition:
vpanic() {
...
pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
arch_do_panic();
suppress_printk = 1;
console_flush_on_panic(CONSOLE_FLUSH_PENDING);
nbcon_atomic_flush_unsafe();
...
}
Could this cause deferred log messages, such as NMI backtraces or the final
panic banner, to be lost because the required explicit flush is never executed?
> /* Do not scroll important messages printed above */
> suppress_printk = 1;
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260805-arch_do_panic-v4-0-af4a36f99414@linux.ibm.com?part=1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v4 2/3] s390: Implement arch_do_panic()
2026-08-05 9:48 [PATCH v4 0/3] Introduce arch_do_panic Mete Durlu
2026-08-05 9:48 ` [PATCH v4 1/3] panic: " Mete Durlu
@ 2026-08-05 9:48 ` Mete Durlu
2026-08-05 9:56 ` sashiko-bot
2026-08-05 10:06 ` Heiko Carstens
2026-08-05 9:48 ` [PATCH v4 3/3] sparc: Implement arch_do_panic Mete Durlu
2 siblings, 2 replies; 9+ messages in thread
From: Mete Durlu @ 2026-08-05 9:48 UTC (permalink / raw)
To: Andrew Morton, Petr Mladek, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
David S. Miller, Andreas Larsson, Bradley Morgan
Cc: linux-kernel, linux-s390, sparclinux, Mete Durlu
Implement s390 specific arch_do_panic() instead of using s390 specific
ifdef sections in vpanic() code.
No functional changes.
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
---
arch/s390/kernel/ipl.c | 6 ++++++
kernel/panic.c | 3 ---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
index 3c346b02ceb9..31ff7c12c354 100644
--- a/arch/s390/kernel/ipl.c
+++ b/arch/s390/kernel/ipl.c
@@ -13,6 +13,7 @@
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/kstrtox.h>
+#include <linux/panic.h>
#include <linux/panic_notifier.h>
#include <linux/reboot.h>
#include <linux/ctype.h>
@@ -2343,6 +2344,11 @@ static struct notifier_block on_panic_nb = {
.priority = INT_MIN,
};
+void arch_do_panic(void)
+{
+ disabled_wait();
+}
+
void __init setup_ipl(void)
{
BUILD_BUG_ON(sizeof(struct ipl_parameter_block) != PAGE_SIZE);
diff --git a/kernel/panic.c b/kernel/panic.c
index 726a97842232..ee6e3f9e3900 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -752,9 +752,6 @@ void vpanic(const char *fmt, va_list args)
pr_emerg("Press Stop-A (L1-A) from sun keyboard or send break\n"
"twice on console to return to the boot prom\n");
}
-#endif
-#if defined(CONFIG_S390)
- disabled_wait();
#endif
pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
--
2.55.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v4 2/3] s390: Implement arch_do_panic()
2026-08-05 9:48 ` [PATCH v4 2/3] s390: Implement arch_do_panic() Mete Durlu
@ 2026-08-05 9:56 ` sashiko-bot
2026-08-05 10:06 ` Heiko Carstens
1 sibling, 0 replies; 9+ messages in thread
From: sashiko-bot @ 2026-08-05 9:56 UTC (permalink / raw)
To: Mete Durlu; +Cc: Heiko Carstens, Vasily Gorbik, Alexander Gordeev, linux-s390
> Implement s390 specific arch_do_panic() instead of using s390 specific
> ifdef sections in vpanic() code.
> No functional changes.
>
> Signed-off-by: Mete Durlu <meted@linux.ibm.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260805-arch_do_panic-v4-0-af4a36f99414@linux.ibm.com?part=2
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4 2/3] s390: Implement arch_do_panic()
2026-08-05 9:48 ` [PATCH v4 2/3] s390: Implement arch_do_panic() Mete Durlu
2026-08-05 9:56 ` sashiko-bot
@ 2026-08-05 10:06 ` Heiko Carstens
2026-08-05 10:11 ` Mete Durlu
1 sibling, 1 reply; 9+ messages in thread
From: Heiko Carstens @ 2026-08-05 10:06 UTC (permalink / raw)
To: Mete Durlu
Cc: Andrew Morton, Petr Mladek, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, David S. Miller,
Andreas Larsson, Bradley Morgan, linux-kernel, linux-s390,
sparclinux
On Wed, Aug 05, 2026 at 11:48:37AM +0200, Mete Durlu wrote:
> Implement s390 specific arch_do_panic() instead of using s390 specific
> ifdef sections in vpanic() code.
> No functional changes.
>
> Signed-off-by: Mete Durlu <meted@linux.ibm.com>
> ---
> arch/s390/kernel/ipl.c | 6 ++++++
> kernel/panic.c | 3 ---
> 2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
> index 3c346b02ceb9..31ff7c12c354 100644
> --- a/arch/s390/kernel/ipl.c
> +++ b/arch/s390/kernel/ipl.c
> @@ -13,6 +13,7 @@
> #include <linux/device.h>
> #include <linux/delay.h>
> #include <linux/kstrtox.h>
> +#include <linux/panic.h>
> #include <linux/panic_notifier.h>
> #include <linux/reboot.h>
> #include <linux/ctype.h>
> @@ -2343,6 +2344,11 @@ static struct notifier_block on_panic_nb = {
> .priority = INT_MIN,
> };
>
> +void arch_do_panic(void)
> +{
> + disabled_wait();
> +}
> +
Please move this to arch/s390/kernel/traps.c somewhere near
kernel_stack_invalid() and monitor_event_exception().
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v4 2/3] s390: Implement arch_do_panic()
2026-08-05 10:06 ` Heiko Carstens
@ 2026-08-05 10:11 ` Mete Durlu
0 siblings, 0 replies; 9+ messages in thread
From: Mete Durlu @ 2026-08-05 10:11 UTC (permalink / raw)
To: Heiko Carstens
Cc: Andrew Morton, Petr Mladek, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger, Sven Schnelle, David S. Miller,
Andreas Larsson, Bradley Morgan, linux-kernel, linux-s390,
sparclinux
On 05/08/2026 12:06, Heiko Carstens wrote:
> On Wed, Aug 05, 2026 at 11:48:37AM +0200, Mete Durlu wrote:
>> Implement s390 specific arch_do_panic() instead of using s390 specific
>> ifdef sections in vpanic() code.
>> No functional changes.
>>
>> Signed-off-by: Mete Durlu <meted@linux.ibm.com>
>> ---
>> arch/s390/kernel/ipl.c | 6 ++++++
>> kernel/panic.c | 3 ---
>> 2 files changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
>> index 3c346b02ceb9..31ff7c12c354 100644
>> --- a/arch/s390/kernel/ipl.c
>> +++ b/arch/s390/kernel/ipl.c
>> @@ -13,6 +13,7 @@
>> #include <linux/device.h>
>> #include <linux/delay.h>
>> #include <linux/kstrtox.h>
>> +#include <linux/panic.h>
>> #include <linux/panic_notifier.h>
>> #include <linux/reboot.h>
>> #include <linux/ctype.h>
>> @@ -2343,6 +2344,11 @@ static struct notifier_block on_panic_nb = {
>> .priority = INT_MIN,
>> };
>>
>> +void arch_do_panic(void)
>> +{
>> + disabled_wait();
>> +}
>> +
>
> Please move this to arch/s390/kernel/traps.c somewhere near
> kernel_stack_invalid() and monitor_event_exception().
Alright, will do in the next version.
Thank you for having a look!
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v4 3/3] sparc: Implement arch_do_panic
2026-08-05 9:48 [PATCH v4 0/3] Introduce arch_do_panic Mete Durlu
2026-08-05 9:48 ` [PATCH v4 1/3] panic: " Mete Durlu
2026-08-05 9:48 ` [PATCH v4 2/3] s390: Implement arch_do_panic() Mete Durlu
@ 2026-08-05 9:48 ` Mete Durlu
2026-08-05 9:56 ` sashiko-bot
2 siblings, 1 reply; 9+ messages in thread
From: Mete Durlu @ 2026-08-05 9:48 UTC (permalink / raw)
To: Andrew Morton, Petr Mladek, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
David S. Miller, Andreas Larsson, Bradley Morgan
Cc: linux-kernel, linux-s390, sparclinux, Mete Durlu
Implement sparc specific arch_do_panic() instead of using sparc specific
ifdef sections in vpanic() code.
Reorder arch specific panic handling, sparc's Stop-A messages are now
printed after "end Kernel panic" marker.
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
---
arch/sparc/kernel/setup.c | 9 +++++++++
kernel/panic.c | 9 ---------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/arch/sparc/kernel/setup.c b/arch/sparc/kernel/setup.c
index 4975867d9001..5f43cef80638 100644
--- a/arch/sparc/kernel/setup.c
+++ b/arch/sparc/kernel/setup.c
@@ -2,6 +2,8 @@
#include <asm/setup.h>
#include <linux/sysctl.h>
+#include <linux/panic.h>
+#include <linux/printk.h>
static const struct ctl_table sparc_sysctl_table[] = {
{
@@ -36,6 +38,13 @@ static const struct ctl_table sparc_sysctl_table[] = {
#endif
};
+void arch_do_panic(void)
+{
+ /* Make sure the user can actually press Stop-A (L1-A) */
+ stop_a_enabled = 1;
+ pr_emerg("Press Stop-A (L1-A) from sun keyboard or send break\n"
+ "twice on console to return to the boot prom\n");
+}
static int __init init_sparc_sysctls(void)
{
diff --git a/kernel/panic.c b/kernel/panic.c
index ee6e3f9e3900..7dda841c16f9 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -744,15 +744,6 @@ void vpanic(const char *fmt, va_list args)
reboot_mode = panic_reboot_mode;
emergency_restart();
}
-#ifdef __sparc__
- {
- extern int stop_a_enabled;
- /* Make sure the user can actually press Stop-A (L1-A) */
- stop_a_enabled = 1;
- pr_emerg("Press Stop-A (L1-A) from sun keyboard or send break\n"
- "twice on console to return to the boot prom\n");
- }
-#endif
pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
arch_do_panic();
--
2.55.0
^ permalink raw reply related [flat|nested] 9+ messages in thread