root/arch/alpha/mm/fault.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. do_page_fault

   1 /*
   2  *  linux/arch/alpha/mm/fault.c
   3  *
   4  *  Copyright (C) 1995  Linus Torvalds
   5  */
   6 
   7 #include <linux/config.h>
   8 #include <linux/signal.h>
   9 #include <linux/sched.h>
  10 #include <linux/head.h>
  11 #include <linux/kernel.h>
  12 #include <linux/errno.h>
  13 #include <linux/string.h>
  14 #include <linux/types.h>
  15 #include <linux/ptrace.h>
  16 #include <linux/mman.h>
  17 #include <linux/mm.h>
  18 
  19 #include <asm/system.h>
  20 #include <asm/segment.h>
  21 
  22 extern void die_if_kernel(char *,struct pt_regs *,long);
  23 
  24 /*
  25  * This routine handles page faults.  It determines the address,
  26  * and the problem, and then passes it off to one of the appropriate
  27  * routines.
  28  *
  29  * mmcsr:
  30  *      0 = translation not valid (= do_no_page())
  31  *      1 = access violation (= user tries to access kernel pages)
  32  *      2 = fault-on-read
  33  *      3 = fault-on-execute
  34  *      4 = fault-on-write
  35  *
  36  * cause:
  37  *      -1 = instruction fetch
  38  *      0 = load
  39  *      1 = store
  40  */
  41 asmlinkage void do_page_fault(unsigned long address, unsigned long mmcsr,
     /* [previous][next][first][last][top][bottom][index][help] */
  42         long cause, struct pt_regs * regs)
  43 {
  44         struct vm_area_struct * vma;
  45 
  46         if (mmcsr == 1)
  47                 goto bad_area;
  48         vma = find_vma(current, address);
  49         if (!vma)
  50                 goto bad_area;
  51         if (vma->vm_start <= address)
  52                 goto good_area;
  53         if (!(vma->vm_flags & VM_GROWSDOWN))
  54                 goto bad_area;
  55         if (vma->vm_end - address > current->rlim[RLIMIT_STACK].rlim_cur)
  56                 goto bad_area;
  57         vma->vm_offset -= vma->vm_start - (address & PAGE_MASK);
  58         vma->vm_start = (address & PAGE_MASK);
  59 /*
  60  * Ok, we have a good vm_area for this memory access, so
  61  * we can handle it..
  62  */
  63 good_area:
  64         if (cause < 0) {
  65                 if (!(vma->vm_flags & VM_EXEC))
  66                         goto bad_area;
  67         } else if (!cause) {
  68                 if (!(vma->vm_flags & VM_READ))
  69                         goto bad_area;
  70         } else {
  71                 if (!(vma->vm_flags & VM_WRITE))
  72                         goto bad_area;
  73         }
  74 
  75         if (mmcsr) {
  76                 do_wp_page(vma, address, cause > 0);
  77                 return;
  78         }
  79         do_no_page(vma, address, cause > 0);
  80         return;
  81 
  82 /*
  83  * Something tried to access memory that isn't in our memory map..
  84  * Fix it, but check if it's kernel or user first..
  85  */
  86 bad_area:
  87         if (user_mode(regs)) {
  88                 send_sig(SIGSEGV, current, 1);
  89                 return;
  90         }
  91 /*
  92  * Oops. The kernel tried to access some bad page. We'll have to
  93  * terminate things with extreme prejudice.
  94  */
  95         printk(KERN_ALERT "Unable to handle kernel paging request at virtual address %08lx\n",address);
  96         die_if_kernel("Oops", regs, cause);
  97         do_exit(SIGKILL);
  98 }

/* [previous][next][first][last][top][bottom][index][help] */