| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * arch/sh/mm/fault-nommu.c | 
|  | 3 | * | 
|  | 4 | * Copyright (C) 2002 Paul Mundt | 
|  | 5 | * | 
|  | 6 | * Based on linux/arch/sh/mm/fault.c: | 
|  | 7 | *  Copyright (C) 1999  Niibe Yutaka | 
|  | 8 | * | 
|  | 9 | * Released under the terms of the GNU GPL v2.0. | 
|  | 10 | */ | 
|  | 11 |  | 
|  | 12 | #include <linux/signal.h> | 
|  | 13 | #include <linux/sched.h> | 
|  | 14 | #include <linux/kernel.h> | 
|  | 15 | #include <linux/errno.h> | 
|  | 16 | #include <linux/string.h> | 
|  | 17 | #include <linux/types.h> | 
|  | 18 | #include <linux/ptrace.h> | 
|  | 19 | #include <linux/mman.h> | 
|  | 20 | #include <linux/mm.h> | 
|  | 21 | #include <linux/smp.h> | 
|  | 22 | #include <linux/smp_lock.h> | 
|  | 23 | #include <linux/interrupt.h> | 
|  | 24 |  | 
|  | 25 | #include <asm/system.h> | 
|  | 26 | #include <asm/io.h> | 
|  | 27 | #include <asm/uaccess.h> | 
|  | 28 | #include <asm/pgalloc.h> | 
|  | 29 | #include <asm/mmu_context.h> | 
|  | 30 | #include <asm/cacheflush.h> | 
|  | 31 |  | 
|  | 32 | #if defined(CONFIG_SH_KGDB) | 
|  | 33 | #include <asm/kgdb.h> | 
|  | 34 | #endif | 
|  | 35 |  | 
|  | 36 | extern void die(const char *,struct pt_regs *,long); | 
|  | 37 |  | 
|  | 38 | /* | 
|  | 39 | * This routine handles page faults.  It determines the address, | 
|  | 40 | * and the problem, and then passes it off to one of the appropriate | 
|  | 41 | * routines. | 
|  | 42 | */ | 
|  | 43 | asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess, | 
|  | 44 | unsigned long address) | 
|  | 45 | { | 
|  | 46 | #if defined(CONFIG_SH_KGDB) | 
|  | 47 | if (kgdb_nofault && kgdb_bus_err_hook) | 
|  | 48 | kgdb_bus_err_hook(); | 
|  | 49 | #endif | 
|  | 50 |  | 
|  | 51 | /* | 
|  | 52 | * Oops. The kernel tried to access some bad page. We'll have to | 
|  | 53 | * terminate things with extreme prejudice. | 
|  | 54 | * | 
|  | 55 | */ | 
|  | 56 | if (address < PAGE_SIZE) { | 
|  | 57 | printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference"); | 
|  | 58 | } else { | 
|  | 59 | printk(KERN_ALERT "Unable to handle kernel paging request"); | 
|  | 60 | } | 
|  | 61 |  | 
|  | 62 | printk(" at virtual address %08lx\n", address); | 
|  | 63 | printk(KERN_ALERT "pc = %08lx\n", regs->pc); | 
|  | 64 |  | 
|  | 65 | die("Oops", regs, writeaccess); | 
|  | 66 | do_exit(SIGKILL); | 
|  | 67 | } | 
|  | 68 |  | 
|  | 69 | asmlinkage int __do_page_fault(struct pt_regs *regs, unsigned long writeaccess, | 
|  | 70 | unsigned long address) | 
|  | 71 | { | 
|  | 72 | #if defined(CONFIG_SH_KGDB) | 
|  | 73 | if (kgdb_nofault && kgdb_bus_err_hook) | 
|  | 74 | kgdb_bus_err_hook(); | 
|  | 75 | #endif | 
|  | 76 |  | 
|  | 77 | if (address >= TASK_SIZE) | 
|  | 78 | return 1; | 
|  | 79 |  | 
|  | 80 | return 0; | 
|  | 81 | } | 
|  | 82 |  |