--- zzzz-none-000/linux-4.9.279/arch/arm/mm/alignment.c 2021-08-08 06:38:54.000000000 +0000 +++ puma7-arm-6591-750/linux-4.9.279/arch/arm/mm/alignment.c 2023-02-08 10:58:12.000000000 +0000 @@ -21,6 +21,9 @@ #include #include #include +#if defined(CONFIG_AVM_ENHANCED) +#include +#endif/*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ #include #include @@ -84,6 +87,7 @@ static unsigned long ai_dword; static unsigned long ai_multi; static int ai_usermode; +static int ai_kernelmode = 0; static unsigned long cr_no_alignment; core_param(alignment, ai_usermode, int, 0600); @@ -129,6 +133,32 @@ "signal+warn" }; +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ +int print_mem_config(struct mm_struct *mmm, unsigned long addr) { + struct vm_area_struct *vm; + unsigned int i = 0; + if(mmm == NULL) + return 0; + vm = mmm->mmap; + while(vm) { + if((addr >= vm->vm_start) && (addr < vm->vm_end)) { + printk(KERN_ERR"Adresse-Segment(%d): 0x%lx: 0x%lx :0x%lx (offset 0x%lx)", + i, vm->vm_start, addr, vm->vm_end, addr - vm->vm_start); + if(vm->vm_file) { + printk(" Path='%s'", vm->vm_file->f_path.dentry->d_name.name); + } + printk("\n"); + return 0; + } + vm = vm->vm_next; + i++; + } + return 1; +} + +/*------------------------------------------------------------------------------------------*\ +\*------------------------------------------------------------------------------------------*/ static int alignment_proc_show(struct seq_file *m, void *v) { seq_printf(m, "User:\t\t%lu\n", ai_user); @@ -141,7 +171,11 @@ seq_printf(m, "Multi:\t\t%lu\n", ai_multi); seq_printf(m, "User faults:\t%i (%s)\n", ai_usermode, usermode_action[ai_usermode]); - + seq_printf(m, "Kernel faults:\t%i (%s)\n", ai_kernelmode, usermode_action[ai_kernelmode ? 3 : 2]); +#if defined(CONFIG_AVM_ENHANCED) + ai_show_scorelist(m, 0); + ai_show_scorelist(m, 1); +#endif/*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ return 0; } @@ -158,8 +192,11 @@ if (count > 0) { if (get_user(mode, buffer)) return -EFAULT; - if (mode >= '0' && mode <= '5') + if (mode >= '0' && mode <= '5') { ai_usermode = safe_usermode(mode - '0', true); + } else if (mode >= '6' && mode <= '7') { + ai_kernelmode = mode - '6'; + } } return count; } @@ -844,10 +881,22 @@ goto user; ai_sys += 1; +#if defined(CONFIG_AVM_ENHANCED) + ai_add_to_scorelist(instrptr, 0); +#endif/*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ ai_sys_last_pc = (void *)instruction_pointer(regs); fixup: - + if(ai_kernelmode && !user_mode(regs)) { + printk(KERN_ERR "[unaligned %lu] pc=0x%08lx(%pF) addr=0x%08lx task=%s pid=%d lr=0x%08lx(%pF)\nCode: %08x <%08x> %08x\n", + ai_sys, regs->ARM_pc, (void *)regs->ARM_pc, addr, current->comm, current->pid, + regs->ARM_lr, (void *)regs->ARM_lr, + *(unsigned int *)(instrptr-4), *(unsigned int *)(instrptr), *(unsigned int *)(instrptr+4) + ); + if(print_mem_config(current->active_mm, (unsigned long)regs->ARM_pc)) { + print_mem_config(current->mm, (unsigned long)regs->ARM_pc); + } + } regs->ARM_pc += isize; switch (CODING_BITS(instr)) { @@ -962,14 +1011,21 @@ user: ai_user += 1; +#if defined(CONFIG_AVM_ENHANCED) + ai_add_to_scorelist(instrptr, 1); +#endif/*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ - if (ai_usermode & UM_WARN) - printk("Alignment trap: %s (%d) PC=0x%08lx Instr=0x%0*lx " + if (ai_usermode & UM_WARN) { + printk(KERN_ERR "Alignment trap: %s (%d) PC=0x%08lx Instr=0x%0*lx " "Address=0x%08lx FSR 0x%03x\n", current->comm, task_pid_nr(current), instrptr, isize << 1, isize == 2 ? tinstr : instr, addr, fsr); + if(print_mem_config(current->active_mm, (unsigned long)instrptr)) + print_mem_config(current->mm, (unsigned long)instrptr); + } + if (ai_usermode & UM_FIXUP) goto fixup;