diff options
| -rw-r--r-- | include/linux/kmsg_dump.h | 4 | ||||
| -rw-r--r-- | kernel/printk.c | 4 | ||||
| -rw-r--r-- | kernel/sys.c | 6 |
3 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/kmsg_dump.h b/include/linux/kmsg_dump.h index 24b44145a886..2a0d7d651dc3 100644 --- a/include/linux/kmsg_dump.h +++ b/include/linux/kmsg_dump.h | |||
| @@ -18,6 +18,10 @@ enum kmsg_dump_reason { | |||
| 18 | KMSG_DUMP_OOPS, | 18 | KMSG_DUMP_OOPS, |
| 19 | KMSG_DUMP_PANIC, | 19 | KMSG_DUMP_PANIC, |
| 20 | KMSG_DUMP_KEXEC, | 20 | KMSG_DUMP_KEXEC, |
| 21 | KMSG_DUMP_RESTART, | ||
| 22 | KMSG_DUMP_HALT, | ||
| 23 | KMSG_DUMP_POWEROFF, | ||
| 24 | KMSG_DUMP_EMERG, | ||
| 21 | }; | 25 | }; |
| 22 | 26 | ||
| 23 | /** | 27 | /** |
diff --git a/kernel/printk.c b/kernel/printk.c index f64b8997fc76..0b0c9aa71e89 100644 --- a/kernel/printk.c +++ b/kernel/printk.c | |||
| @@ -1539,6 +1539,10 @@ static const char * const kmsg_reasons[] = { | |||
| 1539 | [KMSG_DUMP_OOPS] = "oops", | 1539 | [KMSG_DUMP_OOPS] = "oops", |
| 1540 | [KMSG_DUMP_PANIC] = "panic", | 1540 | [KMSG_DUMP_PANIC] = "panic", |
| 1541 | [KMSG_DUMP_KEXEC] = "kexec", | 1541 | [KMSG_DUMP_KEXEC] = "kexec", |
| 1542 | [KMSG_DUMP_RESTART] = "restart", | ||
| 1543 | [KMSG_DUMP_HALT] = "halt", | ||
| 1544 | [KMSG_DUMP_POWEROFF] = "poweroff", | ||
| 1545 | [KMSG_DUMP_EMERG] = "emergency_restart", | ||
| 1542 | }; | 1546 | }; |
| 1543 | 1547 | ||
| 1544 | static const char *kmsg_to_str(enum kmsg_dump_reason reason) | 1548 | static const char *kmsg_to_str(enum kmsg_dump_reason reason) |
diff --git a/kernel/sys.c b/kernel/sys.c index 2745dcdb6c6c..31b71a276b40 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
| @@ -43,6 +43,8 @@ | |||
| 43 | #include <linux/kprobes.h> | 43 | #include <linux/kprobes.h> |
| 44 | #include <linux/user_namespace.h> | 44 | #include <linux/user_namespace.h> |
| 45 | 45 | ||
| 46 | #include <linux/kmsg_dump.h> | ||
| 47 | |||
| 46 | #include <asm/uaccess.h> | 48 | #include <asm/uaccess.h> |
| 47 | #include <asm/io.h> | 49 | #include <asm/io.h> |
| 48 | #include <asm/unistd.h> | 50 | #include <asm/unistd.h> |
| @@ -285,6 +287,7 @@ out_unlock: | |||
| 285 | */ | 287 | */ |
| 286 | void emergency_restart(void) | 288 | void emergency_restart(void) |
| 287 | { | 289 | { |
| 290 | kmsg_dump(KMSG_DUMP_EMERG); | ||
| 288 | machine_emergency_restart(); | 291 | machine_emergency_restart(); |
| 289 | } | 292 | } |
| 290 | EXPORT_SYMBOL_GPL(emergency_restart); | 293 | EXPORT_SYMBOL_GPL(emergency_restart); |
| @@ -312,6 +315,7 @@ void kernel_restart(char *cmd) | |||
| 312 | printk(KERN_EMERG "Restarting system.\n"); | 315 | printk(KERN_EMERG "Restarting system.\n"); |
| 313 | else | 316 | else |
| 314 | printk(KERN_EMERG "Restarting system with command '%s'.\n", cmd); | 317 | printk(KERN_EMERG "Restarting system with command '%s'.\n", cmd); |
| 318 | kmsg_dump(KMSG_DUMP_RESTART); | ||
| 315 | machine_restart(cmd); | 319 | machine_restart(cmd); |
| 316 | } | 320 | } |
| 317 | EXPORT_SYMBOL_GPL(kernel_restart); | 321 | EXPORT_SYMBOL_GPL(kernel_restart); |
| @@ -333,6 +337,7 @@ void kernel_halt(void) | |||
| 333 | kernel_shutdown_prepare(SYSTEM_HALT); | 337 | kernel_shutdown_prepare(SYSTEM_HALT); |
| 334 | sysdev_shutdown(); | 338 | sysdev_shutdown(); |
| 335 | printk(KERN_EMERG "System halted.\n"); | 339 | printk(KERN_EMERG "System halted.\n"); |
| 340 | kmsg_dump(KMSG_DUMP_HALT); | ||
| 336 | machine_halt(); | 341 | machine_halt(); |
| 337 | } | 342 | } |
| 338 | 343 | ||
| @@ -351,6 +356,7 @@ void kernel_power_off(void) | |||
| 351 | disable_nonboot_cpus(); | 356 | disable_nonboot_cpus(); |
| 352 | sysdev_shutdown(); | 357 | sysdev_shutdown(); |
| 353 | printk(KERN_EMERG "Power down.\n"); | 358 | printk(KERN_EMERG "Power down.\n"); |
| 359 | kmsg_dump(KMSG_DUMP_POWEROFF); | ||
| 354 | machine_power_off(); | 360 | machine_power_off(); |
| 355 | } | 361 | } |
| 356 | EXPORT_SYMBOL_GPL(kernel_power_off); | 362 | EXPORT_SYMBOL_GPL(kernel_power_off); |
