--- zzzz-none-000/linux-5.4.213/arch/arm/mm/fault.c 2022-09-15 10:04:56.000000000 +0000 +++ miami-7690-761/linux-5.4.213/arch/arm/mm/fault.c 2024-05-29 11:19:50.000000000 +0000 @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include "fault.h" @@ -115,6 +117,8 @@ /* * No handler, we'll have to terminate things with extreme prejudice. */ + start_avm_crash_path(regs); + bust_spinlocks(1); pr_alert("8<--- cut here ---\n"); pr_alert("Unable to handle kernel %s at virtual address %08lx\n", @@ -223,7 +227,12 @@ goto out; } - return handle_mm_fault(vma, addr & PAGE_MASK, flags); + /* + * If for any reason at all we couldn't handle the fault, make + * sure we exit gracefully rather than endlessly redo the fault. + */ + fault = handle_mm_fault(vma, addr & PAGE_MASK, flags); + return fault; check_stack: /* Don't allow expansion below FIRST_USER_ADDRESS */ @@ -243,6 +252,7 @@ vm_fault_t fault; unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; + avm_simple_profiling_enter_irq_context(regs->ARM_pc, regs->ARM_lr); if (kprobe_page_fault(regs, fsr)) return 0; @@ -289,7 +299,9 @@ #endif } + avm_simple_profiling_log(avm_profile_data_type_hw_irq_begin, regs->ARM_pc, AVM_PROFILE_PAGE_FAULT_ID); fault = __do_page_fault(mm, addr, fsr, flags, tsk); + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->ARM_pc, AVM_PROFILE_PAGE_FAULT_ID); /* If we need to retry but a fatal signal is pending, handle the * signal first. We do not need to release the mmap_sem because @@ -411,6 +423,7 @@ pud_t *pud, *pud_k; pmd_t *pmd, *pmd_k; + avm_simple_profiling_enter_irq_context(regs->ARM_pc, regs->ARM_lr); if (addr < TASK_SIZE) return do_page_fault(addr, fsr, regs); @@ -536,6 +549,9 @@ pr_alert("8<--- cut here ---\n"); pr_alert("Unhandled fault: %s (0x%03x) at 0x%08lx\n", inf->name, fsr, addr); + + start_avm_crash_path(regs); + show_pte(KERN_ALERT, current->mm, addr); arm_notify_die("", regs, inf->sig, inf->code, (void __user *)addr, @@ -566,6 +582,8 @@ pr_alert("Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n", inf->name, ifsr, addr); + start_avm_crash_path(regs); + arm_notify_die("", regs, inf->sig, inf->code, (void __user *)addr, ifsr, 0); }