Patchwork [070/270] mips, kgdb: fix recursive page fault with CONFIG_KPROBES

mail settings
Submitter Herton Ronaldo Krzesinski
Date Nov. 26, 2012, 4:56 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/201803/
State New
Headers show


Herton Ronaldo Krzesinski - Nov. 26, 2012, 4:56 p.m.
3.5.7u1 -stable review patch.  If anyone has any objections, please let me know.


From: Jason Wessel <>

commit f0a996eeeda214f4293e234df33b29bec003b536 upstream.

This fault was detected using the kgdb test suite on boot and it
crashes recursively due to the fact that CONFIG_KPROBES on mips adds
an extra die notifier in the page fault handler.  The crash signature
looks like this:

kgdbts:RUN bad memory access test
KGDB: re-enter exception: ALL breakpoints killed
Call Trace:
[<807b7548>] dump_stack+0x20/0x54
[<807b7548>] dump_stack+0x20/0x54

The fix for now is to have kgdb return immediately if the fault type
is DIE_PAGE_FAULT and allow the kprobe code to decide what is supposed
to happen.

Cc: Masami Hiramatsu <>
Cc: David S. Miller <>
Signed-off-by: Jason Wessel <>
Signed-off-by: Herton Ronaldo Krzesinski <>
 arch/mips/kernel/kgdb.c |    9 +++++++++
 1 file changed, 9 insertions(+)


diff --git a/arch/mips/kernel/kgdb.c b/arch/mips/kernel/kgdb.c
index f4546e9..23817a6 100644
--- a/arch/mips/kernel/kgdb.c
+++ b/arch/mips/kernel/kgdb.c
@@ -283,6 +283,15 @@  static int kgdb_mips_notify(struct notifier_block *self, unsigned long cmd,
 	struct pt_regs *regs = args->regs;
 	int trap = (regs->cp0_cause & 0x7c) >> 2;
+	/*
+	 * Return immediately if the kprobes fault notifier has set
+	 */
+	if (cmd == DIE_PAGE_FAULT)
+		return NOTIFY_DONE;
+#endif /* CONFIG_KPROBES */
 	/* Userspace events, ignore. */
 	if (user_mode(regs))
 		return NOTIFY_DONE;