powerpc/fault: Perform exception fixup in do_page_fault()
[sfrench/cifs-2.6.git] / arch / powerpc / mm / fault.c
index 389a2a87526298d1a547b97581a03abae1d57348..8961b44f350cd66480905e33dcc753337cf467f6 100644 (file)
@@ -545,10 +545,20 @@ NOKPROBE_SYMBOL(__do_page_fault);
 int do_page_fault(struct pt_regs *regs, unsigned long address,
                  unsigned long error_code)
 {
+       const struct exception_table_entry *entry;
        enum ctx_state prev_state = exception_enter();
        int rc = __do_page_fault(regs, address, error_code);
        exception_exit(prev_state);
-       return rc;
+       if (likely(!rc))
+               return 0;
+
+       entry = search_exception_tables(regs->nip);
+       if (unlikely(!entry))
+               return rc;
+
+       instruction_pointer_set(regs, extable_fixup(entry));
+
+       return 0;
 }
 NOKPROBE_SYMBOL(do_page_fault);
 
@@ -557,17 +567,10 @@ NOKPROBE_SYMBOL(do_page_fault);
  * It is called from the DSI and ISI handlers in head.S and from some
  * of the procedures in traps.c.
  */
-void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig)
+void __bad_page_fault(struct pt_regs *regs, unsigned long address, int sig)
 {
-       const struct exception_table_entry *entry;
        int is_write = page_fault_is_write(regs->dsisr);
 
-       /* Are we prepared to handle this fault?  */
-       if ((entry = search_exception_tables(regs->nip)) != NULL) {
-               regs->nip = extable_fixup(entry);
-               return;
-       }
-
        /* kernel has accessed a bad area */
 
        switch (TRAP(regs)) {
@@ -601,3 +604,15 @@ void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig)
 
        die("Kernel access of bad area", regs, sig);
 }
+
+void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig)
+{
+       const struct exception_table_entry *entry;
+
+       /* Are we prepared to handle this fault?  */
+       entry = search_exception_tables(instruction_pointer(regs));
+       if (entry)
+               instruction_pointer_set(regs, extable_fixup(entry));
+       else
+               __bad_page_fault(regs, address, sig);
+}