--- zzzz-none-000/linux-4.4.271/arch/arm/mm/fault.c 2021-06-03 06:22:09.000000000 +0000 +++ hawkeye-5590-750/linux-4.4.271/arch/arm/mm/fault.c 2023-04-19 10:22:27.000000000 +0000 @@ -25,9 +25,23 @@ #include #include #include +#if defined(CONFIG_AVM_SIMPLE_PROFILING) +#include +#endif/*--- #if defined(CONFIG_AVM_SIMPLE_PROFILING) ---*/ +#if defined(CONFIG_AVM_POWER) +#include +#endif /*--- #if defined(CONFIG_AVM_POWER) ---*/ + +#if defined(CONFIG_AVM_FASTIRQ) +#include +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ + +#include #include "fault.h" +#include + #ifdef CONFIG_MMU #ifdef CONFIG_KPROBES @@ -141,6 +155,8 @@ /* * No handler, we'll have to terminate things with extreme prejudice. */ + start_avm_crash_path(regs); + bust_spinlocks(1); pr_alert("Unable to handle kernel %s at virtual address %08lx\n", (addr < PAGE_SIZE) ? "NULL pointer dereference" : @@ -163,6 +179,7 @@ { struct siginfo si; + trace_user_fault(tsk, addr, fsr); if (addr > TASK_SIZE) harden_branch_predictor(); @@ -246,7 +263,18 @@ goto out; } - return handle_mm_fault(mm, 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. + */ +#if defined(CONFIG_AVM_POWER) + avm_page_statistic_fault_get(); +#endif/*--- #if defined(CONFIG_AVM_POWER) ---*/ + fault = handle_mm_fault(mm, vma, addr & PAGE_MASK, flags); +#if defined(CONFIG_AVM_POWER) + avm_page_statistic_fault_put(); +#endif/*--- #if defined(CONFIG_AVM_POWER) ---*/ + return fault; check_stack: /* Don't allow expansion below FIRST_USER_ADDRESS */ @@ -265,6 +293,10 @@ int fault, sig, code; unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; +#if defined(CONFIG_AVM_SIMPLE_PROFILING) + avm_simple_profiling_enter_irq_context(regs->ARM_pc, regs->ARM_lr); +#endif/*--- #if defined(CONFIG_AVM_SIMPLE_PROFILING) ---*/ + if (notify_page_fault(regs, fsr)) return 0; @@ -311,7 +343,13 @@ #endif } +#if defined(CONFIG_AVM_SIMPLE_PROFILING) + avm_simple_profiling_log(avm_profile_data_type_hw_irq_begin, (unsigned int)regs->ARM_pc, AVM_PROFILE_PAGE_FAULT_ID); +#endif/*--- #if defined(CONFIG_AVM_SIMPLE_PROFILING) ---*/ fault = __do_page_fault(mm, addr, fsr, flags, tsk); +#if defined(CONFIG_AVM_SIMPLE_PROFILING) + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, (unsigned int)regs->ARM_pc, AVM_PROFILE_PAGE_FAULT_ID); +#endif/*--- #if defined(CONFIG_AVM_SIMPLE_PROFILING) ---*/ /* 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 @@ -436,6 +474,10 @@ if (addr < TASK_SIZE) return do_page_fault(addr, fsr, regs); +#if defined(CONFIG_AVM_SIMPLE_PROFILING) + avm_simple_profiling_enter_irq_context(regs->ARM_pc, regs->ARM_lr); +#endif/*--- #if defined(CONFIG_AVM_SIMPLE_PROFILING) ---*/ + if (user_mode(regs)) goto bad_area; @@ -558,6 +600,9 @@ pr_alert("Unhandled fault: %s (0x%03x) at 0x%08lx\n", inf->name, fsr, addr); + + start_avm_crash_path(regs); + show_pte(current->mm, addr); info.si_signo = inf->sig; @@ -592,6 +637,8 @@ pr_alert("Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n", inf->name, ifsr, addr); + start_avm_crash_path(regs); + info.si_signo = inf->sig; info.si_errno = 0; info.si_code = inf->code;