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