]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ARM kprobes: add the kprobes hook to the page fault handler
authorNicolas Pitre <nico@cam.org>
Mon, 3 Dec 2007 20:21:57 +0000 (15:21 -0500)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Sat, 26 Jan 2008 15:25:16 +0000 (15:25 +0000)
Signed-off-by: Nicolas Pitre <nico@marvell.com>
arch/arm/mm/fault.c

index a8a7dab757eb4977bfc88201da37dfe85713cdbc..1e7b1ed304d866d1210c48ee368f7b8d0ecd05d9 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/signal.h>
 #include <linux/mm.h>
 #include <linux/init.h>
+#include <linux/kprobes.h>
 
 #include <asm/system.h>
 #include <asm/pgtable.h>
 
 #include "fault.h"
 
+
+#ifdef CONFIG_KPROBES
+static inline int notify_page_fault(struct pt_regs *regs, unsigned int fsr)
+{
+       int ret = 0;
+
+       if (!user_mode(regs)) {
+               /* kprobe_running() needs smp_processor_id() */
+               preempt_disable();
+               if (kprobe_running() && kprobe_fault_handler(regs, fsr))
+                       ret = 1;
+               preempt_enable();
+       }
+
+       return ret;
+}
+#else
+static inline int notify_page_fault(struct pt_regs *regs, unsigned int fsr)
+{
+       return 0;
+}
+#endif
+
 /*
  * This is useful to dump out the page tables associated with
  * 'addr' in mm 'mm'.
@@ -222,6 +246,9 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
        struct mm_struct *mm;
        int fault, sig, code;
 
+       if (notify_page_fault(regs, fsr))
+               return 0;
+
        tsk = current;
        mm  = tsk->mm;