Merge branch 'torvalds/master'
[firefly-linux-kernel-4.4.55.git] / arch / m68k / mm / fault.c
index a563727806bf922b5b3315559b9b46b5bbb9d7fc..6a94cdd0c8308cb70151d477872ccbeda2022ea8 100644 (file)
 #include <linux/ptrace.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
+#include <linux/uaccess.h>
 
 #include <asm/setup.h>
 #include <asm/traps.h>
-#include <asm/uaccess.h>
 #include <asm/pgalloc.h>
 
 extern void die_if_kernel(char *, struct pt_regs *, long);
@@ -25,9 +25,8 @@ int send_fault_sig(struct pt_regs *regs)
        siginfo.si_signo = current->thread.signo;
        siginfo.si_code = current->thread.code;
        siginfo.si_addr = (void *)current->thread.faddr;
-#ifdef DEBUG
-       printk("send_fault_sig: %p,%d,%d\n", siginfo.si_addr, siginfo.si_signo, siginfo.si_code);
-#endif
+       pr_debug("send_fault_sig: %p,%d,%d\n", siginfo.si_addr,
+                siginfo.si_signo, siginfo.si_code);
 
        if (user_mode(regs)) {
                force_sig_info(siginfo.si_signo,
@@ -45,10 +44,10 @@ int send_fault_sig(struct pt_regs *regs)
                 * terminate things with extreme prejudice.
                 */
                if ((unsigned long)siginfo.si_addr < PAGE_SIZE)
-                       printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference");
+                       pr_alert("Unable to handle kernel NULL pointer dereference");
                else
-                       printk(KERN_ALERT "Unable to handle kernel access");
-               printk(" at virtual address %p\n", siginfo.si_addr);
+                       pr_alert("Unable to handle kernel access");
+               pr_cont(" at virtual address %p\n", siginfo.si_addr);
                die_if_kernel("Oops", regs, 0 /*error_code*/);
                do_exit(SIGKILL);
        }
@@ -75,19 +74,18 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
        int fault;
        unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
 
-#ifdef DEBUG
-       printk ("do page fault:\nregs->sr=%#x, regs->pc=%#lx, address=%#lx, %ld, %p\n",
-               regs->sr, regs->pc, address, error_code,
-               current->mm->pgd);
-#endif
+       pr_debug("do page fault:\nregs->sr=%#x, regs->pc=%#lx, address=%#lx, %ld, %p\n",
+               regs->sr, regs->pc, address, error_code, mm ? mm->pgd : NULL);
 
        /*
         * If we're in an interrupt or have no user
         * context, we must not take the fault..
         */
-       if (in_atomic() || !mm)
+       if (faulthandler_disabled() || !mm)
                goto no_context;
 
+       if (user_mode(regs))
+               flags |= FAULT_FLAG_USER;
 retry:
        down_read(&mm->mmap_sem);
 
@@ -116,9 +114,7 @@ retry:
  * we can handle it..
  */
 good_area:
-#ifdef DEBUG
-       printk("do_page_fault: good_area\n");
-#endif
+       pr_debug("do_page_fault: good_area\n");
        switch (error_code & 3) {
                default:        /* 3: write, present */
                        /* fall through */
@@ -141,9 +137,7 @@ good_area:
         */
 
        fault = handle_mm_fault(mm, vma, address, flags);
-#ifdef DEBUG
-       printk("handle_mm_fault returns %d\n",fault);
-#endif
+       pr_debug("handle_mm_fault returns %d\n", fault);
 
        if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
                return 0;
@@ -151,6 +145,8 @@ good_area:
        if (unlikely(fault & VM_FAULT_ERROR)) {
                if (fault & VM_FAULT_OOM)
                        goto out_of_memory;
+               else if (fault & VM_FAULT_SIGSEGV)
+                       goto map_err;
                else if (fault & VM_FAULT_SIGBUS)
                        goto bus_err;
                BUG();