Skip to content

Commit bda281d

Browse files
penbergpalmer-dabbelt
authored andcommitted
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>
1 parent ac416a7 commit bda281d

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

‎arch/riscv/mm/fault.c‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,6 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
247247
if (fault_signal_pending(fault, regs))
248248
return;
249249

250-
if (unlikely(fault & VM_FAULT_ERROR)) {
251-
if (fault & VM_FAULT_OOM)
252-
goto out_of_memory;
253-
else if (fault & VM_FAULT_SIGBUS)
254-
goto do_sigbus;
255-
BUG();
256-
}
257-
258250
if (unlikely((fault & VM_FAULT_RETRY) && (flags & FAULT_FLAG_ALLOW_RETRY))) {
259251
flags |= FAULT_FLAG_TRIED;
260252

@@ -267,14 +259,21 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
267259
}
268260

269261
mmap_read_unlock(mm);
262+
263+
if (unlikely(fault & VM_FAULT_ERROR)) {
264+
if (fault & VM_FAULT_OOM)
265+
goto out_of_memory;
266+
else if (fault & VM_FAULT_SIGBUS)
267+
goto do_sigbus;
268+
BUG();
269+
}
270270
return;
271271

272272
/*
273273
* We ran out of memory, call the OOM killer, and return the userspace
274274
* (which will retry the fault, or kill us if we got oom-killed).
275275
*/
276276
out_of_memory:
277-
mmap_read_unlock(mm);
278277
if (!user_mode(regs)) {
279278
no_context(regs, addr);
280279
return;
@@ -283,7 +282,6 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
283282
return;
284283

285284
do_sigbus:
286-
mmap_read_unlock(mm);
287285
/* Kernel mode? Handle exceptions or die */
288286
if (!user_mode(regs)) {
289287
no_context(regs, addr);

0 commit comments

Comments
 (0)