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