Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * File: arch/blackfin/kernel/traps.c |
| 3 | * Based on: |
| 4 | * Author: Hamish Macdonald |
| 5 | * |
| 6 | * Created: |
| 7 | * Description: uses S/W interrupt 15 for the system calls |
| 8 | * |
| 9 | * Modified: |
| 10 | * Copyright 2004-2006 Analog Devices Inc. |
| 11 | * |
| 12 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License as published by |
| 16 | * the Free Software Foundation; either version 2 of the License, or |
| 17 | * (at your option) any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program; if not, see the file COPYING, or write |
| 26 | * to the Free Software Foundation, Inc., |
| 27 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 28 | */ |
| 29 | |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 30 | #include <linux/uaccess.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 31 | #include <linux/interrupt.h> |
| 32 | #include <linux/module.h> |
| 33 | #include <linux/kallsyms.h> |
Bryan Wu | d31c5ab | 2007-08-10 13:00:42 -0700 | [diff] [blame] | 34 | #include <linux/fs.h> |
David Howells | 8feae13 | 2009-01-08 12:04:47 +0000 | [diff] [blame] | 35 | #include <linux/rbtree.h> |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 36 | #include <asm/traps.h> |
| 37 | #include <asm/cacheflush.h> |
Mike Frysinger | f4585a0 | 2008-10-13 14:45:21 +0800 | [diff] [blame] | 38 | #include <asm/cplb.h> |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 39 | #include <asm/blackfin.h> |
| 40 | #include <asm/irq_handler.h> |
Robin Getz | d8f66c8 | 2007-12-24 15:27:56 +0800 | [diff] [blame] | 41 | #include <linux/irq.h> |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 42 | #include <asm/trace.h> |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 43 | #include <asm/fixed_code.h> |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 44 | |
| 45 | #ifdef CONFIG_KGDB |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 46 | # include <linux/kgdb.h> |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 47 | |
| 48 | # define CHK_DEBUGGER_TRAP() \ |
| 49 | do { \ |
Sonic Zhang | a5ac012 | 2008-10-13 14:07:19 +0800 | [diff] [blame] | 50 | kgdb_handle_exception(trapnr, sig, info.si_code, fp); \ |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 51 | } while (0) |
| 52 | # define CHK_DEBUGGER_TRAP_MAYBE() \ |
| 53 | do { \ |
| 54 | if (kgdb_connected) \ |
| 55 | CHK_DEBUGGER_TRAP(); \ |
| 56 | } while (0) |
| 57 | #else |
| 58 | # define CHK_DEBUGGER_TRAP() do { } while (0) |
| 59 | # define CHK_DEBUGGER_TRAP_MAYBE() do { } while (0) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 60 | #endif |
| 61 | |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 62 | |
Robin Getz | 4ee1c45 | 2008-10-28 11:36:11 +0800 | [diff] [blame] | 63 | #ifdef CONFIG_DEBUG_VERBOSE |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 64 | #define verbose_printk(fmt, arg...) \ |
| 65 | printk(fmt, ##arg) |
| 66 | #else |
| 67 | #define verbose_printk(fmt, arg...) \ |
| 68 | ({ if (0) printk(fmt, ##arg); 0; }) |
| 69 | #endif |
| 70 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 71 | /* Initiate the event table handler */ |
| 72 | void __init trap_init(void) |
| 73 | { |
| 74 | CSYNC(); |
| 75 | bfin_write_EVT3(trap); |
| 76 | CSYNC(); |
| 77 | } |
| 78 | |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 79 | static void decode_address(char *buf, unsigned long address) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 80 | { |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 81 | #ifdef CONFIG_DEBUG_VERBOSE |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 82 | struct vm_list_struct *vml; |
| 83 | struct task_struct *p; |
| 84 | struct mm_struct *mm; |
Robin Getz | 885be03 | 2007-10-29 17:20:41 +0800 | [diff] [blame] | 85 | unsigned long flags, offset; |
Robin Getz | 904656c | 2008-03-26 09:17:43 +0800 | [diff] [blame] | 86 | unsigned char in_atomic = (bfin_read_IPEND() & 0x10) || in_atomic(); |
David Howells | 8feae13 | 2009-01-08 12:04:47 +0000 | [diff] [blame] | 87 | struct rb_node *n; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 88 | |
| 89 | #ifdef CONFIG_KALLSYMS |
Mike Frysinger | 8a0e665 | 2007-05-21 18:09:19 +0800 | [diff] [blame] | 90 | unsigned long symsize; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 91 | const char *symname; |
| 92 | char *modname; |
| 93 | char *delim = ":"; |
| 94 | char namebuf[128]; |
| 95 | |
| 96 | /* look up the address and see if we are in kernel space */ |
| 97 | symname = kallsyms_lookup(address, &symsize, &offset, &modname, namebuf); |
| 98 | |
| 99 | if (symname) { |
| 100 | /* yeah! kernel space! */ |
| 101 | if (!modname) |
| 102 | modname = delim = ""; |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 103 | sprintf(buf, "<0x%p> { %s%s%s%s + 0x%lx }", |
Mike Frysinger | 1f83b8f | 2007-07-12 22:58:21 +0800 | [diff] [blame] | 104 | (void *)address, delim, modname, delim, symname, |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 105 | (unsigned long)offset); |
Robin Getz | 885be03 | 2007-10-29 17:20:41 +0800 | [diff] [blame] | 106 | return; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 107 | |
| 108 | } |
| 109 | #endif |
| 110 | |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 111 | /* Problem in fixed code section? */ |
| 112 | if (address >= FIXED_CODE_START && address < FIXED_CODE_END) { |
| 113 | sprintf(buf, "<0x%p> /* Maybe fixed code section */", (void *)address); |
| 114 | return; |
| 115 | } |
| 116 | |
| 117 | /* Problem somewhere before the kernel start address */ |
| 118 | if (address < CONFIG_BOOT_LOAD) { |
| 119 | sprintf(buf, "<0x%p> /* Maybe null pointer? */", (void *)address); |
| 120 | return; |
| 121 | } |
| 122 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 123 | /* looks like we're off in user-land, so let's walk all the |
| 124 | * mappings of all our processes and see if we can't be a whee |
| 125 | * bit more specific |
| 126 | */ |
Robin Getz | 885be03 | 2007-10-29 17:20:41 +0800 | [diff] [blame] | 127 | write_lock_irqsave(&tasklist_lock, flags); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 128 | for_each_process(p) { |
Robin Getz | 904656c | 2008-03-26 09:17:43 +0800 | [diff] [blame] | 129 | mm = (in_atomic ? p->mm : get_task_mm(p)); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 130 | if (!mm) |
| 131 | continue; |
| 132 | |
David Howells | 8feae13 | 2009-01-08 12:04:47 +0000 | [diff] [blame] | 133 | for (n = rb_first(&mm->mm_rb); n; n = rb_next(n)) { |
| 134 | struct vm_area_struct *vma; |
| 135 | |
| 136 | vma = rb_entry(n, struct vm_area_struct, vm_rb); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 137 | |
| 138 | if (address >= vma->vm_start && address < vma->vm_end) { |
Jan Blunck | cf28b48 | 2008-02-14 19:38:44 -0800 | [diff] [blame] | 139 | char _tmpbuf[256]; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 140 | char *name = p->comm; |
| 141 | struct file *file = vma->vm_file; |
Jan Blunck | cf28b48 | 2008-02-14 19:38:44 -0800 | [diff] [blame] | 142 | |
Tim Pepper | 6a0bfff | 2008-10-27 12:18:36 +0800 | [diff] [blame] | 143 | if (file) { |
| 144 | char *d_name = d_path(&file->f_path, _tmpbuf, |
Jan Blunck | cf28b48 | 2008-02-14 19:38:44 -0800 | [diff] [blame] | 145 | sizeof(_tmpbuf)); |
Tim Pepper | 6a0bfff | 2008-10-27 12:18:36 +0800 | [diff] [blame] | 146 | if (!IS_ERR(d_name)) |
| 147 | name = d_name; |
| 148 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 149 | |
Mike Frysinger | 8a0e665 | 2007-05-21 18:09:19 +0800 | [diff] [blame] | 150 | /* FLAT does not have its text aligned to the start of |
| 151 | * the map while FDPIC ELF does ... |
| 152 | */ |
Mike Frysinger | 8a0e665 | 2007-05-21 18:09:19 +0800 | [diff] [blame] | 153 | |
Robin Getz | 7f1c906 | 2008-04-25 03:36:31 +0800 | [diff] [blame] | 154 | /* before we can check flat/fdpic, we need to |
| 155 | * make sure current is valid |
| 156 | */ |
| 157 | if ((unsigned long)current >= FIXED_CODE_START && |
| 158 | !((unsigned long)current & 0x3)) { |
| 159 | if (current->mm && |
| 160 | (address > current->mm->start_code) && |
| 161 | (address < current->mm->end_code)) |
| 162 | offset = address - current->mm->start_code; |
| 163 | else |
| 164 | offset = (address - vma->vm_start) + |
| 165 | (vma->vm_pgoff << PAGE_SHIFT); |
| 166 | |
| 167 | sprintf(buf, "<0x%p> [ %s + 0x%lx ]", |
| 168 | (void *)address, name, offset); |
| 169 | } else |
| 170 | sprintf(buf, "<0x%p> [ %s vma:0x%lx-0x%lx]", |
| 171 | (void *)address, name, |
| 172 | vma->vm_start, vma->vm_end); |
| 173 | |
Robin Getz | 904656c | 2008-03-26 09:17:43 +0800 | [diff] [blame] | 174 | if (!in_atomic) |
Robin Getz | 885be03 | 2007-10-29 17:20:41 +0800 | [diff] [blame] | 175 | mmput(mm); |
Robin Getz | 7f1c906 | 2008-04-25 03:36:31 +0800 | [diff] [blame] | 176 | |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 177 | if (!strlen(buf)) |
| 178 | sprintf(buf, "<0x%p> [ %s ] dynamic memory", (void *)address, name); |
| 179 | |
Robin Getz | 885be03 | 2007-10-29 17:20:41 +0800 | [diff] [blame] | 180 | goto done; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 181 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 182 | } |
Robin Getz | 904656c | 2008-03-26 09:17:43 +0800 | [diff] [blame] | 183 | if (!in_atomic) |
Robin Getz | 885be03 | 2007-10-29 17:20:41 +0800 | [diff] [blame] | 184 | mmput(mm); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 185 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 186 | |
| 187 | /* we were unable to find this address anywhere */ |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 188 | sprintf(buf, "<0x%p> /* kernel dynamic memory */", (void *)address); |
Robin Getz | 885be03 | 2007-10-29 17:20:41 +0800 | [diff] [blame] | 189 | |
| 190 | done: |
| 191 | write_unlock_irqrestore(&tasklist_lock, flags); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 192 | #else |
| 193 | sprintf(buf, " "); |
| 194 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 195 | } |
| 196 | |
Robin Getz | 2ebcade | 2007-10-09 17:24:30 +0800 | [diff] [blame] | 197 | asmlinkage void double_fault_c(struct pt_regs *fp) |
| 198 | { |
Robin Getz | a0cab65 | 2009-05-11 18:34:41 +0000 | [diff] [blame] | 199 | #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON |
| 200 | int j; |
| 201 | trace_buffer_save(j); |
| 202 | #endif |
| 203 | |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 204 | console_verbose(); |
| 205 | oops_in_progress = 1; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 206 | #ifdef CONFIG_DEBUG_VERBOSE |
Robin Getz | 2ebcade | 2007-10-09 17:24:30 +0800 | [diff] [blame] | 207 | printk(KERN_EMERG "\n" KERN_EMERG "Double Fault\n"); |
Robin Getz | 0c7a6b2 | 2008-10-08 16:27:12 +0800 | [diff] [blame] | 208 | #ifdef CONFIG_DEBUG_DOUBLEFAULT_PRINT |
| 209 | if (((long)fp->seqstat & SEQSTAT_EXCAUSE) == VEC_UNCOV) { |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 210 | unsigned int cpu = smp_processor_id(); |
Robin Getz | 0c7a6b2 | 2008-10-08 16:27:12 +0800 | [diff] [blame] | 211 | char buf[150]; |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 212 | decode_address(buf, cpu_pda[cpu].retx); |
Robin Getz | 0c7a6b2 | 2008-10-08 16:27:12 +0800 | [diff] [blame] | 213 | printk(KERN_EMERG "While handling exception (EXCAUSE = 0x%x) at %s:\n", |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 214 | (unsigned int)cpu_pda[cpu].seqstat & SEQSTAT_EXCAUSE, buf); |
| 215 | decode_address(buf, cpu_pda[cpu].dcplb_fault_addr); |
Robin Getz | 0c7a6b2 | 2008-10-08 16:27:12 +0800 | [diff] [blame] | 216 | printk(KERN_NOTICE " DCPLB_FAULT_ADDR: %s\n", buf); |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 217 | decode_address(buf, cpu_pda[cpu].icplb_fault_addr); |
Robin Getz | 0c7a6b2 | 2008-10-08 16:27:12 +0800 | [diff] [blame] | 218 | printk(KERN_NOTICE " ICPLB_FAULT_ADDR: %s\n", buf); |
| 219 | |
| 220 | decode_address(buf, fp->retx); |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 221 | printk(KERN_NOTICE "The instruction at %s caused a double exception\n", buf); |
Robin Getz | 0c7a6b2 | 2008-10-08 16:27:12 +0800 | [diff] [blame] | 222 | } else |
| 223 | #endif |
| 224 | { |
| 225 | dump_bfin_process(fp); |
| 226 | dump_bfin_mem(fp); |
| 227 | show_regs(fp); |
Robin Getz | a0cab65 | 2009-05-11 18:34:41 +0000 | [diff] [blame] | 228 | dump_bfin_trace_buffer(); |
Robin Getz | 0c7a6b2 | 2008-10-08 16:27:12 +0800 | [diff] [blame] | 229 | } |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 230 | #endif |
Mike Frysinger | d8804ad | 2009-04-29 06:26:46 +0000 | [diff] [blame] | 231 | panic("Double Fault - unrecoverable event"); |
Robin Getz | 2ebcade | 2007-10-09 17:24:30 +0800 | [diff] [blame] | 232 | |
| 233 | } |
| 234 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 235 | asmlinkage void trap_c(struct pt_regs *fp) |
| 236 | { |
Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 237 | #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON |
| 238 | int j; |
| 239 | #endif |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 240 | #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO |
| 241 | unsigned int cpu = smp_processor_id(); |
| 242 | #endif |
Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 243 | int sig = 0; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 244 | siginfo_t info; |
| 245 | unsigned long trapnr = fp->seqstat & SEQSTAT_EXCAUSE; |
| 246 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 247 | trace_buffer_save(j); |
| 248 | |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 249 | /* Important - be very careful dereferncing pointers - will lead to |
| 250 | * double faults if the stack has become corrupt |
| 251 | */ |
| 252 | |
| 253 | /* If the fault was caused by a kernel thread, or interrupt handler |
| 254 | * we will kernel panic, so the system reboots. |
| 255 | * If KGDB is enabled, don't set this for kernel breakpoints |
| 256 | */ |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 257 | |
| 258 | /* TODO: check to see if we are in some sort of deferred HWERR |
| 259 | * that we should be able to recover from, not kernel panic |
| 260 | */ |
Robin Getz | 6b5eace | 2008-01-10 17:57:56 +0800 | [diff] [blame] | 261 | if ((bfin_read_IPEND() & 0xFFC0) && (trapnr != VEC_STEP) |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 262 | #ifdef CONFIG_KGDB |
Robin Getz | 6b5eace | 2008-01-10 17:57:56 +0800 | [diff] [blame] | 263 | && (trapnr != VEC_EXCPT02) |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 264 | #endif |
| 265 | ){ |
| 266 | console_verbose(); |
| 267 | oops_in_progress = 1; |
| 268 | } else if (current) { |
| 269 | if (current->mm == NULL) { |
| 270 | console_verbose(); |
| 271 | oops_in_progress = 1; |
| 272 | } |
| 273 | } |
| 274 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 275 | /* trap_c() will be called for exceptions. During exceptions |
| 276 | * processing, the pc value should be set with retx value. |
| 277 | * With this change we can cleanup some code in signal.c- TODO |
| 278 | */ |
| 279 | fp->orig_pc = fp->retx; |
| 280 | /* printk("exception: 0x%x, ipend=%x, reti=%x, retx=%x\n", |
| 281 | trapnr, fp->ipend, fp->pc, fp->retx); */ |
| 282 | |
| 283 | /* send the appropriate signal to the user program */ |
| 284 | switch (trapnr) { |
| 285 | |
| 286 | /* This table works in conjuction with the one in ./mach-common/entry.S |
| 287 | * Some exceptions are handled there (in assembly, in exception space) |
| 288 | * Some are handled here, (in C, in interrupt space) |
| 289 | * Some, like CPLB, are handled in both, where the normal path is |
| 290 | * handled in assembly/exception space, and the error path is handled |
| 291 | * here |
| 292 | */ |
| 293 | |
| 294 | /* 0x00 - Linux Syscall, getting here is an error */ |
| 295 | /* 0x01 - userspace gdb breakpoint, handled here */ |
| 296 | case VEC_EXCPT01: |
| 297 | info.si_code = TRAP_ILLTRAP; |
| 298 | sig = SIGTRAP; |
| 299 | CHK_DEBUGGER_TRAP_MAYBE(); |
| 300 | /* Check if this is a breakpoint in kernel space */ |
| 301 | if (fp->ipend & 0xffc0) |
| 302 | return; |
| 303 | else |
| 304 | break; |
Mike Frysinger | 9401e61 | 2007-07-12 11:50:43 +0800 | [diff] [blame] | 305 | /* 0x03 - User Defined, userspace stack overflow */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 306 | case VEC_EXCPT03: |
| 307 | info.si_code = SEGV_STACKFLOW; |
| 308 | sig = SIGSEGV; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 309 | verbose_printk(KERN_NOTICE EXC_0x03(KERN_NOTICE)); |
Sonic Zhang | a5ac012 | 2008-10-13 14:07:19 +0800 | [diff] [blame] | 310 | CHK_DEBUGGER_TRAP_MAYBE(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 311 | break; |
Sonic Zhang | 27707d3 | 2008-10-09 14:04:41 +0800 | [diff] [blame] | 312 | /* 0x02 - KGDB initial connection and break signal trap */ |
| 313 | case VEC_EXCPT02: |
| 314 | #ifdef CONFIG_KGDB |
| 315 | info.si_code = TRAP_ILLTRAP; |
| 316 | sig = SIGTRAP; |
| 317 | CHK_DEBUGGER_TRAP(); |
| 318 | return; |
| 319 | #endif |
Robin Getz | 5c64e0d | 2008-10-08 14:43:47 +0800 | [diff] [blame] | 320 | /* 0x04 - User Defined */ |
| 321 | /* 0x05 - User Defined */ |
| 322 | /* 0x06 - User Defined */ |
| 323 | /* 0x07 - User Defined */ |
| 324 | /* 0x08 - User Defined */ |
| 325 | /* 0x09 - User Defined */ |
| 326 | /* 0x0A - User Defined */ |
| 327 | /* 0x0B - User Defined */ |
| 328 | /* 0x0C - User Defined */ |
| 329 | /* 0x0D - User Defined */ |
| 330 | /* 0x0E - User Defined */ |
| 331 | /* 0x0F - User Defined */ |
Sonic Zhang | 27707d3 | 2008-10-09 14:04:41 +0800 | [diff] [blame] | 332 | /* If we got here, it is most likely that someone was trying to use a |
Robin Getz | 5c64e0d | 2008-10-08 14:43:47 +0800 | [diff] [blame] | 333 | * custom exception handler, and it is not actually installed properly |
| 334 | */ |
| 335 | case VEC_EXCPT04 ... VEC_EXCPT15: |
| 336 | info.si_code = ILL_ILLPARAOP; |
| 337 | sig = SIGILL; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 338 | verbose_printk(KERN_NOTICE EXC_0x04(KERN_NOTICE)); |
Robin Getz | 5c64e0d | 2008-10-08 14:43:47 +0800 | [diff] [blame] | 339 | CHK_DEBUGGER_TRAP_MAYBE(); |
| 340 | break; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 341 | /* 0x10 HW Single step, handled here */ |
| 342 | case VEC_STEP: |
| 343 | info.si_code = TRAP_STEP; |
| 344 | sig = SIGTRAP; |
| 345 | CHK_DEBUGGER_TRAP_MAYBE(); |
| 346 | /* Check if this is a single step in kernel space */ |
| 347 | if (fp->ipend & 0xffc0) |
| 348 | return; |
| 349 | else |
| 350 | break; |
| 351 | /* 0x11 - Trace Buffer Full, handled here */ |
| 352 | case VEC_OVFLOW: |
| 353 | info.si_code = TRAP_TRACEFLOW; |
| 354 | sig = SIGTRAP; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 355 | verbose_printk(KERN_NOTICE EXC_0x11(KERN_NOTICE)); |
Sonic Zhang | a5ac012 | 2008-10-13 14:07:19 +0800 | [diff] [blame] | 356 | CHK_DEBUGGER_TRAP_MAYBE(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 357 | break; |
| 358 | /* 0x12 - Reserved, Caught by default */ |
| 359 | /* 0x13 - Reserved, Caught by default */ |
| 360 | /* 0x14 - Reserved, Caught by default */ |
| 361 | /* 0x15 - Reserved, Caught by default */ |
| 362 | /* 0x16 - Reserved, Caught by default */ |
| 363 | /* 0x17 - Reserved, Caught by default */ |
| 364 | /* 0x18 - Reserved, Caught by default */ |
| 365 | /* 0x19 - Reserved, Caught by default */ |
| 366 | /* 0x1A - Reserved, Caught by default */ |
| 367 | /* 0x1B - Reserved, Caught by default */ |
| 368 | /* 0x1C - Reserved, Caught by default */ |
| 369 | /* 0x1D - Reserved, Caught by default */ |
| 370 | /* 0x1E - Reserved, Caught by default */ |
| 371 | /* 0x1F - Reserved, Caught by default */ |
| 372 | /* 0x20 - Reserved, Caught by default */ |
| 373 | /* 0x21 - Undefined Instruction, handled here */ |
| 374 | case VEC_UNDEF_I: |
| 375 | info.si_code = ILL_ILLOPC; |
| 376 | sig = SIGILL; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 377 | verbose_printk(KERN_NOTICE EXC_0x21(KERN_NOTICE)); |
Sonic Zhang | a5ac012 | 2008-10-13 14:07:19 +0800 | [diff] [blame] | 378 | CHK_DEBUGGER_TRAP_MAYBE(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 379 | break; |
| 380 | /* 0x22 - Illegal Instruction Combination, handled here */ |
| 381 | case VEC_ILGAL_I: |
| 382 | info.si_code = ILL_ILLPARAOP; |
| 383 | sig = SIGILL; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 384 | verbose_printk(KERN_NOTICE EXC_0x22(KERN_NOTICE)); |
Sonic Zhang | a5ac012 | 2008-10-13 14:07:19 +0800 | [diff] [blame] | 385 | CHK_DEBUGGER_TRAP_MAYBE(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 386 | break; |
Robin Getz | f26fbc4 | 2007-11-12 22:21:30 +0800 | [diff] [blame] | 387 | /* 0x23 - Data CPLB protection violation, handled here */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 388 | case VEC_CPLB_VL: |
| 389 | info.si_code = ILL_CPLB_VI; |
Robin Getz | f26fbc4 | 2007-11-12 22:21:30 +0800 | [diff] [blame] | 390 | sig = SIGBUS; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 391 | verbose_printk(KERN_NOTICE EXC_0x23(KERN_NOTICE)); |
Sonic Zhang | a5ac012 | 2008-10-13 14:07:19 +0800 | [diff] [blame] | 392 | CHK_DEBUGGER_TRAP_MAYBE(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 393 | break; |
| 394 | /* 0x24 - Data access misaligned, handled here */ |
| 395 | case VEC_MISALI_D: |
| 396 | info.si_code = BUS_ADRALN; |
| 397 | sig = SIGBUS; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 398 | verbose_printk(KERN_NOTICE EXC_0x24(KERN_NOTICE)); |
Sonic Zhang | a5ac012 | 2008-10-13 14:07:19 +0800 | [diff] [blame] | 399 | CHK_DEBUGGER_TRAP_MAYBE(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 400 | break; |
| 401 | /* 0x25 - Unrecoverable Event, handled here */ |
| 402 | case VEC_UNCOV: |
| 403 | info.si_code = ILL_ILLEXCPT; |
| 404 | sig = SIGILL; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 405 | verbose_printk(KERN_NOTICE EXC_0x25(KERN_NOTICE)); |
Sonic Zhang | a5ac012 | 2008-10-13 14:07:19 +0800 | [diff] [blame] | 406 | CHK_DEBUGGER_TRAP_MAYBE(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 407 | break; |
| 408 | /* 0x26 - Data CPLB Miss, normal case is handled in _cplb_hdr, |
| 409 | error case is handled here */ |
| 410 | case VEC_CPLB_M: |
| 411 | info.si_code = BUS_ADRALN; |
| 412 | sig = SIGBUS; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 413 | verbose_printk(KERN_NOTICE EXC_0x26(KERN_NOTICE)); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 414 | break; |
| 415 | /* 0x27 - Data CPLB Multiple Hits - Linux Trap Zero, handled here */ |
| 416 | case VEC_CPLB_MHIT: |
| 417 | info.si_code = ILL_CPLB_MULHIT; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 418 | sig = SIGSEGV; |
Mike Frysinger | c6c6f75 | 2008-05-17 16:18:08 +0800 | [diff] [blame] | 419 | #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 420 | if (cpu_pda[cpu].dcplb_fault_addr < FIXED_CODE_START) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 421 | verbose_printk(KERN_NOTICE "NULL pointer access\n"); |
Mike Frysinger | c6c6f75 | 2008-05-17 16:18:08 +0800 | [diff] [blame] | 422 | else |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 423 | #endif |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 424 | verbose_printk(KERN_NOTICE EXC_0x27(KERN_NOTICE)); |
Sonic Zhang | a5ac012 | 2008-10-13 14:07:19 +0800 | [diff] [blame] | 425 | CHK_DEBUGGER_TRAP_MAYBE(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 426 | break; |
| 427 | /* 0x28 - Emulation Watchpoint, handled here */ |
| 428 | case VEC_WATCH: |
| 429 | info.si_code = TRAP_WATCHPT; |
| 430 | sig = SIGTRAP; |
Robin Getz | 569a50c | 2007-11-21 16:35:57 +0800 | [diff] [blame] | 431 | pr_debug(EXC_0x28(KERN_DEBUG)); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 432 | CHK_DEBUGGER_TRAP_MAYBE(); |
| 433 | /* Check if this is a watchpoint in kernel space */ |
| 434 | if (fp->ipend & 0xffc0) |
| 435 | return; |
| 436 | else |
| 437 | break; |
| 438 | #ifdef CONFIG_BF535 |
| 439 | /* 0x29 - Instruction fetch access error (535 only) */ |
| 440 | case VEC_ISTRU_VL: /* ADSP-BF535 only (MH) */ |
| 441 | info.si_code = BUS_OPFETCH; |
| 442 | sig = SIGBUS; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 443 | verbose_printk(KERN_NOTICE "BF535: VEC_ISTRU_VL\n"); |
Sonic Zhang | a5ac012 | 2008-10-13 14:07:19 +0800 | [diff] [blame] | 444 | CHK_DEBUGGER_TRAP_MAYBE(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 445 | break; |
| 446 | #else |
| 447 | /* 0x29 - Reserved, Caught by default */ |
| 448 | #endif |
| 449 | /* 0x2A - Instruction fetch misaligned, handled here */ |
| 450 | case VEC_MISALI_I: |
| 451 | info.si_code = BUS_ADRALN; |
| 452 | sig = SIGBUS; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 453 | verbose_printk(KERN_NOTICE EXC_0x2A(KERN_NOTICE)); |
Sonic Zhang | a5ac012 | 2008-10-13 14:07:19 +0800 | [diff] [blame] | 454 | CHK_DEBUGGER_TRAP_MAYBE(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 455 | break; |
Robin Getz | f26fbc4 | 2007-11-12 22:21:30 +0800 | [diff] [blame] | 456 | /* 0x2B - Instruction CPLB protection violation, handled here */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 457 | case VEC_CPLB_I_VL: |
| 458 | info.si_code = ILL_CPLB_VI; |
Robin Getz | f26fbc4 | 2007-11-12 22:21:30 +0800 | [diff] [blame] | 459 | sig = SIGBUS; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 460 | verbose_printk(KERN_NOTICE EXC_0x2B(KERN_NOTICE)); |
Sonic Zhang | a5ac012 | 2008-10-13 14:07:19 +0800 | [diff] [blame] | 461 | CHK_DEBUGGER_TRAP_MAYBE(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 462 | break; |
| 463 | /* 0x2C - Instruction CPLB miss, handled in _cplb_hdr */ |
| 464 | case VEC_CPLB_I_M: |
| 465 | info.si_code = ILL_CPLB_MISS; |
| 466 | sig = SIGBUS; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 467 | verbose_printk(KERN_NOTICE EXC_0x2C(KERN_NOTICE)); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 468 | break; |
| 469 | /* 0x2D - Instruction CPLB Multiple Hits, handled here */ |
| 470 | case VEC_CPLB_I_MHIT: |
| 471 | info.si_code = ILL_CPLB_MULHIT; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 472 | sig = SIGSEGV; |
Mike Frysinger | c6c6f75 | 2008-05-17 16:18:08 +0800 | [diff] [blame] | 473 | #ifdef CONFIG_DEBUG_HUNT_FOR_ZERO |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 474 | if (cpu_pda[cpu].icplb_fault_addr < FIXED_CODE_START) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 475 | verbose_printk(KERN_NOTICE "Jump to NULL address\n"); |
Mike Frysinger | c6c6f75 | 2008-05-17 16:18:08 +0800 | [diff] [blame] | 476 | else |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 477 | #endif |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 478 | verbose_printk(KERN_NOTICE EXC_0x2D(KERN_NOTICE)); |
Sonic Zhang | a5ac012 | 2008-10-13 14:07:19 +0800 | [diff] [blame] | 479 | CHK_DEBUGGER_TRAP_MAYBE(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 480 | break; |
| 481 | /* 0x2E - Illegal use of Supervisor Resource, handled here */ |
| 482 | case VEC_ILL_RES: |
| 483 | info.si_code = ILL_PRVOPC; |
| 484 | sig = SIGILL; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 485 | verbose_printk(KERN_NOTICE EXC_0x2E(KERN_NOTICE)); |
Sonic Zhang | a5ac012 | 2008-10-13 14:07:19 +0800 | [diff] [blame] | 486 | CHK_DEBUGGER_TRAP_MAYBE(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 487 | break; |
| 488 | /* 0x2F - Reserved, Caught by default */ |
| 489 | /* 0x30 - Reserved, Caught by default */ |
| 490 | /* 0x31 - Reserved, Caught by default */ |
| 491 | /* 0x32 - Reserved, Caught by default */ |
| 492 | /* 0x33 - Reserved, Caught by default */ |
| 493 | /* 0x34 - Reserved, Caught by default */ |
| 494 | /* 0x35 - Reserved, Caught by default */ |
| 495 | /* 0x36 - Reserved, Caught by default */ |
| 496 | /* 0x37 - Reserved, Caught by default */ |
| 497 | /* 0x38 - Reserved, Caught by default */ |
| 498 | /* 0x39 - Reserved, Caught by default */ |
| 499 | /* 0x3A - Reserved, Caught by default */ |
| 500 | /* 0x3B - Reserved, Caught by default */ |
| 501 | /* 0x3C - Reserved, Caught by default */ |
| 502 | /* 0x3D - Reserved, Caught by default */ |
| 503 | /* 0x3E - Reserved, Caught by default */ |
| 504 | /* 0x3F - Reserved, Caught by default */ |
Robin Getz | 13fe24f | 2008-01-27 15:38:56 +0800 | [diff] [blame] | 505 | case VEC_HWERR: |
| 506 | info.si_code = BUS_ADRALN; |
| 507 | sig = SIGBUS; |
| 508 | switch (fp->seqstat & SEQSTAT_HWERRCAUSE) { |
| 509 | /* System MMR Error */ |
| 510 | case (SEQSTAT_HWERRCAUSE_SYSTEM_MMR): |
| 511 | info.si_code = BUS_ADRALN; |
| 512 | sig = SIGBUS; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 513 | verbose_printk(KERN_NOTICE HWC_x2(KERN_NOTICE)); |
Robin Getz | 13fe24f | 2008-01-27 15:38:56 +0800 | [diff] [blame] | 514 | break; |
| 515 | /* External Memory Addressing Error */ |
| 516 | case (SEQSTAT_HWERRCAUSE_EXTERN_ADDR): |
| 517 | info.si_code = BUS_ADRERR; |
| 518 | sig = SIGBUS; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 519 | verbose_printk(KERN_NOTICE HWC_x3(KERN_NOTICE)); |
Robin Getz | 13fe24f | 2008-01-27 15:38:56 +0800 | [diff] [blame] | 520 | break; |
| 521 | /* Performance Monitor Overflow */ |
| 522 | case (SEQSTAT_HWERRCAUSE_PERF_FLOW): |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 523 | verbose_printk(KERN_NOTICE HWC_x12(KERN_NOTICE)); |
Robin Getz | 13fe24f | 2008-01-27 15:38:56 +0800 | [diff] [blame] | 524 | break; |
| 525 | /* RAISE 5 instruction */ |
| 526 | case (SEQSTAT_HWERRCAUSE_RAISE_5): |
| 527 | printk(KERN_NOTICE HWC_x18(KERN_NOTICE)); |
| 528 | break; |
| 529 | default: /* Reserved */ |
| 530 | printk(KERN_NOTICE HWC_default(KERN_NOTICE)); |
| 531 | break; |
| 532 | } |
Sonic Zhang | a5ac012 | 2008-10-13 14:07:19 +0800 | [diff] [blame] | 533 | CHK_DEBUGGER_TRAP_MAYBE(); |
Robin Getz | 13fe24f | 2008-01-27 15:38:56 +0800 | [diff] [blame] | 534 | break; |
Robin Getz | 5c64e0d | 2008-10-08 14:43:47 +0800 | [diff] [blame] | 535 | /* |
| 536 | * We should be handling all known exception types above, |
| 537 | * if we get here we hit a reserved one, so panic |
| 538 | */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 539 | default: |
Robin Getz | 5c64e0d | 2008-10-08 14:43:47 +0800 | [diff] [blame] | 540 | oops_in_progress = 1; |
| 541 | info.si_code = ILL_ILLPARAOP; |
| 542 | sig = SIGILL; |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 543 | verbose_printk(KERN_EMERG "Caught Unhandled Exception, code = %08lx\n", |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 544 | (fp->seqstat & SEQSTAT_EXCAUSE)); |
Sonic Zhang | a5ac012 | 2008-10-13 14:07:19 +0800 | [diff] [blame] | 545 | CHK_DEBUGGER_TRAP_MAYBE(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 546 | break; |
| 547 | } |
| 548 | |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 549 | BUG_ON(sig == 0); |
| 550 | |
| 551 | if (sig != SIGTRAP) { |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 552 | dump_bfin_process(fp); |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 553 | dump_bfin_mem(fp); |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 554 | show_regs(fp); |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 555 | |
| 556 | /* Print out the trace buffer if it makes sense */ |
| 557 | #ifndef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE |
| 558 | if (trapnr == VEC_CPLB_I_M || trapnr == VEC_CPLB_M) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 559 | verbose_printk(KERN_NOTICE "No trace since you do not have " |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 560 | "CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE enabled\n" |
| 561 | KERN_NOTICE "\n"); |
| 562 | else |
| 563 | #endif |
| 564 | dump_bfin_trace_buffer(); |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 565 | |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 566 | if (oops_in_progress) { |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 567 | /* Dump the current kernel stack */ |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 568 | verbose_printk(KERN_NOTICE "\n" KERN_NOTICE "Kernel Stack\n"); |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 569 | show_stack(current, NULL); |
Robin Getz | aee3a29 | 2008-01-11 16:53:00 +0800 | [diff] [blame] | 570 | print_modules(); |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 571 | #ifndef CONFIG_ACCESS_CHECK |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 572 | verbose_printk(KERN_EMERG "Please turn on " |
Robin Getz | 90c7f46 | 2007-11-18 00:35:33 +0800 | [diff] [blame] | 573 | "CONFIG_ACCESS_CHECK\n"); |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 574 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 575 | panic("Kernel exception"); |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 576 | } else { |
Robin Getz | 4ee1c45 | 2008-10-28 11:36:11 +0800 | [diff] [blame] | 577 | #ifdef CONFIG_DEBUG_VERBOSE |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 578 | unsigned long *stack; |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 579 | /* Dump the user space stack */ |
| 580 | stack = (unsigned long *)rdusp(); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 581 | verbose_printk(KERN_NOTICE "Userspace Stack\n"); |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 582 | show_stack(NULL, stack); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 583 | #endif |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 584 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 585 | } |
Robin Getz | fb32291 | 2007-11-21 16:38:05 +0800 | [diff] [blame] | 586 | |
Yi Li | 6a01f23 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 587 | #ifdef CONFIG_IPIPE |
| 588 | if (!ipipe_trap_notify(fp->seqstat & 0x3f, fp)) |
| 589 | #endif |
| 590 | { |
| 591 | info.si_signo = sig; |
| 592 | info.si_errno = 0; |
| 593 | info.si_addr = (void __user *)fp->pc; |
| 594 | force_sig_info(sig, &info, current); |
| 595 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 596 | |
Robin Getz | 0acad8d | 2009-05-11 18:55:16 +0000 | [diff] [blame^] | 597 | if (ANOMALY_05000461 && trapnr == VEC_HWERR && !access_ok(VERIFY_READ, fp->pc, 8)) |
| 598 | fp->pc = SAFE_USER_INSTRUCTION; |
| 599 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 600 | trace_buffer_restore(j); |
| 601 | return; |
| 602 | } |
| 603 | |
| 604 | /* Typical exception handling routines */ |
| 605 | |
Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 606 | #define EXPAND_LEN ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 256 - 1) |
| 607 | |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 608 | /* |
| 609 | * Similar to get_user, do some address checking, then dereference |
| 610 | * Return true on sucess, false on bad address |
| 611 | */ |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 612 | static bool get_instruction(unsigned short *val, unsigned short *address) |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 613 | { |
| 614 | |
| 615 | unsigned long addr; |
| 616 | |
| 617 | addr = (unsigned long)address; |
| 618 | |
| 619 | /* Check for odd addresses */ |
| 620 | if (addr & 0x1) |
| 621 | return false; |
| 622 | |
| 623 | /* Check that things do not wrap around */ |
| 624 | if (addr > (addr + 2)) |
| 625 | return false; |
| 626 | |
| 627 | /* |
| 628 | * Since we are in exception context, we need to do a little address checking |
| 629 | * We need to make sure we are only accessing valid memory, and |
| 630 | * we don't read something in the async space that can hang forever |
| 631 | */ |
| 632 | if ((addr >= FIXED_CODE_START && (addr + 2) <= physical_mem_end) || |
Mike Frysinger | 07aa7be | 2008-08-13 16:16:11 +0800 | [diff] [blame] | 633 | #if L2_LENGTH != 0 |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 634 | (addr >= L2_START && (addr + 2) <= (L2_START + L2_LENGTH)) || |
| 635 | #endif |
| 636 | (addr >= BOOT_ROM_START && (addr + 2) <= (BOOT_ROM_START + BOOT_ROM_LENGTH)) || |
| 637 | #if L1_DATA_A_LENGTH != 0 |
| 638 | (addr >= L1_DATA_A_START && (addr + 2) <= (L1_DATA_A_START + L1_DATA_A_LENGTH)) || |
| 639 | #endif |
| 640 | #if L1_DATA_B_LENGTH != 0 |
| 641 | (addr >= L1_DATA_B_START && (addr + 2) <= (L1_DATA_B_START + L1_DATA_B_LENGTH)) || |
| 642 | #endif |
| 643 | (addr >= L1_SCRATCH_START && (addr + 2) <= (L1_SCRATCH_START + L1_SCRATCH_LENGTH)) || |
| 644 | (!(bfin_read_EBIU_AMBCTL0() & B0RDYEN) && |
| 645 | addr >= ASYNC_BANK0_BASE && (addr + 2) <= (ASYNC_BANK0_BASE + ASYNC_BANK0_SIZE)) || |
| 646 | (!(bfin_read_EBIU_AMBCTL0() & B1RDYEN) && |
| 647 | addr >= ASYNC_BANK1_BASE && (addr + 2) <= (ASYNC_BANK1_BASE + ASYNC_BANK1_SIZE)) || |
| 648 | (!(bfin_read_EBIU_AMBCTL1() & B2RDYEN) && |
| 649 | addr >= ASYNC_BANK2_BASE && (addr + 2) <= (ASYNC_BANK2_BASE + ASYNC_BANK1_SIZE)) || |
| 650 | (!(bfin_read_EBIU_AMBCTL1() & B3RDYEN) && |
| 651 | addr >= ASYNC_BANK3_BASE && (addr + 2) <= (ASYNC_BANK3_BASE + ASYNC_BANK1_SIZE))) { |
| 652 | *val = *address; |
| 653 | return true; |
| 654 | } |
| 655 | |
| 656 | #if L1_CODE_LENGTH != 0 |
| 657 | if (addr >= L1_CODE_START && (addr + 2) <= (L1_CODE_START + L1_CODE_LENGTH)) { |
Robin Getz | 9df1028 | 2008-10-08 18:03:33 +0800 | [diff] [blame] | 658 | isram_memcpy(val, address, 2); |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 659 | return true; |
| 660 | } |
| 661 | #endif |
| 662 | |
| 663 | |
| 664 | return false; |
| 665 | } |
| 666 | |
Mike Frysinger | 36f649a | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 667 | /* |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 668 | * decode the instruction if we are printing out the trace, as it |
| 669 | * makes things easier to follow, without running it through objdump |
| 670 | * These are the normal instructions which cause change of flow, which |
| 671 | * would be at the source of the trace buffer |
| 672 | */ |
Mike Frysinger | 36f649a | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 673 | #if defined(CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_BFIN_HWTRACE_ON) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 674 | static void decode_instruction(unsigned short *address) |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 675 | { |
| 676 | unsigned short opcode; |
| 677 | |
| 678 | if (get_instruction(&opcode, address)) { |
| 679 | if (opcode == 0x0010) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 680 | verbose_printk("RTS"); |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 681 | else if (opcode == 0x0011) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 682 | verbose_printk("RTI"); |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 683 | else if (opcode == 0x0012) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 684 | verbose_printk("RTX"); |
Robin Getz | 0be5893 | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 685 | else if (opcode == 0x0013) |
| 686 | verbose_printk("RTN"); |
| 687 | else if (opcode == 0x0014) |
| 688 | verbose_printk("RTE"); |
| 689 | else if (opcode == 0x0025) |
| 690 | verbose_printk("EMUEXCPT"); |
| 691 | else if (opcode == 0x0040 && opcode <= 0x0047) |
| 692 | verbose_printk("STI R%i", opcode & 7); |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 693 | else if (opcode >= 0x0050 && opcode <= 0x0057) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 694 | verbose_printk("JUMP (P%i)", opcode & 7); |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 695 | else if (opcode >= 0x0060 && opcode <= 0x0067) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 696 | verbose_printk("CALL (P%i)", opcode & 7); |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 697 | else if (opcode >= 0x0070 && opcode <= 0x0077) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 698 | verbose_printk("CALL (PC+P%i)", opcode & 7); |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 699 | else if (opcode >= 0x0080 && opcode <= 0x0087) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 700 | verbose_printk("JUMP (PC+P%i)", opcode & 7); |
Robin Getz | 0be5893 | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 701 | else if (opcode >= 0x0090 && opcode <= 0x009F) |
| 702 | verbose_printk("RAISE 0x%x", opcode & 0xF); |
| 703 | else if (opcode >= 0x00A0 && opcode <= 0x00AF) |
| 704 | verbose_printk("EXCPT 0x%x", opcode & 0xF); |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 705 | else if ((opcode >= 0x1000 && opcode <= 0x13FF) || (opcode >= 0x1800 && opcode <= 0x1BFF)) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 706 | verbose_printk("IF !CC JUMP"); |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 707 | else if ((opcode >= 0x1400 && opcode <= 0x17ff) || (opcode >= 0x1c00 && opcode <= 0x1fff)) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 708 | verbose_printk("IF CC JUMP"); |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 709 | else if (opcode >= 0x2000 && opcode <= 0x2fff) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 710 | verbose_printk("JUMP.S"); |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 711 | else if (opcode >= 0xe080 && opcode <= 0xe0ff) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 712 | verbose_printk("LSETUP"); |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 713 | else if (opcode >= 0xe200 && opcode <= 0xe2ff) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 714 | verbose_printk("JUMP.L"); |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 715 | else if (opcode >= 0xe300 && opcode <= 0xe3ff) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 716 | verbose_printk("CALL pcrel"); |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 717 | else |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 718 | verbose_printk("0x%04x", opcode); |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | } |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 722 | #endif |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 723 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 724 | void dump_bfin_trace_buffer(void) |
| 725 | { |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 726 | #ifdef CONFIG_DEBUG_VERBOSE |
Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 727 | #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON |
| 728 | int tflags, i = 0; |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 729 | char buf[150]; |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 730 | unsigned short *addr; |
Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 731 | #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND |
| 732 | int j, index; |
| 733 | #endif |
| 734 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 735 | trace_buffer_save(tflags); |
| 736 | |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 737 | printk(KERN_NOTICE "Hardware Trace:\n"); |
Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 738 | |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 739 | #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND |
| 740 | printk(KERN_NOTICE "WARNING: Expanded trace turned on - can not trace exceptions\n"); |
| 741 | #endif |
| 742 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 743 | if (likely(bfin_read_TBUFSTAT() & TBUFCNT)) { |
Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 744 | for (; bfin_read_TBUFSTAT() & TBUFCNT; i++) { |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 745 | decode_address(buf, (unsigned long)bfin_read_TBUF()); |
| 746 | printk(KERN_NOTICE "%4i Target : %s\n", i, buf); |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 747 | addr = (unsigned short *)bfin_read_TBUF(); |
| 748 | decode_address(buf, (unsigned long)addr); |
| 749 | printk(KERN_NOTICE " Source : %s ", buf); |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 750 | decode_instruction(addr); |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 751 | printk("\n"); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 752 | } |
| 753 | } |
| 754 | |
Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 755 | #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND |
| 756 | if (trace_buff_offset) |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 757 | index = trace_buff_offset / 4; |
Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 758 | else |
| 759 | index = EXPAND_LEN; |
| 760 | |
| 761 | j = (1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 128; |
| 762 | while (j) { |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 763 | decode_address(buf, software_trace_buff[index]); |
| 764 | printk(KERN_NOTICE "%4i Target : %s\n", i, buf); |
Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 765 | index -= 1; |
| 766 | if (index < 0 ) |
| 767 | index = EXPAND_LEN; |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 768 | decode_address(buf, software_trace_buff[index]); |
Robin Getz | d3d0ac2 | 2008-08-06 17:49:27 +0800 | [diff] [blame] | 769 | printk(KERN_NOTICE " Source : %s ", buf); |
| 770 | decode_instruction((unsigned short *)software_trace_buff[index]); |
| 771 | printk("\n"); |
Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 772 | index -= 1; |
| 773 | if (index < 0) |
| 774 | index = EXPAND_LEN; |
Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 775 | j--; |
| 776 | i++; |
| 777 | } |
| 778 | #endif |
| 779 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 780 | trace_buffer_restore(tflags); |
Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 781 | #endif |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 782 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 783 | } |
| 784 | EXPORT_SYMBOL(dump_bfin_trace_buffer); |
| 785 | |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 786 | /* |
| 787 | * Checks to see if the address pointed to is either a |
| 788 | * 16-bit CALL instruction, or a 32-bit CALL instruction |
| 789 | */ |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 790 | static bool is_bfin_call(unsigned short *addr) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 791 | { |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 792 | unsigned short opcode = 0, *ins_addr; |
| 793 | ins_addr = (unsigned short *)addr; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 794 | |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 795 | if (!get_instruction(&opcode, ins_addr)) |
| 796 | return false; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 797 | |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 798 | if ((opcode >= 0x0060 && opcode <= 0x0067) || |
| 799 | (opcode >= 0x0070 && opcode <= 0x0077)) |
| 800 | return true; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 801 | |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 802 | ins_addr--; |
| 803 | if (!get_instruction(&opcode, ins_addr)) |
| 804 | return false; |
| 805 | |
| 806 | if (opcode >= 0xE300 && opcode <= 0xE3FF) |
| 807 | return true; |
| 808 | |
| 809 | return false; |
| 810 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 811 | } |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 812 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 813 | void show_stack(struct task_struct *task, unsigned long *stack) |
| 814 | { |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 815 | #ifdef CONFIG_PRINTK |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 816 | unsigned int *addr, *endstack, *fp = 0, *frame; |
| 817 | unsigned short *ins_addr; |
| 818 | char buf[150]; |
| 819 | unsigned int i, j, ret_addr, frame_no = 0; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 820 | |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 821 | /* |
| 822 | * If we have been passed a specific stack, use that one otherwise |
| 823 | * if we have been passed a task structure, use that, otherwise |
| 824 | * use the stack of where the variable "stack" exists |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 825 | */ |
| 826 | |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 827 | if (stack == NULL) { |
| 828 | if (task) { |
| 829 | /* We know this is a kernel stack, so this is the start/end */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 830 | stack = (unsigned long *)task->thread.ksp; |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 831 | endstack = (unsigned int *)(((unsigned int)(stack) & ~(THREAD_SIZE - 1)) + THREAD_SIZE); |
| 832 | } else { |
| 833 | /* print out the existing stack info */ |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 834 | stack = (unsigned long *)&stack; |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 835 | endstack = (unsigned int *)PAGE_ALIGN((unsigned int)stack); |
| 836 | } |
| 837 | } else |
| 838 | endstack = (unsigned int *)PAGE_ALIGN((unsigned int)stack); |
| 839 | |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 840 | printk(KERN_NOTICE "Stack info:\n"); |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 841 | decode_address(buf, (unsigned int)stack); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 842 | printk(KERN_NOTICE " SP: [0x%p] %s\n", stack, buf); |
| 843 | |
Robin Getz | a0cab65 | 2009-05-11 18:34:41 +0000 | [diff] [blame] | 844 | if (!access_ok(VERIFY_READ, stack, (unsigned int)endstack - (unsigned int)stack)) { |
| 845 | printk(KERN_NOTICE "Invalid stack pointer\n"); |
| 846 | return; |
| 847 | } |
| 848 | |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 849 | /* First thing is to look for a frame pointer */ |
Jie Zhang | 881eb62 | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 850 | for (addr = (unsigned int *)((unsigned int)stack & ~0xF); addr < endstack; addr++) { |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 851 | if (*addr & 0x1) |
| 852 | continue; |
| 853 | ins_addr = (unsigned short *)*addr; |
| 854 | ins_addr--; |
| 855 | if (is_bfin_call(ins_addr)) |
| 856 | fp = addr - 1; |
| 857 | |
| 858 | if (fp) { |
| 859 | /* Let's check to see if it is a frame pointer */ |
Jie Zhang | 881eb62 | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 860 | while (fp >= (addr - 1) && fp < endstack |
| 861 | && fp && ((unsigned int) fp & 0x3) == 0) |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 862 | fp = (unsigned int *)*fp; |
| 863 | if (fp == 0 || fp == endstack) { |
| 864 | fp = addr - 1; |
| 865 | break; |
| 866 | } |
| 867 | fp = 0; |
| 868 | } |
| 869 | } |
| 870 | if (fp) { |
| 871 | frame = fp; |
Jie Zhang | b339dc7 | 2009-01-07 23:14:39 +0800 | [diff] [blame] | 872 | printk(KERN_NOTICE " FP: (0x%p)\n", fp); |
Robin Getz | f09630b | 2008-07-26 19:45:46 +0800 | [diff] [blame] | 873 | } else |
| 874 | frame = 0; |
| 875 | |
| 876 | /* |
| 877 | * Now that we think we know where things are, we |
| 878 | * walk the stack again, this time printing things out |
| 879 | * incase there is no frame pointer, we still look for |
| 880 | * valid return addresses |
| 881 | */ |
| 882 | |
| 883 | /* First time print out data, next time, print out symbols */ |
| 884 | for (j = 0; j <= 1; j++) { |
| 885 | if (j) |
| 886 | printk(KERN_NOTICE "Return addresses in stack:\n"); |
| 887 | else |
| 888 | printk(KERN_NOTICE " Memory from 0x%08lx to %p", ((long unsigned int)stack & ~0xF), endstack); |
| 889 | |
| 890 | fp = frame; |
| 891 | frame_no = 0; |
| 892 | |
| 893 | for (addr = (unsigned int *)((unsigned int)stack & ~0xF), i = 0; |
| 894 | addr <= endstack; addr++, i++) { |
| 895 | |
| 896 | ret_addr = 0; |
| 897 | if (!j && i % 8 == 0) |
| 898 | printk("\n" KERN_NOTICE "%p:",addr); |
| 899 | |
| 900 | /* if it is an odd address, or zero, just skip it */ |
| 901 | if (*addr & 0x1 || !*addr) |
| 902 | goto print; |
| 903 | |
| 904 | ins_addr = (unsigned short *)*addr; |
| 905 | |
| 906 | /* Go back one instruction, and see if it is a CALL */ |
| 907 | ins_addr--; |
| 908 | ret_addr = is_bfin_call(ins_addr); |
| 909 | print: |
| 910 | if (!j && stack == (unsigned long *)addr) |
| 911 | printk("[%08x]", *addr); |
| 912 | else if (ret_addr) |
| 913 | if (j) { |
| 914 | decode_address(buf, (unsigned int)*addr); |
| 915 | if (frame == addr) { |
| 916 | printk(KERN_NOTICE " frame %2i : %s\n", frame_no, buf); |
| 917 | continue; |
| 918 | } |
| 919 | printk(KERN_NOTICE " address : %s\n", buf); |
| 920 | } else |
| 921 | printk("<%08x>", *addr); |
| 922 | else if (fp == addr) { |
| 923 | if (j) |
| 924 | frame = addr+1; |
| 925 | else |
| 926 | printk("(%08x)", *addr); |
| 927 | |
| 928 | fp = (unsigned int *)*addr; |
| 929 | frame_no++; |
| 930 | |
| 931 | } else if (!j) |
| 932 | printk(" %08x ", *addr); |
| 933 | } |
| 934 | if (!j) |
| 935 | printk("\n"); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 936 | } |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 937 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 938 | } |
| 939 | |
| 940 | void dump_stack(void) |
| 941 | { |
| 942 | unsigned long stack; |
Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 943 | #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 944 | int tflags; |
Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 945 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 946 | trace_buffer_save(tflags); |
| 947 | dump_bfin_trace_buffer(); |
| 948 | show_stack(current, &stack); |
| 949 | trace_buffer_restore(tflags); |
| 950 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 951 | EXPORT_SYMBOL(dump_stack); |
| 952 | |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 953 | void dump_bfin_process(struct pt_regs *fp) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 954 | { |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 955 | #ifdef CONFIG_DEBUG_VERBOSE |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 956 | /* We should be able to look at fp->ipend, but we don't push it on the |
| 957 | * stack all the time, so do this until we fix that */ |
| 958 | unsigned int context = bfin_read_IPEND(); |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 959 | |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 960 | if (oops_in_progress) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 961 | verbose_printk(KERN_EMERG "Kernel OOPS in progress\n"); |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 962 | |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 963 | if (context & 0x0020 && (fp->seqstat & SEQSTAT_EXCAUSE) == VEC_HWERR) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 964 | verbose_printk(KERN_NOTICE "HW Error context\n"); |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 965 | else if (context & 0x0020) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 966 | verbose_printk(KERN_NOTICE "Deferred Exception context\n"); |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 967 | else if (context & 0x3FC0) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 968 | verbose_printk(KERN_NOTICE "Interrupt context\n"); |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 969 | else if (context & 0x4000) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 970 | verbose_printk(KERN_NOTICE "Deferred Interrupt context\n"); |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 971 | else if (context & 0x8000) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 972 | verbose_printk(KERN_NOTICE "Kernel process context\n"); |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 973 | |
Robin Getz | 9a62ca4 | 2008-03-26 09:15:58 +0800 | [diff] [blame] | 974 | /* Because we are crashing, and pointers could be bad, we check things |
| 975 | * pretty closely before we use them |
| 976 | */ |
Robin Getz | 7f1c906 | 2008-04-25 03:36:31 +0800 | [diff] [blame] | 977 | if ((unsigned long)current >= FIXED_CODE_START && |
| 978 | !((unsigned long)current & 0x3) && current->pid) { |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 979 | verbose_printk(KERN_NOTICE "CURRENT PROCESS:\n"); |
Robin Getz | 9a62ca4 | 2008-03-26 09:15:58 +0800 | [diff] [blame] | 980 | if (current->comm >= (char *)FIXED_CODE_START) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 981 | verbose_printk(KERN_NOTICE "COMM=%s PID=%d\n", |
Robin Getz | 9a62ca4 | 2008-03-26 09:15:58 +0800 | [diff] [blame] | 982 | current->comm, current->pid); |
| 983 | else |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 984 | verbose_printk(KERN_NOTICE "COMM= invalid\n"); |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 985 | |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 986 | printk(KERN_NOTICE "CPU = %d\n", current_thread_info()->cpu); |
Robin Getz | 9a62ca4 | 2008-03-26 09:15:58 +0800 | [diff] [blame] | 987 | if (!((unsigned long)current->mm & 0x3) && (unsigned long)current->mm >= FIXED_CODE_START) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 988 | verbose_printk(KERN_NOTICE "TEXT = 0x%p-0x%p DATA = 0x%p-0x%p\n" |
Robin Getz | 9a62ca4 | 2008-03-26 09:15:58 +0800 | [diff] [blame] | 989 | KERN_NOTICE " BSS = 0x%p-0x%p USER-STACK = 0x%p\n" |
| 990 | KERN_NOTICE "\n", |
| 991 | (void *)current->mm->start_code, |
| 992 | (void *)current->mm->end_code, |
| 993 | (void *)current->mm->start_data, |
| 994 | (void *)current->mm->end_data, |
| 995 | (void *)current->mm->end_data, |
| 996 | (void *)current->mm->brk, |
| 997 | (void *)current->mm->start_stack); |
| 998 | else |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 999 | verbose_printk(KERN_NOTICE "invalid mm\n"); |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 1000 | } else |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1001 | verbose_printk(KERN_NOTICE "\n" KERN_NOTICE |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 1002 | "No Valid process in current context\n"); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1003 | #endif |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 1004 | } |
| 1005 | |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 1006 | void dump_bfin_mem(struct pt_regs *fp) |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 1007 | { |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1008 | #ifdef CONFIG_DEBUG_VERBOSE |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 1009 | unsigned short *addr, *erraddr, val = 0, err = 0; |
| 1010 | char sti = 0, buf[6]; |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1011 | |
Bernd Schmidt | 5d750b9 | 2008-04-25 05:02:33 +0800 | [diff] [blame] | 1012 | erraddr = (void *)fp->pc; |
Robin Getz | c5d88d9 | 2007-06-21 11:34:16 +0800 | [diff] [blame] | 1013 | |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1014 | verbose_printk(KERN_NOTICE "return address: [0x%p]; contents of:", erraddr); |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 1015 | |
| 1016 | for (addr = (unsigned short *)((unsigned long)erraddr & ~0xF) - 0x10; |
| 1017 | addr < (unsigned short *)((unsigned long)erraddr & ~0xF) + 0x10; |
| 1018 | addr++) { |
| 1019 | if (!((unsigned long)addr & 0xF)) |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1020 | verbose_printk("\n" KERN_NOTICE "0x%p: ", addr); |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 1021 | |
Robin Getz | 7d98c88 | 2008-10-08 16:29:01 +0800 | [diff] [blame] | 1022 | if (!get_instruction(&val, addr)) { |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 1023 | val = 0; |
| 1024 | sprintf(buf, "????"); |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 1025 | } else |
| 1026 | sprintf(buf, "%04x", val); |
| 1027 | |
| 1028 | if (addr == erraddr) { |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1029 | verbose_printk("[%s]", buf); |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 1030 | err = val; |
| 1031 | } else |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1032 | verbose_printk(" %s ", buf); |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 1033 | |
| 1034 | /* Do any previous instructions turn on interrupts? */ |
| 1035 | if (addr <= erraddr && /* in the past */ |
| 1036 | ((val >= 0x0040 && val <= 0x0047) || /* STI instruction */ |
| 1037 | val == 0x017b)) /* [SP++] = RETI */ |
| 1038 | sti = 1; |
| 1039 | } |
| 1040 | |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1041 | verbose_printk("\n"); |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 1042 | |
| 1043 | /* Hardware error interrupts can be deferred */ |
| 1044 | if (unlikely(sti && (fp->seqstat & SEQSTAT_EXCAUSE) == VEC_HWERR && |
| 1045 | oops_in_progress)){ |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1046 | verbose_printk(KERN_NOTICE "Looks like this was a deferred error - sorry\n"); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1047 | #ifndef CONFIG_DEBUG_HWERR |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1048 | verbose_printk(KERN_NOTICE "The remaining message may be meaningless\n" |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 1049 | KERN_NOTICE "You should enable CONFIG_DEBUG_HWERR to get a" |
| 1050 | " better idea where it came from\n"); |
| 1051 | #else |
| 1052 | /* If we are handling only one peripheral interrupt |
| 1053 | * and current mm and pid are valid, and the last error |
| 1054 | * was in that user space process's text area |
| 1055 | * print it out - because that is where the problem exists |
| 1056 | */ |
| 1057 | if ((!(((fp)->ipend & ~0x30) & (((fp)->ipend & ~0x30) - 1))) && |
| 1058 | (current->pid && current->mm)) { |
| 1059 | /* And the last RETI points to the current userspace context */ |
| 1060 | if ((fp + 1)->pc >= current->mm->start_code && |
| 1061 | (fp + 1)->pc <= current->mm->end_code) { |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1062 | verbose_printk(KERN_NOTICE "It might be better to look around here : \n"); |
| 1063 | verbose_printk(KERN_NOTICE "-------------------------------------------\n"); |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 1064 | show_regs(fp + 1); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1065 | verbose_printk(KERN_NOTICE "-------------------------------------------\n"); |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 1066 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1067 | } |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 1068 | #endif |
| 1069 | } |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1070 | #endif |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 1071 | } |
| 1072 | |
| 1073 | void show_regs(struct pt_regs *fp) |
| 1074 | { |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1075 | #ifdef CONFIG_DEBUG_VERBOSE |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 1076 | char buf [150]; |
Robin Getz | d8f66c8 | 2007-12-24 15:27:56 +0800 | [diff] [blame] | 1077 | struct irqaction *action; |
| 1078 | unsigned int i; |
Robin Getz | 2f95d5b | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 1079 | unsigned long flags = 0; |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1080 | unsigned int cpu = smp_processor_id(); |
Robin Getz | 2f95d5b | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 1081 | unsigned char in_atomic = (bfin_read_IPEND() & 0x10) || in_atomic(); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1082 | |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1083 | verbose_printk(KERN_NOTICE "\n" KERN_NOTICE "SEQUENCER STATUS:\t\t%s\n", print_tainted()); |
| 1084 | verbose_printk(KERN_NOTICE " SEQSTAT: %08lx IPEND: %04lx SYSCFG: %04lx\n", |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1085 | (long)fp->seqstat, fp->ipend, fp->syscfg); |
Robin Getz | 1d5ff7e | 2008-10-09 17:06:32 +0800 | [diff] [blame] | 1086 | if ((fp->seqstat & SEQSTAT_EXCAUSE) == VEC_HWERR) { |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1087 | verbose_printk(KERN_NOTICE " HWERRCAUSE: 0x%lx\n", |
Robin Getz | 1d5ff7e | 2008-10-09 17:06:32 +0800 | [diff] [blame] | 1088 | (fp->seqstat & SEQSTAT_HWERRCAUSE) >> 14); |
| 1089 | #ifdef EBIU_ERRMST |
| 1090 | /* If the error was from the EBIU, print it out */ |
| 1091 | if (bfin_read_EBIU_ERRMST() & CORE_ERROR) { |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1092 | verbose_printk(KERN_NOTICE " EBIU Error Reason : 0x%04x\n", |
Robin Getz | 1d5ff7e | 2008-10-09 17:06:32 +0800 | [diff] [blame] | 1093 | bfin_read_EBIU_ERRMST()); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1094 | verbose_printk(KERN_NOTICE " EBIU Error Address : 0x%08x\n", |
Robin Getz | 1d5ff7e | 2008-10-09 17:06:32 +0800 | [diff] [blame] | 1095 | bfin_read_EBIU_ERRADD()); |
| 1096 | } |
| 1097 | #endif |
| 1098 | } |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1099 | verbose_printk(KERN_NOTICE " EXCAUSE : 0x%lx\n", |
Robin Getz | 13fe24f | 2008-01-27 15:38:56 +0800 | [diff] [blame] | 1100 | fp->seqstat & SEQSTAT_EXCAUSE); |
Robin Getz | 2f95d5b | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 1101 | for (i = 2; i <= 15 ; i++) { |
Robin Getz | d8f66c8 | 2007-12-24 15:27:56 +0800 | [diff] [blame] | 1102 | if (fp->ipend & (1 << i)) { |
Robin Getz | 2f95d5b | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 1103 | if (i != 4) { |
| 1104 | decode_address(buf, bfin_read32(EVT0 + 4*i)); |
| 1105 | verbose_printk(KERN_NOTICE " physical IVG%i asserted : %s\n", i, buf); |
| 1106 | } else |
| 1107 | verbose_printk(KERN_NOTICE " interrupts disabled\n"); |
Robin Getz | d8f66c8 | 2007-12-24 15:27:56 +0800 | [diff] [blame] | 1108 | } |
| 1109 | } |
| 1110 | |
| 1111 | /* if no interrupts are going off, don't print this out */ |
| 1112 | if (fp->ipend & ~0x3F) { |
| 1113 | for (i = 0; i < (NR_IRQS - 1); i++) { |
Robin Getz | 2f95d5b | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 1114 | if (!in_atomic) |
| 1115 | spin_lock_irqsave(&irq_desc[i].lock, flags); |
| 1116 | |
Robin Getz | d8f66c8 | 2007-12-24 15:27:56 +0800 | [diff] [blame] | 1117 | action = irq_desc[i].action; |
| 1118 | if (!action) |
| 1119 | goto unlock; |
| 1120 | |
| 1121 | decode_address(buf, (unsigned int)action->handler); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1122 | verbose_printk(KERN_NOTICE " logical irq %3d mapped : %s", i, buf); |
Robin Getz | d8f66c8 | 2007-12-24 15:27:56 +0800 | [diff] [blame] | 1123 | for (action = action->next; action; action = action->next) { |
| 1124 | decode_address(buf, (unsigned int)action->handler); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1125 | verbose_printk(", %s", buf); |
Robin Getz | d8f66c8 | 2007-12-24 15:27:56 +0800 | [diff] [blame] | 1126 | } |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1127 | verbose_printk("\n"); |
Robin Getz | d8f66c8 | 2007-12-24 15:27:56 +0800 | [diff] [blame] | 1128 | unlock: |
Robin Getz | 2f95d5b | 2009-02-04 16:49:45 +0800 | [diff] [blame] | 1129 | if (!in_atomic) |
| 1130 | spin_unlock_irqrestore(&irq_desc[i].lock, flags); |
Robin Getz | d8f66c8 | 2007-12-24 15:27:56 +0800 | [diff] [blame] | 1131 | } |
| 1132 | } |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1133 | |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1134 | decode_address(buf, fp->rete); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1135 | verbose_printk(KERN_NOTICE " RETE: %s\n", buf); |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1136 | decode_address(buf, fp->retn); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1137 | verbose_printk(KERN_NOTICE " RETN: %s\n", buf); |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1138 | decode_address(buf, fp->retx); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1139 | verbose_printk(KERN_NOTICE " RETX: %s\n", buf); |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1140 | decode_address(buf, fp->rets); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1141 | verbose_printk(KERN_NOTICE " RETS: %s\n", buf); |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 1142 | decode_address(buf, fp->pc); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1143 | verbose_printk(KERN_NOTICE " PC : %s\n", buf); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1144 | |
Robin Getz | 13fe24f | 2008-01-27 15:38:56 +0800 | [diff] [blame] | 1145 | if (((long)fp->seqstat & SEQSTAT_EXCAUSE) && |
| 1146 | (((long)fp->seqstat & SEQSTAT_EXCAUSE) != VEC_HWERR)) { |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1147 | decode_address(buf, cpu_pda[cpu].dcplb_fault_addr); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1148 | verbose_printk(KERN_NOTICE "DCPLB_FAULT_ADDR: %s\n", buf); |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1149 | decode_address(buf, cpu_pda[cpu].icplb_fault_addr); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1150 | verbose_printk(KERN_NOTICE "ICPLB_FAULT_ADDR: %s\n", buf); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1151 | } |
| 1152 | |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1153 | verbose_printk(KERN_NOTICE "\n" KERN_NOTICE "PROCESSOR STATE:\n"); |
| 1154 | verbose_printk(KERN_NOTICE " R0 : %08lx R1 : %08lx R2 : %08lx R3 : %08lx\n", |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1155 | fp->r0, fp->r1, fp->r2, fp->r3); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1156 | verbose_printk(KERN_NOTICE " R4 : %08lx R5 : %08lx R6 : %08lx R7 : %08lx\n", |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1157 | fp->r4, fp->r5, fp->r6, fp->r7); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1158 | verbose_printk(KERN_NOTICE " P0 : %08lx P1 : %08lx P2 : %08lx P3 : %08lx\n", |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1159 | fp->p0, fp->p1, fp->p2, fp->p3); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1160 | verbose_printk(KERN_NOTICE " P4 : %08lx P5 : %08lx FP : %08lx SP : %08lx\n", |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1161 | fp->p4, fp->p5, fp->fp, (long)fp); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1162 | verbose_printk(KERN_NOTICE " LB0: %08lx LT0: %08lx LC0: %08lx\n", |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1163 | fp->lb0, fp->lt0, fp->lc0); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1164 | verbose_printk(KERN_NOTICE " LB1: %08lx LT1: %08lx LC1: %08lx\n", |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1165 | fp->lb1, fp->lt1, fp->lc1); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1166 | verbose_printk(KERN_NOTICE " B0 : %08lx L0 : %08lx M0 : %08lx I0 : %08lx\n", |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1167 | fp->b0, fp->l0, fp->m0, fp->i0); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1168 | verbose_printk(KERN_NOTICE " B1 : %08lx L1 : %08lx M1 : %08lx I1 : %08lx\n", |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1169 | fp->b1, fp->l1, fp->m1, fp->i1); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1170 | verbose_printk(KERN_NOTICE " B2 : %08lx L2 : %08lx M2 : %08lx I2 : %08lx\n", |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1171 | fp->b2, fp->l2, fp->m2, fp->i2); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1172 | verbose_printk(KERN_NOTICE " B3 : %08lx L3 : %08lx M3 : %08lx I3 : %08lx\n", |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1173 | fp->b3, fp->l3, fp->m3, fp->i3); |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1174 | verbose_printk(KERN_NOTICE "A0.w: %08lx A0.x: %08lx A1.w: %08lx A1.x: %08lx\n", |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1175 | fp->a0w, fp->a0x, fp->a1w, fp->a1x); |
| 1176 | |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1177 | verbose_printk(KERN_NOTICE "USP : %08lx ASTAT: %08lx\n", |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1178 | rdusp(), fp->astat); |
| 1179 | |
Robin Getz | 9f06c38 | 2008-10-10 18:13:21 +0800 | [diff] [blame] | 1180 | verbose_printk(KERN_NOTICE "\n"); |
| 1181 | #endif |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1182 | } |
| 1183 | |
| 1184 | #ifdef CONFIG_SYS_BFIN_SPINLOCK_L1 |
| 1185 | asmlinkage int sys_bfin_spinlock(int *spinlock)__attribute__((l1_text)); |
| 1186 | #endif |
| 1187 | |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1188 | static DEFINE_SPINLOCK(bfin_spinlock_lock); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1189 | |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1190 | asmlinkage int sys_bfin_spinlock(int *p) |
| 1191 | { |
| 1192 | int ret, tmp = 0; |
| 1193 | |
| 1194 | spin_lock(&bfin_spinlock_lock); /* This would also hold kernel preemption. */ |
| 1195 | ret = get_user(tmp, p); |
| 1196 | if (likely(ret == 0)) { |
| 1197 | if (unlikely(tmp)) |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1198 | ret = 1; |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1199 | else |
| 1200 | put_user(1, p); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1201 | } |
Graf Yang | 8f65873 | 2008-11-18 17:48:22 +0800 | [diff] [blame] | 1202 | spin_unlock(&bfin_spinlock_lock); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1203 | return ret; |
| 1204 | } |
| 1205 | |
Mike Frysinger | 1ffe664 | 2007-08-05 17:14:04 +0800 | [diff] [blame] | 1206 | int bfin_request_exception(unsigned int exception, void (*handler)(void)) |
| 1207 | { |
| 1208 | void (*curr_handler)(void); |
| 1209 | |
| 1210 | if (exception > 0x3F) |
| 1211 | return -EINVAL; |
| 1212 | |
| 1213 | curr_handler = ex_table[exception]; |
| 1214 | |
| 1215 | if (curr_handler != ex_replaceable) |
| 1216 | return -EBUSY; |
| 1217 | |
| 1218 | ex_table[exception] = handler; |
| 1219 | |
| 1220 | return 0; |
| 1221 | } |
| 1222 | EXPORT_SYMBOL(bfin_request_exception); |
| 1223 | |
| 1224 | int bfin_free_exception(unsigned int exception, void (*handler)(void)) |
| 1225 | { |
| 1226 | void (*curr_handler)(void); |
| 1227 | |
| 1228 | if (exception > 0x3F) |
| 1229 | return -EINVAL; |
| 1230 | |
| 1231 | curr_handler = ex_table[exception]; |
| 1232 | |
| 1233 | if (curr_handler != handler) |
| 1234 | return -EBUSY; |
| 1235 | |
| 1236 | ex_table[exception] = ex_replaceable; |
| 1237 | |
| 1238 | return 0; |
| 1239 | } |
| 1240 | EXPORT_SYMBOL(bfin_free_exception); |
| 1241 | |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1242 | void panic_cplb_error(int cplb_panic, struct pt_regs *fp) |
| 1243 | { |
| 1244 | switch (cplb_panic) { |
| 1245 | case CPLB_NO_UNLOCKED: |
| 1246 | printk(KERN_EMERG "All CPLBs are locked\n"); |
| 1247 | break; |
| 1248 | case CPLB_PROT_VIOL: |
| 1249 | return; |
| 1250 | case CPLB_NO_ADDR_MATCH: |
| 1251 | return; |
| 1252 | case CPLB_UNKNOWN_ERR: |
| 1253 | printk(KERN_EMERG "Unknown CPLB Exception\n"); |
| 1254 | break; |
| 1255 | } |
| 1256 | |
Robin Getz | 226eb1e | 2007-10-29 17:59:07 +0800 | [diff] [blame] | 1257 | oops_in_progress = 1; |
| 1258 | |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 1259 | dump_bfin_process(fp); |
Robin Getz | b03b08b | 2007-12-23 22:57:01 +0800 | [diff] [blame] | 1260 | dump_bfin_mem(fp); |
Mike Frysinger | 49dce91 | 2007-11-21 16:46:49 +0800 | [diff] [blame] | 1261 | show_regs(fp); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1262 | dump_stack(); |
Mike Frysinger | d8804ad | 2009-04-29 06:26:46 +0000 | [diff] [blame] | 1263 | panic("Unrecoverable event"); |
Bryan Wu | 1394f03 | 2007-05-06 14:50:22 -0700 | [diff] [blame] | 1264 | } |