--- zzzz-none-000/linux-4.19.183/arch/arm/kernel/traps.c 2021-03-24 10:07:39.000000000 +0000 +++ bcm63-7530ax-756/linux-4.19.183/arch/arm/kernel/traps.c 2023-06-28 08:54:18.000000000 +0000 @@ -40,7 +40,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", @@ -70,7 +76,12 @@ unsigned long end = frame + 4 + sizeof(struct pt_regs); #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 @@ -206,6 +217,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 @@ -272,6 +286,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); @@ -291,6 +308,9 @@ 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; @@ -325,7 +345,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); @@ -338,6 +362,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) @@ -355,6 +384,10 @@ unsigned long flags = oops_begin(); int sig = SIGSEGV; +#ifdef CONFIG_AVM_DEBUG + printk_avm_console_bend(0); +#endif + if (!user_mode(regs)) bug_type = report_bug(regs->ARM_pc, regs); if (bug_type != BUG_TRAP_TYPE_NONE) @@ -370,10 +403,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); } @@ -442,11 +479,22 @@ 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) ---*/ clear_siginfo(&info); 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]); @@ -481,8 +529,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); } @@ -530,10 +582,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"); @@ -747,15 +820,26 @@ { 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) ---*/ clear_siginfo(&info); #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