Skip to content

Commit 0f4bd46

Browse files
kosakiDavid Woodhouse
authored andcommitted
kmsg_dump: Dump on crash_kexec as well
crash_kexec gets called before kmsg_dump(KMSG_DUMP_OOPS) if panic_on_oops is set, so the kernel log buffer is not stored for this case. This patch adds a KMSG_DUMP_KEXEC dump type which gets called when crash_kexec() is invoked. To avoid getting double dumps, the old KMSG_DUMP_PANIC is moved below crash_kexec(). The mtdoops driver is modified to handle KMSG_DUMP_KEXEC in the same way as a panic. Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Acked-by: Simon Kagstrom <simon.kagstrom@netinsight.net> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent 60d9aa7 commit 0f4bd46

5 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎drivers/mtd/mtdoops.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static void mtdoops_do_dump(struct kmsg_dumper *dumper,
322322
memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy);
323323

324324
/* Panics must be written immediately */
325-
if (reason == KMSG_DUMP_PANIC) {
325+
if (reason != KMSG_DUMP_OOPS) {
326326
if (!cxt->mtd->panic_write)
327327
printk(KERN_ERR "mtdoops: Cannot write from panic without panic_write\n");
328328
else

‎include/linux/kmsg_dump.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
enum kmsg_dump_reason {
1818
KMSG_DUMP_OOPS,
1919
KMSG_DUMP_PANIC,
20+
KMSG_DUMP_KEXEC,
2021
};
2122

2223
/**

‎kernel/kexec.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/console.h>
3333
#include <linux/vmalloc.h>
3434
#include <linux/swap.h>
35+
#include <linux/kmsg_dump.h>
3536

3637
#include <asm/page.h>
3738
#include <asm/uaccess.h>
@@ -1074,6 +1075,9 @@ void crash_kexec(struct pt_regs *regs)
10741075
if (mutex_trylock(&kexec_mutex)) {
10751076
if (kexec_crash_image) {
10761077
struct pt_regs fixed_regs;
1078+
1079+
kmsg_dump(KMSG_DUMP_KEXEC);
1080+
10771081
crash_setup_regs(&fixed_regs, regs);
10781082
crash_save_vmcoreinfo();
10791083
machine_crash_shutdown(&fixed_regs);

‎kernel/panic.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,15 @@ NORET_TYPE void panic(const char * fmt, ...)
7575
dump_stack();
7676
#endif
7777

78-
kmsg_dump(KMSG_DUMP_PANIC);
7978
/*
8079
* If we have crashed and we have a crash kernel loaded let it handle
8180
* everything else.
8281
* Do we want to call this before we try to display a message?
8382
*/
8483
crash_kexec(NULL);
8584

85+
kmsg_dump(KMSG_DUMP_PANIC);
86+
8687
/*
8788
* Note smp_send_stop is the usual smp shutdown function, which
8889
* unfortunately means it may not be hardened to work in a panic

‎kernel/printk.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,7 @@ EXPORT_SYMBOL_GPL(kmsg_dump_unregister);
14671467
static const char const *kmsg_reasons[] = {
14681468
[KMSG_DUMP_OOPS] = "oops",
14691469
[KMSG_DUMP_PANIC] = "panic",
1470+
[KMSG_DUMP_KEXEC] = "kexec",
14701471
};
14711472

14721473
static const char *kmsg_to_str(enum kmsg_dump_reason reason)

0 commit comments

Comments
 (0)