Commit bda281d5 authored by Pekka Enberg's avatar Pekka Enberg Committed by Palmer Dabbelt

riscv/mm/fault: Simplify fault error handling

Move fault error handling after retry logic. This simplifies the code
flow and makes it easier to move fault error handling to its own
function.
Signed-off-by: default avatarPekka Enberg <penberg@kernel.org>
Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
parent ac416a72
...@@ -247,14 +247,6 @@ asmlinkage void do_page_fault(struct pt_regs *regs) ...@@ -247,14 +247,6 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
if (fault_signal_pending(fault, regs)) if (fault_signal_pending(fault, regs))
return; return;
if (unlikely(fault & VM_FAULT_ERROR)) {
if (fault & VM_FAULT_OOM)
goto out_of_memory;
else if (fault & VM_FAULT_SIGBUS)
goto do_sigbus;
BUG();
}
if (unlikely((fault & VM_FAULT_RETRY) && (flags & FAULT_FLAG_ALLOW_RETRY))) { if (unlikely((fault & VM_FAULT_RETRY) && (flags & FAULT_FLAG_ALLOW_RETRY))) {
flags |= FAULT_FLAG_TRIED; flags |= FAULT_FLAG_TRIED;
...@@ -267,6 +259,14 @@ asmlinkage void do_page_fault(struct pt_regs *regs) ...@@ -267,6 +259,14 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
} }
mmap_read_unlock(mm); mmap_read_unlock(mm);
if (unlikely(fault & VM_FAULT_ERROR)) {
if (fault & VM_FAULT_OOM)
goto out_of_memory;
else if (fault & VM_FAULT_SIGBUS)
goto do_sigbus;
BUG();
}
return; return;
/* /*
...@@ -274,7 +274,6 @@ asmlinkage void do_page_fault(struct pt_regs *regs) ...@@ -274,7 +274,6 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
* (which will retry the fault, or kill us if we got oom-killed). * (which will retry the fault, or kill us if we got oom-killed).
*/ */
out_of_memory: out_of_memory:
mmap_read_unlock(mm);
if (!user_mode(regs)) { if (!user_mode(regs)) {
no_context(regs, addr); no_context(regs, addr);
return; return;
...@@ -283,7 +282,6 @@ asmlinkage void do_page_fault(struct pt_regs *regs) ...@@ -283,7 +282,6 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
return; return;
do_sigbus: do_sigbus:
mmap_read_unlock(mm);
/* Kernel mode? Handle exceptions or die */ /* Kernel mode? Handle exceptions or die */
if (!user_mode(regs)) { if (!user_mode(regs)) {
no_context(regs, addr); no_context(regs, addr);
......
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