Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/m32r/mm/fault.c |
| 3 | * |
| 4 | * Copyright (c) 2001, 2002 Hitoshi Yamamoto, and H. Kondo |
| 5 | * |
| 6 | * Some code taken from i386 version. |
| 7 | * Copyright (C) 1995 Linus Torvalds |
| 8 | */ |
| 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/signal.h> |
| 11 | #include <linux/sched.h> |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/errno.h> |
| 14 | #include <linux/string.h> |
| 15 | #include <linux/types.h> |
| 16 | #include <linux/ptrace.h> |
| 17 | #include <linux/mman.h> |
| 18 | #include <linux/mm.h> |
| 19 | #include <linux/smp.h> |
| 20 | #include <linux/smp_lock.h> |
| 21 | #include <linux/interrupt.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/vt_kern.h> /* For unblank_screen() */ |
| 24 | |
| 25 | #include <asm/m32r.h> |
| 26 | #include <asm/system.h> |
| 27 | #include <asm/uaccess.h> |
| 28 | #include <asm/pgalloc.h> |
| 29 | #include <asm/pgtable.h> |
| 30 | #include <asm/hardirq.h> |
| 31 | #include <asm/mmu_context.h> |
| 32 | |
| 33 | extern void die(const char *, struct pt_regs *, long); |
| 34 | |
| 35 | #ifndef CONFIG_SMP |
| 36 | asmlinkage unsigned int tlb_entry_i_dat; |
| 37 | asmlinkage unsigned int tlb_entry_d_dat; |
| 38 | #define tlb_entry_i tlb_entry_i_dat |
| 39 | #define tlb_entry_d tlb_entry_d_dat |
| 40 | #else |
| 41 | unsigned int tlb_entry_i_dat[NR_CPUS]; |
| 42 | unsigned int tlb_entry_d_dat[NR_CPUS]; |
| 43 | #define tlb_entry_i tlb_entry_i_dat[smp_processor_id()] |
| 44 | #define tlb_entry_d tlb_entry_d_dat[smp_processor_id()] |
| 45 | #endif |
| 46 | |
| 47 | /* |
| 48 | * Unlock any spinlocks which will prevent us from getting the |
| 49 | * message out |
| 50 | */ |
| 51 | void bust_spinlocks(int yes) |
| 52 | { |
| 53 | int loglevel_save = console_loglevel; |
| 54 | |
| 55 | if (yes) { |
| 56 | oops_in_progress = 1; |
| 57 | return; |
| 58 | } |
| 59 | #ifdef CONFIG_VT |
| 60 | unblank_screen(); |
| 61 | #endif |
| 62 | oops_in_progress = 0; |
| 63 | /* |
| 64 | * OK, the message is on the console. Now we call printk() |
| 65 | * without oops_in_progress set so that printk will give klogd |
| 66 | * a poke. Hold onto your hats... |
| 67 | */ |
Hirokazu Takata | fabb626 | 2007-02-10 01:43:40 -0800 | [diff] [blame^] | 68 | console_loglevel = 15; /* NMI oopser may have shut the console up */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | printk(" "); |
| 70 | console_loglevel = loglevel_save; |
| 71 | } |
| 72 | |
| 73 | void do_BUG(const char *file, int line) |
| 74 | { |
| 75 | bust_spinlocks(1); |
| 76 | printk("kernel BUG at %s:%d!\n", file, line); |
| 77 | } |
| 78 | |
| 79 | /*======================================================================* |
| 80 | * do_page_fault() |
| 81 | *======================================================================* |
| 82 | * This routine handles page faults. It determines the address, |
| 83 | * and the problem, and then passes it off to one of the appropriate |
| 84 | * routines. |
| 85 | * |
| 86 | * ARGUMENT: |
| 87 | * regs : M32R SP reg. |
| 88 | * error_code : See below |
| 89 | * address : M32R MMU MDEVA reg. (Operand ACE) |
| 90 | * : M32R BPC reg. (Instruction ACE) |
| 91 | * |
| 92 | * error_code : |
| 93 | * bit 0 == 0 means no page found, 1 means protection fault |
| 94 | * bit 1 == 0 means read, 1 means write |
| 95 | * bit 2 == 0 means kernel, 1 means user-mode |
| 96 | *======================================================================*/ |
| 97 | asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code, |
| 98 | unsigned long address) |
| 99 | { |
| 100 | |
| 101 | /* |
| 102 | * Oops. The kernel tried to access some bad page. We'll have to |
| 103 | * terminate things with extreme prejudice. |
| 104 | */ |
| 105 | |
| 106 | bust_spinlocks(1); |
| 107 | |
| 108 | if (address < PAGE_SIZE) |
| 109 | printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference"); |
| 110 | else |
| 111 | printk(KERN_ALERT "Unable to handle kernel paging request"); |
| 112 | printk(" at virtual address %08lx\n",address); |
| 113 | printk(" printing bpc:\n"); |
| 114 | printk(KERN_ALERT "bpc = %08lx\n", regs->bpc); |
| 115 | |
| 116 | die("Oops", regs, error_code); |
| 117 | bust_spinlocks(0); |
| 118 | do_exit(SIGKILL); |
| 119 | } |
| 120 | |
| 121 | /*======================================================================* |
| 122 | * update_mmu_cache() |
| 123 | *======================================================================*/ |
| 124 | void update_mmu_cache(struct vm_area_struct *vma, unsigned long addr, |
| 125 | pte_t pte) |
| 126 | { |
| 127 | BUG(); |
| 128 | } |
| 129 | |
| 130 | /*======================================================================* |
| 131 | * flush_tlb_page() : flushes one page |
| 132 | *======================================================================*/ |
| 133 | void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page) |
| 134 | { |
| 135 | BUG(); |
| 136 | } |
| 137 | |
| 138 | /*======================================================================* |
| 139 | * flush_tlb_range() : flushes a range of pages |
| 140 | *======================================================================*/ |
| 141 | void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, |
| 142 | unsigned long end) |
| 143 | { |
| 144 | BUG(); |
| 145 | } |
| 146 | |
| 147 | /*======================================================================* |
| 148 | * flush_tlb_mm() : flushes the specified mm context TLB's |
| 149 | *======================================================================*/ |
| 150 | void local_flush_tlb_mm(struct mm_struct *mm) |
| 151 | { |
| 152 | BUG(); |
| 153 | } |
| 154 | |
| 155 | /*======================================================================* |
| 156 | * flush_tlb_all() : flushes all processes TLBs |
| 157 | *======================================================================*/ |
| 158 | void local_flush_tlb_all(void) |
| 159 | { |
| 160 | BUG(); |
| 161 | } |