Skip to content

Commit

Permalink
arm: mm: drop VM_FAULT_BADMAP/VM_FAULT_BADACCESS
Browse files Browse the repository at this point in the history
If bad map or access, directly set code to SEGV_MAPRR or SEGV_ACCERR, also
set fault to 0 and goto error handling, which make us to drop the arch's
special vm fault reason.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Kefeng Wang <[email protected]>
Cc: Aishwarya TCV <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Cristian Marussi <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Russell King <[email protected]>
Cc: Will Deacon <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
Kefeng Wang authored and akpm00 committed Apr 29, 2024
1 parent 677d29b commit 5c57df0
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions arch/arm/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,6 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
}

#ifdef CONFIG_MMU
#define VM_FAULT_BADMAP ((__force vm_fault_t)0x010000)
#define VM_FAULT_BADACCESS ((__force vm_fault_t)0x020000)

static inline bool is_permission_fault(unsigned int fsr)
{
int fs = fsr_fs(fsr);
Expand Down Expand Up @@ -295,7 +292,8 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
if (!(vma->vm_flags & vm_flags)) {
vma_end_read(vma);
count_vm_vma_lock_event(VMA_LOCK_SUCCESS);
fault = VM_FAULT_BADACCESS;
fault = 0;
code = SEGV_ACCERR;
goto bad_area;
}
fault = handle_mm_fault(vma, addr, flags | FAULT_FLAG_VMA_LOCK, regs);
Expand All @@ -321,18 +319,23 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
retry:
vma = lock_mm_and_find_vma(mm, addr, regs);
if (unlikely(!vma)) {
fault = VM_FAULT_BADMAP;
fault = 0;
code = SEGV_MAPERR;
goto bad_area;
}

/*
* ok, we have a good vm_area for this memory access, check the
* permissions on the VMA allow for the fault which occurred.
*/
if (!(vma->vm_flags & vm_flags))
fault = VM_FAULT_BADACCESS;
else
fault = handle_mm_fault(vma, addr & PAGE_MASK, flags, regs);
if (!(vma->vm_flags & vm_flags)) {
mmap_read_unlock(mm);
fault = 0;
code = SEGV_ACCERR;
goto bad_area;
}

fault = handle_mm_fault(vma, addr & PAGE_MASK, flags, regs);

/* If we need to retry but a fatal signal is pending, handle the
* signal first. We do not need to release the mmap_lock because
Expand All @@ -358,12 +361,11 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
mmap_read_unlock(mm);
done:

/*
* Handle the "normal" case first - VM_FAULT_MAJOR
*/
if (likely(!(fault & (VM_FAULT_ERROR | VM_FAULT_BADMAP | VM_FAULT_BADACCESS))))
/* Handle the "normal" case first */
if (likely(!(fault & VM_FAULT_ERROR)))
return 0;

code = SEGV_MAPERR;
bad_area:
/*
* If we are in kernel mode at this point, we
Expand Down Expand Up @@ -395,8 +397,6 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
* isn't in our memory map..
*/
sig = SIGSEGV;
code = fault == VM_FAULT_BADACCESS ?
SEGV_ACCERR : SEGV_MAPERR;
}

__do_user_fault(addr, fsr, sig, code, regs);
Expand Down

0 comments on commit 5c57df0

Please sign in to comment.