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