* [PATCH 1/3] panic: Introduce arch_do_panic
2026-07-27 8:58 [PATCH 0/3] Introduce arch_do_panic Mete Durlu
@ 2026-07-27 8:58 ` Mete Durlu
2026-07-27 9:09 ` sashiko-bot
2026-07-27 8:58 ` [PATCH 2/3] s390: Implement arch_do_panic Mete Durlu
2026-07-27 8:58 ` [PATCH 3/3] sparc: " Mete Durlu
2 siblings, 1 reply; 8+ messages in thread
From: Mete Durlu @ 2026-07-27 8:58 UTC (permalink / raw)
To: Andrew Morton, Petr Mladek, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
Michael Holzheu, David S. Miller, Andreas Larsson
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.
Suggested-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
---
kernel/panic.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kernel/panic.c b/kernel/panic.c
index 213725b612aa..1eb0cdc159d9 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -567,6 +567,11 @@ static void panic_other_cpus_shutdown(bool crash_kexec)
crash_smp_send_stop();
}
+#ifndef arch_do_panic
+#define arch_do_panic arch_do_panic
+static inline void arch_do_panic(void) {}
+#endif
+
/**
* vpanic - halt the system
* @fmt: The text string to print
@@ -756,6 +761,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] 8+ messages in thread* [PATCH 2/3] s390: Implement arch_do_panic
2026-07-27 8:58 [PATCH 0/3] Introduce arch_do_panic Mete Durlu
2026-07-27 8:58 ` [PATCH 1/3] panic: " Mete Durlu
@ 2026-07-27 8:58 ` Mete Durlu
2026-07-27 9:10 ` sashiko-bot
2026-07-27 8:58 ` [PATCH 3/3] sparc: " Mete Durlu
2 siblings, 1 reply; 8+ messages in thread
From: Mete Durlu @ 2026-07-27 8:58 UTC (permalink / raw)
To: Andrew Morton, Petr Mladek, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
Michael Holzheu, David S. Miller, Andreas Larsson
Cc: linux-kernel, linux-s390, sparclinux, Mete Durlu
s390 has a custom panic handler which carries out user specified actions
during a panic scenario. This handler is invoked via the panic_notifier
call chain and executed before panic_timeout value is evaluated in
common code.
Use arch_do_panic() hook to invoke arch specific panic handling instead
of using panic_notifier call chain. The execution order of panic
handlers now allow for user specified panic_timeout value to be taken
into account.
Fixes: ff6b8ea68f4b ("[S390] ipl/dump on panic.")
Suggested-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
---
arch/s390/include/asm/ipl.h | 1 +
arch/s390/include/asm/setup.h | 3 +++
arch/s390/kernel/ipl.c | 15 +--------------
kernel/panic.c | 3 ---
4 files changed, 5 insertions(+), 17 deletions(-)
diff --git a/arch/s390/include/asm/ipl.h b/arch/s390/include/asm/ipl.h
index b0d00032479d..38924c4a5d1d 100644
--- a/arch/s390/include/asm/ipl.h
+++ b/arch/s390/include/asm/ipl.h
@@ -166,5 +166,6 @@ enum diag308_rc {
extern int diag308(unsigned long subcode, void *addr);
extern void store_status(void (*fn)(void *), void *data);
extern void lgr_info_log(void);
+void s390_do_panic(void);
#endif /* _ASM_S390_IPL_H */
diff --git a/arch/s390/include/asm/setup.h b/arch/s390/include/asm/setup.h
index cbf60ade741d..6b38017f7cf3 100644
--- a/arch/s390/include/asm/setup.h
+++ b/arch/s390/include/asm/setup.h
@@ -90,6 +90,9 @@ extern void (*_machine_restart)(char *command);
extern void (*_machine_halt)(void);
extern void (*_machine_power_off)(void);
+void arch_do_panic(void);
+#define arch_do_panic arch_do_panic
+
struct oldmem_data {
unsigned long start;
unsigned long size;
diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
index 3c346b02ceb9..8ab02e821256 100644
--- a/arch/s390/kernel/ipl.c
+++ b/arch/s390/kernel/ipl.c
@@ -2115,7 +2115,7 @@ static ssize_t on_panic_store(struct kobject *kobj,
}
static struct kobj_attribute on_panic_attr = __ATTR_RW(on_panic);
-static void do_panic(void)
+void arch_do_panic(void)
{
lgr_info_log();
on_panic_trigger.action->fn(&on_panic_trigger);
@@ -2331,18 +2331,6 @@ static int __init vmcmd_on_poff_setup(char *str)
}
__setup("vmpoff=", vmcmd_on_poff_setup);
-static int on_panic_notify(struct notifier_block *self,
- unsigned long event, void *data)
-{
- do_panic();
- return NOTIFY_OK;
-}
-
-static struct notifier_block on_panic_nb = {
- .notifier_call = on_panic_notify,
- .priority = INT_MIN,
-};
-
void __init setup_ipl(void)
{
BUILD_BUG_ON(sizeof(struct ipl_parameter_block) != PAGE_SIZE);
@@ -2375,7 +2363,6 @@ void __init setup_ipl(void)
/* We have no info to copy */
break;
}
- atomic_notifier_chain_register(&panic_notifier_list, &on_panic_nb);
}
void __no_stack_protector s390_reset_system(void)
diff --git a/kernel/panic.c b/kernel/panic.c
index 1eb0cdc159d9..de0bda946cab 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -755,9 +755,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] 8+ messages in thread* Re: [PATCH 2/3] s390: Implement arch_do_panic
2026-07-27 8:58 ` [PATCH 2/3] s390: Implement arch_do_panic Mete Durlu
@ 2026-07-27 9:10 ` sashiko-bot
2026-07-27 9:35 ` Mete Durlu
0 siblings, 1 reply; 8+ messages in thread
From: sashiko-bot @ 2026-07-27 9:10 UTC (permalink / raw)
To: Mete Durlu; +Cc: Alexander Gordeev, Vasily Gorbik, linux-s390, Heiko Carstens
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] arch_do_panic() is bypassed when panic_timeout != 0
- [Low] Unused declaration of s390_do_panic()
--
--- Patch [2]: [PATCH 2/3] s390: Implement arch_do_panic ---
commit 640e72aef0a165dacc87c9e5913aa8f9442aa6e9
Author: Mete Durlu <meted@linux.ibm.com>
s390: Implement arch_do_panic
This commit implements the arch_do_panic() hook for s390 to handle
architecture-specific panic actions instead of relying on the panic_notifier
chain. This change allows user-specified panic_timeout values to be evaluated
in common code before executing the s390 specific actions.
> diff --git a/arch/s390/include/asm/ipl.h b/arch/s390/include/asm/ipl.h
> index b0d00032479d6..38924c4a5d1d7 100644
> --- a/arch/s390/include/asm/ipl.h
> +++ b/arch/s390/include/asm/ipl.h
> @@ -166,5 +166,6 @@ enum diag308_rc {
> extern int diag308(unsigned long subcode, void *addr);
> extern void store_status(void (*fn)(void *), void *data);
> extern void lgr_info_log(void);
> +void s390_do_panic(void);
[Severity: Low]
Is this declaration necessary?
It looks like s390_do_panic() is declared here but never implemented or used,
as the actual implementation provided in arch/s390/kernel/ipl.c is named
arch_do_panic().
[ ... ]
> diff --git a/kernel/panic.c b/kernel/panic.c
> index 1eb0cdc159d94..de0bda946cabb 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -755,9 +755,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);
[Severity: High]
Does this change unintentionally bypass the s390 panic actions when
panic_timeout != 0?
Looking at vpanic() in kernel/panic.c, if a panic timeout is set, the system
will restart before reaching arch_do_panic():
if (panic_timeout != 0) {
...
emergency_restart();
}
pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
arch_do_panic();
Since emergency_restart() does not return, will the user-configured on_panic
actions be lost in this scenario?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260727-arch_do_panic-v1-0-ca1777547c38@linux.ibm.com?part=2
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 2/3] s390: Implement arch_do_panic
2026-07-27 9:10 ` sashiko-bot
@ 2026-07-27 9:35 ` Mete Durlu
0 siblings, 0 replies; 8+ messages in thread
From: Mete Durlu @ 2026-07-27 9:35 UTC (permalink / raw)
To: sashiko-reviews
Cc: Alexander Gordeev, Vasily Gorbik, linux-s390, Heiko Carstens
On 7/27/26 11:10 AM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] arch_do_panic() is bypassed when panic_timeout != 0
> - [Low] Unused declaration of s390_do_panic()
> --
>
> --- Patch [2]: [PATCH 2/3] s390: Implement arch_do_panic ---
> commit 640e72aef0a165dacc87c9e5913aa8f9442aa6e9
> Author: Mete Durlu <meted@linux.ibm.com>
>
> s390: Implement arch_do_panic
>
> This commit implements the arch_do_panic() hook for s390 to handle
> architecture-specific panic actions instead of relying on the panic_notifier
> chain. This change allows user-specified panic_timeout values to be evaluated
> in common code before executing the s390 specific actions.
>
>> diff --git a/arch/s390/include/asm/ipl.h b/arch/s390/include/asm/ipl.h
>> index b0d00032479d6..38924c4a5d1d7 100644
>> --- a/arch/s390/include/asm/ipl.h
>> +++ b/arch/s390/include/asm/ipl.h
>> @@ -166,5 +166,6 @@ enum diag308_rc {
>> extern int diag308(unsigned long subcode, void *addr);
>> extern void store_status(void (*fn)(void *), void *data);
>> extern void lgr_info_log(void);
>> +void s390_do_panic(void);
>
> [Severity: Low]
> Is this declaration necessary?
>
> It looks like s390_do_panic() is declared here but never implemented or used,
> as the actual implementation provided in arch/s390/kernel/ipl.c is named
> arch_do_panic().
This is leftover code. I'll remove it in the next version.
> [ ... ]
>
>> diff --git a/kernel/panic.c b/kernel/panic.c
>> index 1eb0cdc159d94..de0bda946cabb 100644
>> --- a/kernel/panic.c
>> +++ b/kernel/panic.c
>> @@ -755,9 +755,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);
>
> [Severity: High]
> Does this change unintentionally bypass the s390 panic actions when
> panic_timeout != 0?
>
> Looking at vpanic() in kernel/panic.c, if a panic timeout is set, the system
> will restart before reaching arch_do_panic():
>
> if (panic_timeout != 0) {
> ...
> emergency_restart();
> }
> pr_emerg("---[ end Kernel panic - not syncing: %s ]---\n", buf);
>
> arch_do_panic();
>
> Since emergency_restart() does not return, will the user-configured on_panic
> actions be lost in this scenario?
Yes, this is the intended behavior with this change. I'll document it in
the commit message in next version.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/3] sparc: Implement arch_do_panic
2026-07-27 8:58 [PATCH 0/3] Introduce arch_do_panic Mete Durlu
2026-07-27 8:58 ` [PATCH 1/3] panic: " Mete Durlu
2026-07-27 8:58 ` [PATCH 2/3] s390: Implement arch_do_panic Mete Durlu
@ 2026-07-27 8:58 ` Mete Durlu
2026-07-27 9:11 ` sashiko-bot
2 siblings, 1 reply; 8+ messages in thread
From: Mete Durlu @ 2026-07-27 8:58 UTC (permalink / raw)
To: Andrew Morton, Petr Mladek, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
Michael Holzheu, David S. Miller, Andreas Larsson
Cc: linux-kernel, linux-s390, sparclinux, Mete Durlu
Implement sparc specific arch_do_panic() instead of using sparc specific
ifdef sections in vpanic() code.
Signed-off-by: Mete Durlu <meted@linux.ibm.com>
---
arch/sparc/include/asm/setup.h | 4 +++-
arch/sparc/kernel/setup.c | 8 ++++++++
kernel/panic.c | 9 ---------
3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/arch/sparc/include/asm/setup.h b/arch/sparc/include/asm/setup.h
index 21bed5514028..557e8277a640 100644
--- a/arch/sparc/include/asm/setup.h
+++ b/arch/sparc/include/asm/setup.h
@@ -43,7 +43,6 @@ void __init device_scan(void);
/* unaligned_32.c */
unsigned long safe_compute_effective_address(struct pt_regs *, unsigned int);
-
#endif
#ifdef CONFIG_SPARC64
@@ -67,4 +66,7 @@ void sun_do_break(void);
extern int stop_a_enabled;
extern int scons_pwroff;
+void arch_do_panic(void);
+#define arch_do_panic arch_do_panic
+
#endif /* _SPARC_SETUP_H */
diff --git a/arch/sparc/kernel/setup.c b/arch/sparc/kernel/setup.c
index 4975867d9001..87d3569c520f 100644
--- a/arch/sparc/kernel/setup.c
+++ b/arch/sparc/kernel/setup.c
@@ -36,6 +36,14 @@ static const struct ctl_table sparc_sysctl_table[] = {
#endif
};
+void arch_do_panic(void)
+{
+ 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");
+}
static int __init init_sparc_sysctls(void)
{
diff --git a/kernel/panic.c b/kernel/panic.c
index de0bda946cab..593aa2c24d93 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -747,15 +747,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] 8+ messages in thread* Re: [PATCH 3/3] sparc: Implement arch_do_panic
2026-07-27 8:58 ` [PATCH 3/3] sparc: " Mete Durlu
@ 2026-07-27 9:11 ` sashiko-bot
0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-07-27 9:11 UTC (permalink / raw)
To: Mete Durlu; +Cc: Alexander Gordeev, Vasily Gorbik, linux-s390, Heiko Carstens
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The newly introduced SPARC implementation of `arch_do_panic()` is never called because the overriding macro is not visible in `kernel/panic.c`, resulting in the empty fallback stub being used and the SPARC implementation becoming dead code.
- [Low] Redundant local `extern` declaration of `stop_a_enabled`.
--
--- Patch [3]: [PATCH 3/3] sparc: Implement arch_do_panic ---
commit 0468bb7524180e5a2aa478f794a79dc389197120
Author: Mete Durlu <meted@linux.ibm.com>
sparc: Implement arch_do_panic
This patch implements a sparc-specific arch_do_panic function to handle
the Stop-A hardware sequence. It removes the architecture-specific ifdef
blocks from the generic panic code.
> diff --git a/arch/sparc/include/asm/setup.h b/arch/sparc/include/asm/setup.h
> index 21bed55140288..557e8277a6407 100644
> --- a/arch/sparc/include/asm/setup.h
> +++ b/arch/sparc/include/asm/setup.h
[ ... ]
> @@ -67,4 +66,7 @@ void sun_do_break(void);
> extern int stop_a_enabled;
> extern int scons_pwroff;
>
> +void arch_do_panic(void);
> +#define arch_do_panic arch_do_panic
> +
> #endif /* _SPARC_SETUP_H */
> diff --git a/arch/sparc/kernel/setup.c b/arch/sparc/kernel/setup.c
> index 4975867d9001b..87d3569c520f8 100644
> --- a/arch/sparc/kernel/setup.c
> +++ b/arch/sparc/kernel/setup.c
[ ... ]
> @@ -36,6 +36,14 @@ static const struct ctl_table sparc_sysctl_table[] = {
> #endif
> };
>
> +void arch_do_panic(void)
> +{
> + extern int stop_a_enabled;
[Severity: Low]
This isn't a bug, but is this local extern declaration necessary?
Since asm/setup.h is included at the top of this file, the global
declaration of stop_a_enabled should already be visible.
> + /* 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");
> +}
> diff --git a/kernel/panic.c b/kernel/panic.c
> index de0bda946cabb..593aa2c24d93f 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
[ ... ]
> @@ -747,15 +747,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();
[Severity: High]
Will this actually call the sparc-specific implementation?
Looking at kernel/panic.c, it does not appear to include asm/setup.h where
the override macro for arch_do_panic is defined. Because the override macro
isn't visible in this translation unit, won't vpanic end up executing
the default empty inline fallback instead of the newly added sparc
implementation, effectively dropping the sparc panic behavior?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260727-arch_do_panic-v1-0-ca1777547c38@linux.ibm.com?part=3
^ permalink raw reply [flat|nested] 8+ messages in thread