Commit b287a25a authored by Aaro Koskinen's avatar Aaro Koskinen Committed by Linus Torvalds

panic/reboot: allow specifying reboot_mode for panic only

Allow specifying reboot_mode for panic only.  This is needed on systems
where ramoops is used to store panic logs, and user wants to use warm
reset to preserve those, while still having cold reset on normal
reboots.

Link: http://lkml.kernel.org/r/20190322004735.27702-1-aaro.koskinen@iki.fiSigned-off-by: default avatarAaro Koskinen <aaro.koskinen@nokia.com>
Reviewed-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c39ea0b9
...@@ -4064,7 +4064,9 @@ ...@@ -4064,7 +4064,9 @@
[[,]s[mp]#### \ [[,]s[mp]#### \
[[,]b[ios] | a[cpi] | k[bd] | t[riple] | e[fi] | p[ci]] \ [[,]b[ios] | a[cpi] | k[bd] | t[riple] | e[fi] | p[ci]] \
[[,]f[orce] [[,]f[orce]
Where reboot_mode is one of warm (soft) or cold (hard) or gpio, Where reboot_mode is one of warm (soft) or cold (hard) or gpio
(prefix with 'panic_' to set mode for panic
reboot only),
reboot_type is one of bios, acpi, kbd, triple, efi, or pci, reboot_type is one of bios, acpi, kbd, triple, efi, or pci,
reboot_force is either force or not specified, reboot_force is either force or not specified,
reboot_cpu is s[mp]#### with #### being the processor reboot_cpu is s[mp]#### with #### being the processor
......
...@@ -14,6 +14,7 @@ struct device; ...@@ -14,6 +14,7 @@ struct device;
#define SYS_POWER_OFF 0x0003 /* Notify of system power off */ #define SYS_POWER_OFF 0x0003 /* Notify of system power off */
enum reboot_mode { enum reboot_mode {
REBOOT_UNDEFINED = -1,
REBOOT_COLD = 0, REBOOT_COLD = 0,
REBOOT_WARM, REBOOT_WARM,
REBOOT_HARD, REBOOT_HARD,
...@@ -21,6 +22,7 @@ enum reboot_mode { ...@@ -21,6 +22,7 @@ enum reboot_mode {
REBOOT_GPIO, REBOOT_GPIO,
}; };
extern enum reboot_mode reboot_mode; extern enum reboot_mode reboot_mode;
extern enum reboot_mode panic_reboot_mode;
enum reboot_type { enum reboot_type {
BOOT_TRIPLE = 't', BOOT_TRIPLE = 't',
......
...@@ -306,6 +306,8 @@ void panic(const char *fmt, ...) ...@@ -306,6 +306,8 @@ void panic(const char *fmt, ...)
* shutting down. But if there is a chance of * shutting down. But if there is a chance of
* rebooting the system it will be rebooted. * rebooting the system it will be rebooted.
*/ */
if (panic_reboot_mode != REBOOT_UNDEFINED)
reboot_mode = panic_reboot_mode;
emergency_restart(); emergency_restart();
} }
#ifdef __sparc__ #ifdef __sparc__
......
...@@ -31,6 +31,7 @@ EXPORT_SYMBOL(cad_pid); ...@@ -31,6 +31,7 @@ EXPORT_SYMBOL(cad_pid);
#define DEFAULT_REBOOT_MODE #define DEFAULT_REBOOT_MODE
#endif #endif
enum reboot_mode reboot_mode DEFAULT_REBOOT_MODE; enum reboot_mode reboot_mode DEFAULT_REBOOT_MODE;
enum reboot_mode panic_reboot_mode = REBOOT_UNDEFINED;
/* /*
* This variable is used privately to keep track of whether or not * This variable is used privately to keep track of whether or not
...@@ -519,6 +520,8 @@ EXPORT_SYMBOL_GPL(orderly_reboot); ...@@ -519,6 +520,8 @@ EXPORT_SYMBOL_GPL(orderly_reboot);
static int __init reboot_setup(char *str) static int __init reboot_setup(char *str)
{ {
for (;;) { for (;;) {
enum reboot_mode *mode;
/* /*
* Having anything passed on the command line via * Having anything passed on the command line via
* reboot= will cause us to disable DMI checking * reboot= will cause us to disable DMI checking
...@@ -526,17 +529,24 @@ static int __init reboot_setup(char *str) ...@@ -526,17 +529,24 @@ static int __init reboot_setup(char *str)
*/ */
reboot_default = 0; reboot_default = 0;
if (!strncmp(str, "panic_", 6)) {
mode = &panic_reboot_mode;
str += 6;
} else {
mode = &reboot_mode;
}
switch (*str) { switch (*str) {
case 'w': case 'w':
reboot_mode = REBOOT_WARM; *mode = REBOOT_WARM;
break; break;
case 'c': case 'c':
reboot_mode = REBOOT_COLD; *mode = REBOOT_COLD;
break; break;
case 'h': case 'h':
reboot_mode = REBOOT_HARD; *mode = REBOOT_HARD;
break; break;
case 's': case 's':
...@@ -553,11 +563,11 @@ static int __init reboot_setup(char *str) ...@@ -553,11 +563,11 @@ static int __init reboot_setup(char *str)
if (rc) if (rc)
return rc; return rc;
} else } else
reboot_mode = REBOOT_SOFT; *mode = REBOOT_SOFT;
break; break;
} }
case 'g': case 'g':
reboot_mode = REBOOT_GPIO; *mode = REBOOT_GPIO;
break; break;
case 'b': case 'b':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment