Prechádzať zdrojové kódy

powerpc,kgdb: Introduce low level trap catching

The only way the debugger can handle a trap in inside rcu_lock,
notify_die, or atomic_notifier_call_chain without a recursive fault is
to allow the kernel debugger to handle the exception first in
program_check_exception().

The other change here is to make sure that kgdb_handle_exception() is
called with correct parameters when catching an oops, because kdb
needs to know if the entry was an oops, single step, or breakpoint
exception.

[benh@kernel.crashing.org: move debugger_bpt instead of #ifdef]

CC: Paul Mackerras <paulus@samba.org>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Jason Wessel 15 rokov pred
rodič
commit
ba797b2813
2 zmenil súbory, kde vykonal 9 pridanie a 4 odobranie
  1. 4 2
      arch/powerpc/kernel/kgdb.c
  2. 5 2
      arch/powerpc/kernel/traps.c

+ 4 - 2
arch/powerpc/kernel/kgdb.c

@@ -20,6 +20,7 @@
 #include <linux/smp.h>
 #include <linux/smp.h>
 #include <linux/signal.h>
 #include <linux/signal.h>
 #include <linux/ptrace.h>
 #include <linux/ptrace.h>
+#include <linux/kdebug.h>
 #include <asm/current.h>
 #include <asm/current.h>
 #include <asm/processor.h>
 #include <asm/processor.h>
 #include <asm/machdep.h>
 #include <asm/machdep.h>
@@ -115,7 +116,8 @@ void kgdb_roundup_cpus(unsigned long flags)
 /* KGDB functions to use existing PowerPC64 hooks. */
 /* KGDB functions to use existing PowerPC64 hooks. */
 static int kgdb_debugger(struct pt_regs *regs)
 static int kgdb_debugger(struct pt_regs *regs)
 {
 {
-	return kgdb_handle_exception(0, computeSignal(TRAP(regs)), 0, regs);
+	return !kgdb_handle_exception(1, computeSignal(TRAP(regs)),
+				      DIE_OOPS, regs);
 }
 }
 
 
 static int kgdb_handle_breakpoint(struct pt_regs *regs)
 static int kgdb_handle_breakpoint(struct pt_regs *regs)
@@ -123,7 +125,7 @@ static int kgdb_handle_breakpoint(struct pt_regs *regs)
 	if (user_mode(regs))
 	if (user_mode(regs))
 		return 0;
 		return 0;
 
 
-	if (kgdb_handle_exception(0, SIGTRAP, 0, regs) != 0)
+	if (kgdb_handle_exception(1, SIGTRAP, 0, regs) != 0)
 		return 0;
 		return 0;
 
 
 	if (*(u32 *) (regs->nip) == *(u32 *) (&arch_kgdb_ops.gdb_bpt_instr))
 	if (*(u32 *) (regs->nip) == *(u32 *) (&arch_kgdb_ops.gdb_bpt_instr))

+ 5 - 2
arch/powerpc/kernel/traps.c

@@ -815,12 +815,15 @@ void __kprobes program_check_exception(struct pt_regs *regs)
 		return;
 		return;
 	}
 	}
 	if (reason & REASON_TRAP) {
 	if (reason & REASON_TRAP) {
+		/* Debugger is first in line to stop recursive faults in
+		 * rcu_lock, notify_die, or atomic_notifier_call_chain */
+		if (debugger_bpt(regs))
+			return;
+
 		/* trap exception */
 		/* trap exception */
 		if (notify_die(DIE_BPT, "breakpoint", regs, 5, 5, SIGTRAP)
 		if (notify_die(DIE_BPT, "breakpoint", regs, 5, 5, SIGTRAP)
 				== NOTIFY_STOP)
 				== NOTIFY_STOP)
 			return;
 			return;
-		if (debugger_bpt(regs))
-			return;
 
 
 		if (!(regs->msr & MSR_PR) &&  /* not user-mode */
 		if (!(regs->msr & MSR_PR) &&  /* not user-mode */
 		    report_bug(regs->nip, regs) == BUG_TRAP_TYPE_WARN) {
 		    report_bug(regs->nip, regs) == BUG_TRAP_TYPE_WARN) {