--- zzzz-none-000/linux-4.1.52/arch/arm/kernel/traps.c 2018-05-28 02:26:45.000000000 +0000 +++ bcm63-7530ax-731/linux-4.1.52/arch/arm/kernel/traps.c 2022-03-02 11:37:12.000000000 +0000 @@ -37,7 +37,13 @@ #include #include #include - +#if defined(CONFIG_AVM_ENHANCED) +#include +#endif/*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ + +#if defined(CONFIG_AVM_FASTIRQ) +#include +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ static const char *handler[]= { "prefetch abort", @@ -65,7 +71,12 @@ void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame) { #ifdef CONFIG_KALLSYMS - printk("[<%08lx>] (%ps) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from); +#if defined(CONFIG_AVM_ENHANCED) + printk(KERN_ERR"%04lx: [<%08lx>] (%pS)\n", frame & (THREAD_SIZE - 1), where, (void *)where); +#else/*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ + printk(KERN_DEFAULT "[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", + where, (void *)where, from, (void *)from); +#endif/*--- #else ---*//*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ #else printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from); #endif @@ -119,14 +130,14 @@ for (p = first, i = 0; i < 8 && p < top; i++, p += 4) { if (p >= bottom && p < top) { - unsigned long val; + unsigned long val; if (__get_user(val, (unsigned long *)p) == 0) sprintf(str + i * 9, " %08lx", val); else sprintf(str + i * 9, " ????????"); } } - printk("%s%04lx:%s\n", lvl, first & 0xffff, str); + printk("%s%04lx:%s\n", lvl, first & 0xffff, str); } set_fs(fs); @@ -181,6 +192,9 @@ #ifdef CONFIG_ARM_UNWIND static inline void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) { +#if defined(CONFIG_AVM_ENHANCED) + printk(KERN_EMERG"Backtrace:\n"); +#endif/*--- #endif ---*//*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ unwind_backtrace(regs, tsk); } #else @@ -247,6 +261,9 @@ struct task_struct *tsk = current; static int die_counter; int ret; +#if defined(CONFIG_AVM_FASTIRQ) + tsk = current_thread_info_depend_on_context(regs)->task; +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ pr_emerg("Internal error: %s: %x [#%d]" S_PREEMPT S_SMP S_ISA "\n", str, err, ++die_counter); @@ -259,13 +276,16 @@ print_modules(); __show_regs(regs); pr_emerg("Process %.*s (pid: %d, stack limit = 0x%p)\n", - TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), end_of_stack(tsk)); + TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), end_of_stack(tsk)); if (!user_mode(regs) || in_interrupt()) { - dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp, - THREAD_SIZE + (unsigned long)task_stack_page(tsk)); + dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp, + THREAD_SIZE + (unsigned long)task_stack_page(tsk)); dump_backtrace(regs, tsk); dump_instr(KERN_EMERG, regs); +#if defined(CONFIG_AVM_ENHANCED) + show_stacktrace_memoryclassifier(regs); +#endif/*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ } return 0; @@ -300,7 +320,11 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr) { - if (regs && kexec_should_crash(current)) + struct thread_info *thread = current_thread_info(); +#if defined(CONFIG_AVM_FASTIRQ) + thread = current_thread_info_depend_on_context(regs); +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ + if (regs && kexec_should_crash(thread->task)) crash_kexec(regs); bust_spinlocks(0); @@ -313,6 +337,11 @@ raw_local_irq_restore(flags); oops_exit(); +#if defined(CONFIG_AVM_FASTIRQ) + if(panic_oops_on_fiq) { + panic("Fatal exception in fastirq"); + } +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ if (in_interrupt()) panic("Fatal exception in interrupt"); if (panic_on_oops) @@ -345,10 +374,14 @@ struct siginfo *info, unsigned long err, unsigned long trap) { if (user_mode(regs)) { - current->thread.error_code = err; - current->thread.trap_no = trap; + struct task_struct *tsk = current; +#if defined(CONFIG_AVM_FASTIRQ) + tsk = current_thread_info_depend_on_context(regs)->task; +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ + tsk->thread.error_code = err; + tsk->thread.trap_no = trap; - force_sig_info(info->si_signo, info, current); + force_sig_info(info->si_signo, info, tsk); } else { die(str, regs, err); } @@ -416,10 +449,21 @@ unsigned int instr; siginfo_t info; void __user *pc; - +#if defined(CONFIG_AVM_FASTIRQ) + struct pt_regs fregs; + prepare_register_for_trap(&fregs, ®s); + if(processor_mode(regs) == FIQ_MODE) { + panic_oops_on_fiq = 1 + raw_smp_processor_id(); + } +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ + early_printk("%s\n", __func__); pc = (void __user *)instruction_pointer(regs); - if (processor_mode(regs) == SVC_MODE) { + if (processor_mode(regs) == SVC_MODE +#if defined(CONFIG_AVM_FASTIRQ) + || (processor_mode(regs) == FIQ_MODE) +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ + ) { #ifdef CONFIG_THUMB2_KERNEL if (thumb_mode(regs)) { instr = __mem_to_opcode_thumb16(((u16 *)pc)[0]); @@ -454,8 +498,12 @@ die_sig: #ifdef CONFIG_DEBUG_USER if (user_debug & UDBG_UNDEFINED) { + struct task_struct *tsk = current; +#if defined(CONFIG_AVM_FASTIRQ) + tsk = current_thread_info_depend_on_context(regs)->task; +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ pr_info("%s (%d): undefined instruction: pc=%p\n", - current->comm, task_pid_nr(current), pc); + tsk->comm, task_pid_nr(tsk), pc); __show_regs(regs); dump_instr(KERN_INFO, regs); } @@ -502,10 +550,31 @@ */ asmlinkage void bad_mode(struct pt_regs *regs, int reason) { +#if defined(CONFIG_AVM_FASTIRQ) + struct pt_regs fregs; +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ console_verbose(); pr_crit("Bad mode in %s handler detected\n", handler[reason]); +#if defined(CONFIG_AVM_FASTIRQ) + prepare_register_for_trap(&fregs, ®s); + if(processor_mode(regs) == FIQ_MODE) { + if(reason == 4 /* BAD_UNDEFINSTR */) { + regs->ARM_pc -= thumb_mode(regs) ? 2 : 4; /*--- if undefined instruction so set pc on undefined instruction (so BUG_ON on fastirq possible) ---*/ + } + panic_oops_on_fiq = 1 + raw_smp_processor_id(); + } +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ +#if defined(CONFIG_AVM_FASTIRQ) + prepare_register_for_trap(&fregs, ®s); + if(processor_mode(regs) == FIQ_MODE) { + if(reason == 4 /* BAD_UNDEFINSTR */) { + regs->ARM_pc -= thumb_mode(regs) ? 2 : 4; /*--- if undefined instruction so set pc on undefined instruction (so BUG_ON on fastirq possible) ---*/ + } + panic_oops_on_fiq = 1 + raw_smp_processor_id(); + } +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ die("Oops - bad mode", regs, 0); local_irq_disable(); panic("bad mode"); @@ -775,12 +844,24 @@ unsigned long addr = instruction_pointer(regs); siginfo_t info; +#if defined(CONFIG_AVM_FASTIRQ) + struct pt_regs fregs; + prepare_register_for_trap(&fregs, ®s); + if(processor_mode(regs) == FIQ_MODE) { + panic_oops_on_fiq = 1 + raw_smp_processor_id(); + } +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ + #ifdef CONFIG_DEBUG_USER if (user_debug & UDBG_BADABORT) { - pr_err("[%d] %s: bad data abort: code %d instr 0x%08lx\n", - task_pid_nr(current), current->comm, code, instr); + struct task_struct *tsk = current; +#if defined(CONFIG_AVM_FASTIRQ) + tsk = current_thread_info_depend_on_context(regs)->task; +#endif/*--- #if defined(CONFIG_AVM_FASTIRQ) ---*/ + printk(KERN_ERR "[%d] %s: bad data abort: code %d instr 0x%08lx\n", + task_pid_nr(tsk), tsk->comm, code, instr); dump_instr(KERN_ERR, regs); - show_pte(current->mm, addr); + show_pte(tsk->mm, addr); } #endif