Merge remote-tracking branch 'origin/v4.4/topic/kprobes64' into linux-linaro-lsk...
[firefly-linux-kernel-4.4.55.git] / arch / arm64 / mm / fault.c
index edc3e20f7ba9371be929052730b02eb2aa4a07c6..6c16e4963b39092a30ad444f1862d39d270538ae 100644 (file)
 
 static const char *fault_name(unsigned int esr);
 
+#ifdef CONFIG_KPROBES
+static inline int notify_page_fault(struct pt_regs *regs, unsigned int esr)
+{
+       int ret = 0;
+
+       /* kprobe_running() needs smp_processor_id() */
+       if (!user_mode(regs)) {
+               preempt_disable();
+               if (kprobe_running() && kprobe_fault_handler(regs, esr))
+                       ret = 1;
+               preempt_enable();
+       }
+
+       return ret;
+}
+#else
+static inline int notify_page_fault(struct pt_regs *regs, unsigned int esr)
+{
+       return 0;
+}
+#endif
+
 /*
  * Dump out the page tables associated with 'addr' in mm 'mm'.
  */
@@ -259,6 +281,9 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
        unsigned long vm_flags = VM_READ | VM_WRITE | VM_EXEC;
        unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
 
+       if (notify_page_fault(regs, esr))
+               return 0;
+
        tsk = current;
        mm  = tsk->mm;
 
@@ -613,6 +638,7 @@ asmlinkage int __exception do_debug_exception(unsigned long addr,
 
        return 0;
 }
+NOKPROBE_SYMBOL(do_debug_exception);
 
 #ifdef CONFIG_ARM64_PAN
 void cpu_enable_pan(void *__unused)