--- zzzz-none-000/linux-2.6.39.4/arch/arm/mm/alignment.c 2011-08-03 19:43:28.000000000 +0000 +++ puma6-arm-6490-729/linux-2.6.39.4/arch/arm/mm/alignment.c 2021-11-10 13:23:09.000000000 +0000 @@ -21,6 +21,9 @@ #include #include #include +#if defined(CONFIG_AVM_ENHANCED) +#include +#endif/*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ #include @@ -78,6 +81,7 @@ static unsigned long ai_dword; static unsigned long ai_multi; static int ai_usermode; +static int ai_kernelmode = 0; core_param(alignment, ai_usermode, int, 0600); @@ -95,6 +99,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); @@ -107,7 +137,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; } @@ -124,8 +158,11 @@ if (count > 0) { if (get_user(mode, buffer)) return -EFAULT; - if (mode >= '0' && mode <= '5') + if (mode >= '0' && mode <= '5') { ai_usermode = mode - '0'; + } else if (mode >= '6' && mode <= '7') { + ai_kernelmode = mode - '6'; + } } return count; } @@ -727,6 +764,7 @@ int isize = 4; int thumb2_32b = 0; + memset(&offset,0, sizeof(offset)); instrptr = instruction_pointer(regs); fs = get_fs(); @@ -759,9 +797,21 @@ goto user; ai_sys += 1; +#if defined(CONFIG_AVM_ENHANCED) + ai_add_to_scorelist(instrptr, 0); +#endif/*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ 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)) { @@ -871,14 +921,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;