Commit 65d47fd4 authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt Committed by Michael Ellerman

powerpc/mm: Simplify returns from __do_page_fault

Now that we moved the exception state handling to a wrapper, we can
just directly return rather than "goto bail"
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent bb4be50e
...@@ -233,39 +233,36 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address, ...@@ -233,39 +233,36 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address,
if (error_code & ICSWX_DSI_UCT) { if (error_code & ICSWX_DSI_UCT) {
rc = acop_handle_fault(regs, address, error_code); rc = acop_handle_fault(regs, address, error_code);
if (rc) if (rc)
goto bail; return rc;
} }
#endif /* CONFIG_PPC_ICSWX */ #endif /* CONFIG_PPC_ICSWX */
if (notify_page_fault(regs)) if (notify_page_fault(regs))
goto bail; return 0;
if (unlikely(page_fault_is_bad(error_code))) { if (unlikely(page_fault_is_bad(error_code))) {
if (is_user) if (is_user) {
_exception(SIGBUS, regs, BUS_OBJERR, address); _exception(SIGBUS, regs, BUS_OBJERR, address);
else return 0;
rc = SIGBUS; }
goto bail; return SIGBUS;
} }
/* /*
* The kernel should never take an execute fault nor should it * The kernel should never take an execute fault nor should it
* take a page fault to a kernel address. * take a page fault to a kernel address.
*/ */
if (!is_user && (is_exec || (address >= TASK_SIZE))) { if (!is_user && (is_exec || (address >= TASK_SIZE)))
rc = SIGSEGV; return SIGSEGV;
goto bail;
}
/* We restore the interrupt state now */ /* We restore the interrupt state now */
if (!arch_irq_disabled_regs(regs)) if (!arch_irq_disabled_regs(regs))
local_irq_enable(); local_irq_enable();
if (faulthandler_disabled() || mm == NULL) { if (faulthandler_disabled() || mm == NULL) {
if (!is_user) { if (!is_user)
rc = SIGSEGV; return SIGSEGV;
goto bail;
}
/* faulthandler_disabled() in user mode is really bad, /* faulthandler_disabled() in user mode is really bad,
as is current->mm == NULL. */ as is current->mm == NULL. */
printk(KERN_EMERG "Page fault in user mode with " printk(KERN_EMERG "Page fault in user mode with "
...@@ -454,9 +451,8 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address, ...@@ -454,9 +451,8 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address,
goto bad_area_nosemaphore; goto bad_area_nosemaphore;
rc = mm_fault_error(regs, address, fault); rc = mm_fault_error(regs, address, fault);
if (rc >= MM_FAULT_RETURN) if (rc >= MM_FAULT_RETURN)
goto bail; return rc;
else rc = 0;
rc = 0;
} }
/* /*
...@@ -483,7 +479,7 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address, ...@@ -483,7 +479,7 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address,
regs, address); regs, address);
} }
goto bail; return rc;
bad_area: bad_area:
up_read(&mm->mmap_sem); up_read(&mm->mmap_sem);
...@@ -492,7 +488,7 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address, ...@@ -492,7 +488,7 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address,
/* User mode accesses cause a SIGSEGV */ /* User mode accesses cause a SIGSEGV */
if (is_user) { if (is_user) {
_exception(SIGSEGV, regs, code, address); _exception(SIGSEGV, regs, code, address);
goto bail; return 0;
} }
if (is_exec && (error_code & DSISR_PROTFAULT)) if (is_exec && (error_code & DSISR_PROTFAULT))
...@@ -500,10 +496,7 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address, ...@@ -500,10 +496,7 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address,
" page (%lx) - exploit attempt? (uid: %d)\n", " page (%lx) - exploit attempt? (uid: %d)\n",
address, from_kuid(&init_user_ns, current_uid())); address, from_kuid(&init_user_ns, current_uid()));
rc = SIGSEGV; return SIGSEGV;
bail:
return rc;
} }
NOKPROBE_SYMBOL(__do_page_fault); NOKPROBE_SYMBOL(__do_page_fault);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment