UPSTREAM: GKI: 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.fi
Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit b287a25a7148a89d977c819c1f7d6584f875b682)
Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Bug: 154175554
Change-Id: Id1075f4d97eddb818aa495903a7643958e6c73d6
This commit is contained in:
Aaro Koskinen
2019-05-14 15:45:37 -07:00
committed by Saravana Kannan
parent efea5004c8
commit 4a853c72f4
4 changed files with 22 additions and 6 deletions

View File

@@ -31,6 +31,7 @@ EXPORT_SYMBOL(cad_pid);
#define DEFAULT_REBOOT_MODE
#endif
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
@@ -518,6 +519,8 @@ EXPORT_SYMBOL_GPL(orderly_reboot);
static int __init reboot_setup(char *str)
{
for (;;) {
enum reboot_mode *mode;
/*
* Having anything passed on the command line via
* reboot= will cause us to disable DMI checking
@@ -525,17 +528,24 @@ static int __init reboot_setup(char *str)
*/
reboot_default = 0;
if (!strncmp(str, "panic_", 6)) {
mode = &panic_reboot_mode;
str += 6;
} else {
mode = &reboot_mode;
}
switch (*str) {
case 'w':
reboot_mode = REBOOT_WARM;
*mode = REBOOT_WARM;
break;
case 'c':
reboot_mode = REBOOT_COLD;
*mode = REBOOT_COLD;
break;
case 'h':
reboot_mode = REBOOT_HARD;
*mode = REBOOT_HARD;
break;
case 's':
@@ -552,11 +562,11 @@ static int __init reboot_setup(char *str)
if (rc)
return rc;
} else
reboot_mode = REBOOT_SOFT;
*mode = REBOOT_SOFT;
break;
}
case 'g':
reboot_mode = REBOOT_GPIO;
*mode = REBOOT_GPIO;
break;
case 'b':