Loading arch/riscv/mm/fault.c +27 −21 Original line number Diff line number Diff line Loading @@ -156,6 +156,30 @@ static void inline vmalloc_fault(struct pt_regs *regs, int code, unsigned long a local_flush_tlb_page(addr); } static inline bool access_error(unsigned long cause, struct vm_area_struct *vma) { switch (cause) { case EXC_INST_PAGE_FAULT: if (!(vma->vm_flags & VM_EXEC)) { return true; } break; case EXC_LOAD_PAGE_FAULT: if (!(vma->vm_flags & VM_READ)) { return true; } break; case EXC_STORE_PAGE_FAULT: if (!(vma->vm_flags & VM_WRITE)) { return true; } break; default: panic("%s: unhandled cause %lu", __func__, cause); } return false; } /* * This routine handles page faults. It determines the address and the * problem, and then passes it off to one of the appropriate routines. Loading Loading @@ -236,28 +260,10 @@ asmlinkage void do_page_fault(struct pt_regs *regs) good_area: code = SEGV_ACCERR; switch (cause) { case EXC_INST_PAGE_FAULT: if (!(vma->vm_flags & VM_EXEC)) { bad_area(regs, mm, code, addr); return; } break; case EXC_LOAD_PAGE_FAULT: if (!(vma->vm_flags & VM_READ)) { if (unlikely(access_error(cause, vma))) { bad_area(regs, mm, code, addr); return; } break; case EXC_STORE_PAGE_FAULT: if (!(vma->vm_flags & VM_WRITE)) { bad_area(regs, mm, code, addr); return; } break; default: panic("%s: unhandled cause %lu", __func__, cause); } /* * If for any reason at all we could not handle the fault, Loading Loading
arch/riscv/mm/fault.c +27 −21 Original line number Diff line number Diff line Loading @@ -156,6 +156,30 @@ static void inline vmalloc_fault(struct pt_regs *regs, int code, unsigned long a local_flush_tlb_page(addr); } static inline bool access_error(unsigned long cause, struct vm_area_struct *vma) { switch (cause) { case EXC_INST_PAGE_FAULT: if (!(vma->vm_flags & VM_EXEC)) { return true; } break; case EXC_LOAD_PAGE_FAULT: if (!(vma->vm_flags & VM_READ)) { return true; } break; case EXC_STORE_PAGE_FAULT: if (!(vma->vm_flags & VM_WRITE)) { return true; } break; default: panic("%s: unhandled cause %lu", __func__, cause); } return false; } /* * This routine handles page faults. It determines the address and the * problem, and then passes it off to one of the appropriate routines. Loading Loading @@ -236,28 +260,10 @@ asmlinkage void do_page_fault(struct pt_regs *regs) good_area: code = SEGV_ACCERR; switch (cause) { case EXC_INST_PAGE_FAULT: if (!(vma->vm_flags & VM_EXEC)) { bad_area(regs, mm, code, addr); return; } break; case EXC_LOAD_PAGE_FAULT: if (!(vma->vm_flags & VM_READ)) { if (unlikely(access_error(cause, vma))) { bad_area(regs, mm, code, addr); return; } break; case EXC_STORE_PAGE_FAULT: if (!(vma->vm_flags & VM_WRITE)) { bad_area(regs, mm, code, addr); return; } break; default: panic("%s: unhandled cause %lu", __func__, cause); } /* * If for any reason at all we could not handle the fault, Loading