]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/mm/fault.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6-omap-h63xx.git] / arch / arm / mm / fault.c
index c04124a095cfb7eb0603471fdd3dd6566592558f..28ad7ab1c0cd9cfc506623ec1dbcc91082bc9c14 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'.
@@ -145,8 +169,8 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
                __do_kernel_fault(mm, addr, fsr, regs);
 }
 
-#define VM_FAULT_BADMAP                (-20)
-#define VM_FAULT_BADACCESS     (-21)
+#define VM_FAULT_BADMAP                0x010000
+#define VM_FAULT_BADACCESS     0x020000
 
 static int
 __do_page_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
@@ -197,7 +221,7 @@ survive:
        return fault;
 
 out_of_memory:
-       if (!is_init(tsk))
+       if (!is_global_init(tsk))
                goto out;
 
        /*
@@ -215,13 +239,16 @@ out:
        return fault;
 }
 
-static int
+static int __kprobes
 do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 {
        struct task_struct *tsk;
        struct mm_struct *mm;
        int fault, sig, code;
 
+       if (notify_page_fault(regs, fsr))
+               return 0;
+
        tsk = current;
        mm  = tsk->mm;
 
@@ -249,7 +276,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
        /*
         * Handle the "normal" case first - VM_FAULT_MAJOR / VM_FAULT_MINOR
         */
-       if (likely(!(fault & VM_FAULT_ERROR)))
+       if (likely(!(fault & (VM_FAULT_ERROR | VM_FAULT_BADMAP | VM_FAULT_BADACCESS))))
                return 0;
 
        /*
@@ -266,7 +293,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
                 * the page fault gracefully.
                 */
                printk("VM: killing process %s\n", tsk->comm);
-               do_exit(SIGKILL);
+               do_group_exit(SIGKILL);
                return 0;
        }
        if (fault & VM_FAULT_SIGBUS) {
@@ -311,7 +338,7 @@ no_context:
  * interrupt or a critical region, and should only copy the information
  * from the master page table, nothing more.
  */
-static int
+static int __kprobes
 do_translation_fault(unsigned long addr, unsigned int fsr,
                     struct pt_regs *regs)
 {