Bug 218574

Summary: Setting negative PANIC_TIMEOUT values not respected
Product: Other Reporter: Donald Carr (sirspudd)
Component: ConfigurationAssignee: other_configuration (other_configuration)
Status: NEW ---    
Severity: normal CC: sirspudd
Priority: P3    
Hardware: All   
OS: Linux   
Kernel Version: Subsystem:
Regression: No Bisected commit-id:

Description Donald Carr 2024-03-08 18:48:08 UTC
I am working against the v6.7 tag:

I have spent some time trying to get panic=-1
respected in the kernel. The code was clearly there for negative
values and there are consumers:

./arch/arm/configs/aspeed_g5_defconfig:CONFIG_PANIC_TIMEOUT=-1
./arch/arm/configs/aspeed_g4_defconfig:CONFIG_PANIC_TIMEOUT=-1
./arch/arm/configs/coltrane_defconfig:CONFIG_PANIC_TIMEOUT=-1
./arch/mips/configs/ath25_defconfig:CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-2
./arch/mips/configs/ath79_defconfig:CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-2

I have verified that explicitly setting panic_timeout = -1 as below works as intended.

diff --git a/kernel/panic.c b/kernel/panic.c
index 2807639aab51..f07ac734a8f6 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -404,6 +404,9 @@ void panic(const char *fmt, ...)
        if (!panic_blink)
                panic_blink = no_blink;

+       /* this is filthy but it gets the job done */
+       panic_timeout = -1;
+
        if (panic_timeout > 0) {

I tried tracing the path from defconfig to panic_timeout:

+++ b/scripts/kconfig/confdata.c
@@ -273,6 +273,8 @@ static int conf_set_sym_val(struct symbol *sym,
int def, int def_flags, char *p)
                if (sym_string_valid(sym, p)) {
                        sym->def[def].val = xstrdup(p);
                        sym->flags |= def_flags;
+                       conf_warning("symbol value '%s' for %s",
+                                            sym->def[def].val, sym->name);
                } else {
                        if (def != S_DEF_AUTO)
                                conf_warning("symbol value '%s' invalid for %s",

and can tell you a value of -1 is present as of this point in the code. I dont know if this is broken by design or not, but it seems unlikely given the code which handles negative values.
Comment 1 Donald Carr 2024-03-08 19:22:09 UTC
despite there being existing defconfigs which specify negative values,
this channel does not actually appear to work, and the kernel behaves
as if the sign is being discarded. A PANIC_TIMEOUT=-1 reboots after a
second, not immediately.

Hardcoding the value in situ works, passing it via defconfig not so
much. I assume the negative value code path is intended for
consumption