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

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