Skip to contentSkip to conversation

kdump: x86_64 add crashdump trigger points

PATCH In review Vivek Goyal 2 participants 3 messages Apr 10, 2006 – Apr 11, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kdump: x86_64 add crashdump trigger points

o Start booting into the capture kernel after an Oops if system is in a unrecoverable state. System will boot into the capture kernel, if one is pre-loaded by the user, and capture the kernel core dump.

o One of the following conditions should be true to trigger the booting of capture kernel.
- panic_on_oops is set.
- pid of current thread is 0
- pid of current thread is 1
- Oops happened inside interrupt context.

---

 arch/x86_64/kernel/traps.c  |    9 ++++++---
 arch/x86_64/mm/fault.c      |    4 ++--
 include/asm-x86_64/kdebug.h |    2 +-
 3 files changed, 9 insertions(+), 6 deletions(-)
arch/x86_64/kernel/traps.c renamed from arch/x86_64/kernel/traps.c~kdump-x86_64-add-crash-kexec-calls +6 -3
diff -puN arch/x86_64/kernel/traps.c~kdump-x86_64-add-crash-kexec-calls arch/x86_64/kernel/traps.c
@@ -30,6 +30,7 @@
 #include <linux/moduleparam.h>
 #include <linux/nmi.h>
 #include <linux/kprobes.h>
+#include <linux/kexec.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -404,11 +405,13 @@ unsigned __kprobes long oops_begin(void)
 	return flags;
 }
 
-void __kprobes oops_end(unsigned long flags)
+void __kprobes oops_end(unsigned long flags, struct pt_regs *regs)
 { 
 	die_owner = -1;
 	bust_spinlocks(0);
 	spin_unlock_irqrestore(&die_lock, flags);
+	if (kexec_should_crash(current))
+		crash_kexec(regs);
 	if (panic_on_oops)
 		panic("Oops");
 }
@@ -441,7 +444,7 @@ void die(const char * str, struct pt_reg
 
 	handle_BUG(regs);
 	__die(str, regs, err);
-	oops_end(flags);
+	oops_end(flags, regs);
 	do_exit(SIGSEGV); 
 }
 
@@ -458,7 +461,7 @@ void __kprobes die_nmi(char *str, struct
 	if (panic_on_timeout || panic_on_oops)
 		panic("nmi watchdog");
 	printk("console shuts up ...\n");
-	oops_end(flags);
+	oops_end(flags, regs);
 	do_exit(SIGSEGV);
 }
 
arch/x86_64/mm/fault.c renamed from arch/x86_64/mm/fault.c~kdump-x86_64-add-crash-kexec-calls +2 -2
diff -puN arch/x86_64/mm/fault.c~kdump-x86_64-add-crash-kexec-calls arch/x86_64/mm/fault.c
@@ -238,7 +238,7 @@ static noinline void pgtable_bad(unsigne
 	tsk->thread.trap_no = 14;
 	tsk->thread.error_code = error_code;
 	__die("Bad pagetable", regs, error_code);
-	oops_end(flags);
+	oops_end(flags, regs);
 	do_exit(SIGKILL);
 }
 
@@ -542,7 +542,7 @@ no_context:
 	__die("Oops", regs, error_code);
 	/* Executive summary in case the body of the oops scrolled away */
 	printk(KERN_EMERG "CR2: %016lx\n", address);
-	oops_end(flags);
+	oops_end(flags, regs);
 	do_exit(SIGKILL);
 
 /*
include/asm-x86_64/kdebug.h renamed from include/asm-x86_64/kdebug.h~kdump-x86_64-add-crash-kexec-calls +1 -1
diff -puN include/asm-x86_64/kdebug.h~kdump-x86_64-add-crash-kexec-calls include/asm-x86_64/kdebug.h
@@ -53,6 +53,6 @@ extern void __die(const char *,struct pt
 extern void show_registers(struct pt_regs *regs);
 extern void dump_pagetable(unsigned long);
 extern unsigned long oops_begin(void);
-extern void oops_end(unsigned long);
+extern void oops_end(unsigned long,struct pt_regs *);
 
 #endif

_

#1 lore raw
Quoted 6 lines · Vivek Goyal

o Start booting into the capture kernel after an Oops if system is in a unrecoverable state. System will boot into the capture kernel, if one is pre-loaded by the user, and capture the kernel core dump.

Quoted 6 lines

o One of the following conditions should be true to trigger the booting of capture kernel.
- panic_on_oops is set.
- pid of current thread is 0
- pid of current thread is 1
- Oops happened inside interrupt context.

I would rather put it into die(). Then the patch will be much smaller too.

-Andi

#2 lore raw
Quoted 14 lines · Andi Kleen
Quoted 6 lines · Vivek Goyal

o Start booting into the capture kernel after an Oops if system is in a unrecoverable state. System will boot into the capture kernel, if one is pre-loaded by the user, and capture the kernel core dump.

Quoted 6 lines

o One of the following conditions should be true to trigger the booting of capture kernel.
- panic_on_oops is set.
- pid of current thread is 0
- pid of current thread is 1
- Oops happened inside interrupt context.

Quoted 2 lines

I would rather put it into die(). Then the patch will be much smaller too.

Not everybody calls die(), instead they call __die() directly. For example do_page_fault(), pgtable_bad(). Hence I am putting this call inside __die().

Anyway, if capture kernel is loaded, after displaying the registers and backtrace, we probably don't want to do anything else and just boot into capture kernel. Please find attached the modified patch.

o Start booting into the capture kernel after an Oops if system is in a unrecoverable state. System will boot into the capture kernel, if one is pre-loaded by the user, and capture the kernel core dump.

o One of the following conditions should be true to trigger the booting of capture kernel.
- panic_on_oops is set.
- pid of current thread is 0
- pid of current thread is 1
- Oops happened inside interrupt context.

---

 arch/x86_64/kernel/traps.c |    5 +++++
 1 file changed, 5 insertions(+)
arch/x86_64/kernel/traps.c renamed from arch/x86_64/kernel/traps.c~kdump-x86_64-add-crashdump-trigger-points +5 -0
diff -puN arch/x86_64/kernel/traps.c~kdump-x86_64-add-crashdump-trigger-points arch/x86_64/kernel/traps.c
@@ -30,6 +30,7 @@
 #include <linux/moduleparam.h>
 #include <linux/nmi.h>
 #include <linux/kprobes.h>
+#include <linux/kexec.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -433,6 +434,8 @@ void __kprobes __die(const char * str, s
 	printk(KERN_ALERT "RIP ");
 	printk_address(regs->rip); 
 	printk(" RSP <%016lx>\n", regs->rsp); 
+	if (kexec_should_crash(current))
+		crash_kexec(regs);
 }
 
 void die(const char * str, struct pt_regs * regs, long err)
@@ -455,6 +458,8 @@ void __kprobes die_nmi(char *str, struct
 	 */
 	printk(str, safe_smp_processor_id());
 	show_registers(regs);
+	if (kexec_should_crash(current))
+		crash_kexec(regs);
 	if (panic_on_timeout || panic_on_oops)
 		panic("nmi watchdog");
 	printk("console shuts up ...\n");

_