aboutsummaryrefslogtreecommitdiffstats
path: root/arch/riscv/mm/fault.c
diff options
context:
space:
mode:
authorPekka Enberg <penberg@kernel.org>2020-08-25 19:01:43 +0300
committerPalmer Dabbelt <palmerdabbelt@google.com>2020-09-15 18:46:01 -0700
commitbda281d5bfb70f895880ebfb94a7f20d0604437f (patch)
tree1f48486d9f6e254e942dd5b547b21011ee29108d /arch/riscv/mm/fault.c
parentriscv/mm/fault: Move vmalloc fault handling to vmalloc_fault() (diff)
downloadlinux-dev-bda281d5bfb70f895880ebfb94a7f20d0604437f.tar.xz
linux-dev-bda281d5bfb70f895880ebfb94a7f20d0604437f.zip
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: Pekka Enberg <penberg@kernel.org> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Diffstat (limited to 'arch/riscv/mm/fault.c')
-rw-r--r--arch/riscv/mm/fault.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
index 460ea1d6c24e..bfb40927cb7a 100644
--- a/arch/riscv/mm/fault.c
+++ b/arch/riscv/mm/fault.c
@@ -247,14 +247,6 @@ good_area:
if (fault_signal_pending(fault, regs))
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))) {
flags |= FAULT_FLAG_TRIED;
@@ -267,6 +259,14 @@ good_area:
}
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;
/*
@@ -274,7 +274,6 @@ good_area:
* (which will retry the fault, or kill us if we got oom-killed).
*/
out_of_memory:
- mmap_read_unlock(mm);
if (!user_mode(regs)) {
no_context(regs, addr);
return;
@@ -283,7 +282,6 @@ out_of_memory:
return;
do_sigbus:
- mmap_read_unlock(mm);
/* Kernel mode? Handle exceptions or die */
if (!user_mode(regs)) {
no_context(regs, addr);