]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
sh: kprobes: Hook up kprobe_fault_handler() in the page fault path.
authorPaul Mundt <lethal@linux-sh.org>
Mon, 8 Sep 2008 03:22:47 +0000 (12:22 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Mon, 8 Sep 2008 03:22:47 +0000 (12:22 +0900)
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/include/asm/kprobes.h
arch/sh/kernel/kprobes.c
arch/sh/mm/fault_32.c

index 70fc629df904a6d9ded480576852942393d9e92b..756a5cd96378ceb2db3307650e7888fec0756bbc 100644 (file)
@@ -6,8 +6,6 @@
 #include <linux/types.h>
 #include <linux/ptrace.h>
 
-struct pt_regs;
-
 typedef u16 kprobe_opcode_t;
 #define BREAKPOINT_INSTRUCTION 0xc3ff
 
@@ -48,6 +46,7 @@ struct kprobe_ctlblk {
        struct prev_kprobe prev_kprobe;
 };
 
+extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
 extern int kprobe_exceptions_notify(struct notifier_block *self,
                                    unsigned long val, void *data);
 extern int kprobe_handle_illslot(unsigned long pc);
index ac6074942fd66fee308c46710ac4854043aa97ab..81a3725e515572610a9be847705d0182ef98fc49 100644 (file)
@@ -393,7 +393,7 @@ static inline int post_kprobe_handler(struct pt_regs *regs)
        return 1;
 }
 
-static inline int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
+int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
 {
        struct kprobe *cur = kprobe_running();
        struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
index e8efda9846bb3d5204d5df517247a2b783cf0933..659811c179e6a09290d90ac3c8bf12a2563bf9b7 100644 (file)
@@ -2,7 +2,7 @@
  * Page fault handler for SH with an MMU.
  *
  *  Copyright (C) 1999  Niibe Yutaka
- *  Copyright (C) 2003 - 2007  Paul Mundt
+ *  Copyright (C) 2003 - 2008  Paul Mundt
  *
  *  Based on linux/arch/i386/mm/fault.c:
  *   Copyright (C) 1995  Linus Torvalds
 #include <asm/tlbflush.h>
 #include <asm/kgdb.h>
 
+#ifdef CONFIG_KPROBES
+static inline int notify_page_fault(struct pt_regs *regs, int trap)
+{
+       int ret = 0;
+
+       if (!user_mode(regs)) {
+               preempt_disable();
+               if (kprobe_running() && kprobe_fault_handler(regs, trap))
+                       ret = 1;
+               preempt_enable();
+       }
+
+       return ret;
+}
+#else
+static inline int notify_page_fault(struct pt_regs *regs, int trap)
+{
+       return 0;
+}
+#endif
+
 /*
  * This routine handles page faults.  It determines the address,
  * and the problem, and then passes it off to one of the appropriate
@@ -37,6 +58,9 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
        int fault;
        siginfo_t info;
 
+       if (notify_page_fault(regs, writeaccess))
+               return;
+
 #ifdef CONFIG_SH_KGDB
        if (kgdb_nofault && kgdb_bus_err_hook)
                kgdb_bus_err_hook();
@@ -269,6 +293,9 @@ asmlinkage int __kprobes __do_page_fault(struct pt_regs *regs,
        pte_t *pte;
        pte_t entry;
 
+       if (notify_page_fault(regs, writeaccess))
+               return 0;
+
 #ifdef CONFIG_SH_KGDB
        if (kgdb_nofault && kgdb_bus_err_hook)
                kgdb_bus_err_hook();