traps.c 35 KB

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