Merge branch 'x86-trace-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[cascardo/linux.git] / arch / x86 / mm / fault.c
index e532230..1560a5d 100644 (file)
@@ -54,7 +54,7 @@ kmmio_fault(struct pt_regs *regs, unsigned long addr)
        return 0;
 }
 
-static inline int __kprobes notify_page_fault(struct pt_regs *regs)
+static inline int __kprobes kprobes_fault(struct pt_regs *regs)
 {
        int ret = 0;
 
@@ -1051,7 +1051,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
                        return;
 
                /* kprobes don't want to hook the spurious faults: */
-               if (notify_page_fault(regs))
+               if (kprobes_fault(regs))
                        return;
                /*
                 * Don't take the mm semaphore here. If we fixup a prefetch
@@ -1063,23 +1063,8 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
        }
 
        /* kprobes don't want to hook the spurious faults: */
-       if (unlikely(notify_page_fault(regs)))
+       if (unlikely(kprobes_fault(regs)))
                return;
-       /*
-        * It's safe to allow irq's after cr2 has been saved and the
-        * vmalloc fault has been handled.
-        *
-        * User-mode registers count as a user access even for any
-        * potential system fault or CPU buglet:
-        */
-       if (user_mode_vm(regs)) {
-               local_irq_enable();
-               error_code |= PF_USER;
-               flags |= FAULT_FLAG_USER;
-       } else {
-               if (regs->flags & X86_EFLAGS_IF)
-                       local_irq_enable();
-       }
 
        if (unlikely(error_code & PF_RSVD))
                pgtable_bad(regs, error_code, address);
@@ -1091,8 +1076,6 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
                }
        }
 
-       perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
-
        /*
         * If we're in an interrupt, have no user context or are running
         * in an atomic region then we must not take the fault:
@@ -1102,6 +1085,24 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
                return;
        }
 
+       /*
+        * It's safe to allow irq's after cr2 has been saved and the
+        * vmalloc fault has been handled.
+        *
+        * User-mode registers count as a user access even for any
+        * potential system fault or CPU buglet:
+        */
+       if (user_mode_vm(regs)) {
+               local_irq_enable();
+               error_code |= PF_USER;
+               flags |= FAULT_FLAG_USER;
+       } else {
+               if (regs->flags & X86_EFLAGS_IF)
+                       local_irq_enable();
+       }
+
+       perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
+
        if (error_code & PF_WRITE)
                flags |= FAULT_FLAG_WRITE;