--- zzzz-none-000/linux-4.1.52/arch/arm/mm/fault.c 2018-05-28 02:26:45.000000000 +0000 +++ bcm63-7530ax-731/linux-4.1.52/arch/arm/mm/fault.c 2022-03-02 11:37:12.000000000 +0000 @@ -25,6 +25,12 @@ #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) ---*/ #include "fault.h" @@ -163,6 +169,11 @@ { struct siginfo si; +#if defined(CONFIG_BCM_KF_SPECTRE_PATCH) && defined(CONFIG_BCM_SPECTRE_PATCH_ENABLE) + if (addr > TASK_SIZE) + harden_branch_predictor(); +#endif + #ifdef CONFIG_DEBUG_USER if (((user_debug & UDBG_SEGV) && (sig == SIGSEGV)) || ((user_debug & UDBG_BUS) && (sig == SIGBUS))) { @@ -243,7 +254,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 */ @@ -262,6 +284,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; @@ -308,7 +334,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 @@ -433,6 +465,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;