--- zzzz-none-000/linux-2.6.32.61/arch/mips/mm/fault.c 2013-06-10 09:43:48.000000000 +0000 +++ virian-300e-630/linux-2.6.32.61/arch/mips/mm/fault.c 2014-01-08 16:21:32.000000000 +0000 @@ -25,6 +25,16 @@ #include #include #include /* For VMALLOC_END */ +#if defined(CONFIG_NMI_ARBITER_WORKAROUND) +#include +#endif/*--- #if defined(CONFIG_NMI_ARBITER_WORKAROUND) ---*/ +#if defined(CONFIG_AVM_POWER) +#include +#endif/*--- #if defined(CONFIG_AVM_POWER) ---*/ + +#if defined(CONFIG_AVM_SIMPLE_PROFILING) +#include +#endif /*--- #if defined(CONFIG_AVM_SIMPLE_PROFILING) ---*/ /* * This routine handles page faults. It determines the address, @@ -41,6 +51,9 @@ siginfo_t info; int fault; +#if defined(CONFIG_AVM_SIMPLE_PROFILING) + avm_simple_profiling_enter_irqcontext((unsigned int)regs->cp0_epc); +#endif/*--- #if defined(CONFIG_AVM_SIMPLE_PROFILING) ---*/ #if 0 printk("Cpu%d[%s:%d:%0*lx:%ld:%0*lx]\n", raw_smp_processor_id(), current->comm, current->pid, field, address, write, @@ -49,6 +62,8 @@ info.si_code = SEGV_MAPERR; + current->pg_faults++; + /* * We fault-in kernel-space virtual memory on-demand. The * 'reference' page table is init_mm.pgd. @@ -108,7 +123,20 @@ * make sure we exit gracefully rather than endlessly redo * the fault. */ +#if defined(CONFIG_AVM_SIMPLE_PROFILING) + avm_simple_profiling_log(avm_profile_data_type_hw_irq_begin, (unsigned int)regs->cp0_epc, AVM_PROFILE_PAGE_FAULT_ID); +#endif/*--- #if defined(CONFIG_AVM_SIMPLE_PROFILING) ---*/ +#if defined(CONFIG_AVM_POWER) + avm_page_statistic_fault_get(); +#endif/*--- #if defined(CONFIG_AVM_POWER) ---*/ fault = handle_mm_fault(mm, vma, address, write ? FAULT_FLAG_WRITE : 0); +#if defined(CONFIG_AVM_POWER) + avm_page_statistic_fault_put(); +#endif/*--- #if defined(CONFIG_AVM_POWER) ---*/ +#if defined(CONFIG_AVM_SIMPLE_PROFILING) + avm_simple_profiling_log(avm_profile_data_type_hw_irq_end, regs->cp0_epc, AVM_PROFILE_PAGE_FAULT_ID); +#endif/*--- #endif ---*//*--- #if defined(CONFIG_AVM_SIMPLE_PROFILING) ---*/ + if (unlikely(fault & VM_FAULT_ERROR)) { if (fault & VM_FAULT_OOM) goto out_of_memory; @@ -159,7 +187,10 @@ current->thread.cp0_baduaddr = address; return; } - +write_protect_die: +#if defined(CONFIG_NMI_ARBITER_WORKAROUND) + ath_workaround_nmi_stop(); +#endif/*--- #if defined(CONFIG_NMI_ARBITER_WORKAROUND) ---*/ /* * Oops. The kernel tried to access some bad page. We'll have to * terminate things with extreme prejudice. @@ -170,6 +201,7 @@ "virtual address %0*lx, epc == %0*lx, ra == %0*lx\n", raw_smp_processor_id(), field, address, field, regs->cp0_epc, field, regs->regs[31]); + die("Oops", regs); out_of_memory: @@ -246,6 +278,11 @@ pte_k = pte_offset_kernel(pmd_k, address); if (!pte_present(*pte_k)) goto no_context; + + if(write && !pte_write(*pte_k)) { + printk(KERN_ALERT"----- VMALLOC-AREA WRITE-PROTECTED -----\n"); + goto write_protect_die; + } return; } #endif