Skip to content
Snippets Groups Projects
Select Git revision
  • 2a872a5dcec7052e9fd948ee77a62187791735ff
  • master default
  • android-container
  • nanopc-t4
  • for-kernelci
  • WIP-syscall
  • v4.16-rc5
  • v4.16-rc4
  • v4.16-rc3
  • v4.16-rc2
  • v4.16-rc1
  • v4.15
  • v4.15-rc9
  • v4.15-rc8
  • v4.15-rc7
  • v4.15-rc6
  • v4.15-rc5
  • v4.15-rc4
  • v4.15-rc3
  • v4.15-rc2
  • v4.15-rc1
  • v4.14
  • v4.14-rc8
  • v4.14-rc7
  • v4.14-rc6
  • v4.14-rc5
26 results

fault.c

Blame
  • fault.c 8.69 KiB
    /*
     * This file is subject to the terms and conditions of the GNU General Public
     * License.  See the file "COPYING" in the main directory of this archive
     * for more details.
     *
     * Copyright (C) 1995 - 2000 by Ralf Baechle
     */
    #include <linux/context_tracking.h>
    #include <linux/signal.h>
    #include <linux/sched.h>
    #include <linux/interrupt.h>
    #include <linux/kernel.h>
    #include <linux/errno.h>
    #include <linux/string.h>
    #include <linux/types.h>
    #include <linux/ptrace.h>
    #include <linux/ratelimit.h>
    #include <linux/mman.h>
    #include <linux/mm.h>
    #include <linux/smp.h>
    #include <linux/kprobes.h>
    #include <linux/perf_event.h>
    #include <linux/uaccess.h>
    
    #include <asm/branch.h>
    #include <asm/mmu_context.h>
    #include <asm/ptrace.h>
    #include <asm/highmem.h>		/* For VMALLOC_END */
    #include <linux/kdebug.h>
    
    int show_unhandled_signals = 1;
    
    /*
     * This routine handles page faults.  It determines the address,
     * and the problem, and then passes it off to one of the appropriate
     * routines.
     */
    static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,
    	unsigned long address)
    {
    	struct vm_area_struct * vma = NULL;
    	struct task_struct *tsk = current;
    	struct mm_struct *mm = tsk->mm;
    	const int field = sizeof(unsigned long) * 2;
    	siginfo_t info;
    	int fault;
    	unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
    
    	static DEFINE_RATELIMIT_STATE(ratelimit_state, 5 * HZ, 10);
    
    #if 0
    	printk("Cpu%d[%s:%d:%0*lx:%ld:%0*lx]\n", raw_smp_processor_id(),
    	       current->comm, current->pid, field, address, write,
    	       field, regs->cp0_epc);
    #endif
    
    #ifdef CONFIG_KPROBES
    	/*
    	 * This is to notify the fault handler of the kprobes.
    	 */
    	if (notify_die(DIE_PAGE_FAULT, "page fault", regs, -1,
    		       current->thread.trap_nr, SIGSEGV) == NOTIFY_STOP)
    		return;
    #endif
    
    	info.si_code = SEGV_MAPERR;
    
    	/*
    	 * We fault-in kernel-space virtual memory on-demand. The
    	 * 'reference' page table is init_mm.pgd.