ARM: 9165/1: mm: Provide is_write_fault()
authorWang Kefeng <wangkefeng.wang@huawei.com>
Fri, 3 Dec 2021 09:26:32 +0000 (10:26 +0100)
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Fri, 17 Dec 2021 11:34:37 +0000 (11:34 +0000)
The function will check whether the fault is caused by a write access,
it will be called in die_kernel_fault() too in next patch, so put it
before the function of die_kernel_fault().

Acked-by: Marco Elver <elver@google.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
arch/arm/mm/fault.c

index 013921a..1d41e8f 100644 (file)
@@ -99,6 +99,11 @@ void show_pte(const char *lvl, struct mm_struct *mm, unsigned long addr)
 { }
 #endif                                 /* CONFIG_MMU */
 
+static inline bool is_write_fault(unsigned int fsr)
+{
+       return (fsr & FSR_WRITE) && !(fsr & FSR_CM);
+}
+
 static void die_kernel_fault(const char *msg, struct mm_struct *mm,
                             unsigned long addr, unsigned int fsr,
                             struct pt_regs *regs)
@@ -261,7 +266,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
        if (user_mode(regs))
                flags |= FAULT_FLAG_USER;
 
-       if ((fsr & FSR_WRITE) && !(fsr & FSR_CM)) {
+       if (is_write_fault(fsr)) {
                flags |= FAULT_FLAG_WRITE;
                vm_flags = VM_WRITE;
        }