riscv/mm/fault: Move FAULT_FLAG_WRITE handling in do_page_fault()
authorPekka Enberg <penberg@kernel.org>
Tue, 25 Aug 2020 16:42:54 +0000 (19:42 +0300)
committerPalmer Dabbelt <palmerdabbelt@google.com>
Wed, 16 Sep 2020 01:46:04 +0000 (18:46 -0700)
Let's handle the translation of EXC_STORE_PAGE_FAULT to FAULT_FLAG_WRITE
once before looking up the VMA. This makes it easier to extract access
error logic in the next patch.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
arch/riscv/mm/fault.c

index 3b430fb..bdc70d3 100644 (file)
@@ -208,6 +208,9 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
 
        perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr);
 
+       if (cause == EXC_STORE_PAGE_FAULT)
+               flags |= FAULT_FLAG_WRITE;
+
 retry:
        mmap_read_lock(mm);
        vma = find_vma(mm, addr);
@@ -251,7 +254,6 @@ good_area:
                        bad_area(regs, mm, code, addr);
                        return;
                }
-               flags |= FAULT_FLAG_WRITE;
                break;
        default:
                panic("%s: unhandled cause %lu", __func__, cause);