traps.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. /* $Id: traps.c,v 1.17 2004/05/02 01:46:30 sugioka Exp $
  2. *
  3. * linux/arch/sh/traps.c
  4. *
  5. * SuperH version: Copyright (C) 1999 Niibe Yutaka
  6. * Copyright (C) 2000 Philipp Rumpf
  7. * Copyright (C) 2000 David Howells
  8. * Copyright (C) 2002, 2003 Paul Mundt
  9. */
  10. /*
  11. * 'Traps.c' handles hardware traps and faults after we have saved some
  12. * state in 'entry.S'.
  13. */
  14. #include <linux/sched.h>
  15. #include <linux/kernel.h>
  16. #include <linux/string.h>
  17. #include <linux/errno.h>
  18. #include <linux/ptrace.h>
  19. #include <linux/timer.h>
  20. #include <linux/mm.h>
  21. #include <linux/smp.h>
  22. #include <linux/smp_lock.h>
  23. #include <linux/init.h>
  24. #include <linux/delay.h>
  25. #include <linux/spinlock.h>
  26. #include <linux/module.h>
  27. #include <linux/kallsyms.h>
  28. #include <asm/system.h>
  29. #include <asm/uaccess.h>
  30. #include <asm/io.h>
  31. #include <asm/atomic.h>
  32. #include <asm/processor.h>
  33. #include <asm/sections.h>
  34. #ifdef CONFIG_SH_KGDB
  35. #include <asm/kgdb.h>
  36. #define CHK_REMOTE_DEBUG(regs) \
  37. { \
  38. if ((kgdb_debug_hook != (kgdb_debug_hook_t *) NULL) && (!user_mode(regs))) \
  39. { \
  40. (*kgdb_debug_hook)(regs); \
  41. } \
  42. }
  43. #else
  44. #define CHK_REMOTE_DEBUG(regs)
  45. #endif
  46. #define DO_ERROR(trapnr, signr, str, name, tsk) \
  47. asmlinkage void do_##name(unsigned long r4, unsigned long r5, \
  48. unsigned long r6, unsigned long r7, \
  49. struct pt_regs regs) \
  50. { \
  51. unsigned long error_code; \
  52. \
  53. /* Check if it's a DSP instruction */ \
  54. if (is_dsp_inst(&regs)) { \
  55. /* Enable DSP mode, and restart instruction. */ \
  56. regs.sr |= SR_DSP; \
  57. return; \
  58. } \
  59. \
  60. asm volatile("stc r2_bank, %0": "=r" (error_code)); \
  61. local_irq_enable(); \
  62. tsk->thread.error_code = error_code; \
  63. tsk->thread.trap_no = trapnr; \
  64. CHK_REMOTE_DEBUG(&regs); \
  65. force_sig(signr, tsk); \
  66. die_if_no_fixup(str,&regs,error_code); \
  67. }
  68. #ifdef CONFIG_CPU_SH2
  69. #define TRAP_RESERVED_INST 4
  70. #define TRAP_ILLEGAL_SLOT_INST 6
  71. #else
  72. #define TRAP_RESERVED_INST 12
  73. #define TRAP_ILLEGAL_SLOT_INST 13
  74. #endif
  75. /*
  76. * These constants are for searching for possible module text
  77. * segments. VMALLOC_OFFSET comes from mm/vmalloc.c; MODULE_RANGE is
  78. * a guess of how much space is likely to be vmalloced.
  79. */
  80. #define VMALLOC_OFFSET (8*1024*1024)
  81. #define MODULE_RANGE (8*1024*1024)
  82. spinlock_t die_lock;
  83. void die(const char * str, struct pt_regs * regs, long err)
  84. {
  85. static int die_counter;
  86. console_verbose();
  87. spin_lock_irq(&die_lock);
  88. printk("%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
  89. CHK_REMOTE_DEBUG(regs);
  90. show_regs(regs);
  91. spin_unlock_irq(&die_lock);
  92. do_exit(SIGSEGV);
  93. }
  94. static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err)
  95. {
  96. if (!user_mode(regs))
  97. die(str, regs, err);
  98. }
  99. static int handle_unaligned_notify_count = 10;
  100. /*
  101. * try and fix up kernelspace address errors
  102. * - userspace errors just cause EFAULT to be returned, resulting in SEGV
  103. * - kernel/userspace interfaces cause a jump to an appropriate handler
  104. * - other kernel errors are bad
  105. * - return 0 if fixed-up, -EFAULT if non-fatal (to the kernel) fault
  106. */
  107. static int die_if_no_fixup(const char * str, struct pt_regs * regs, long err)
  108. {
  109. if (!user_mode(regs))
  110. {
  111. const struct exception_table_entry *fixup;
  112. fixup = search_exception_tables(regs->pc);
  113. if (fixup) {
  114. regs->pc = fixup->fixup;
  115. return 0;
  116. }
  117. die(str, regs, err);
  118. }
  119. return -EFAULT;
  120. }
  121. /*
  122. * handle an instruction that does an unaligned memory access by emulating the
  123. * desired behaviour
  124. * - note that PC _may not_ point to the faulting instruction
  125. * (if that instruction is in a branch delay slot)
  126. * - return 0 if emulation okay, -EFAULT on existential error
  127. */
  128. static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
  129. {
  130. int ret, index, count;
  131. unsigned long *rm, *rn;
  132. unsigned char *src, *dst;
  133. index = (instruction>>8)&15; /* 0x0F00 */
  134. rn = &regs->regs[index];
  135. index = (instruction>>4)&15; /* 0x00F0 */
  136. rm = &regs->regs[index];
  137. count = 1<<(instruction&3);
  138. ret = -EFAULT;
  139. switch (instruction>>12) {
  140. case 0: /* mov.[bwl] to/from memory via r0+rn */
  141. if (instruction & 8) {
  142. /* from memory */
  143. src = (unsigned char*) *rm;
  144. src += regs->regs[0];
  145. dst = (unsigned char*) rn;
  146. *(unsigned long*)dst = 0;
  147. #ifdef __LITTLE_ENDIAN__
  148. if (copy_from_user(dst, src, count))
  149. goto fetch_fault;
  150. if ((count == 2) && dst[1] & 0x80) {
  151. dst[2] = 0xff;
  152. dst[3] = 0xff;
  153. }
  154. #else
  155. dst += 4-count;
  156. if (__copy_user(dst, src, count))
  157. goto fetch_fault;
  158. if ((count == 2) && dst[2] & 0x80) {
  159. dst[0] = 0xff;
  160. dst[1] = 0xff;
  161. }
  162. #endif
  163. } else {
  164. /* to memory */
  165. src = (unsigned char*) rm;
  166. #if !defined(__LITTLE_ENDIAN__)
  167. src += 4-count;
  168. #endif
  169. dst = (unsigned char*) *rn;
  170. dst += regs->regs[0];
  171. if (copy_to_user(dst, src, count))
  172. goto fetch_fault;
  173. }
  174. ret = 0;
  175. break;
  176. case 1: /* mov.l Rm,@(disp,Rn) */
  177. src = (unsigned char*) rm;
  178. dst = (unsigned char*) *rn;
  179. dst += (instruction&0x000F)<<2;
  180. if (copy_to_user(dst,src,4))
  181. goto fetch_fault;
  182. ret = 0;
  183. break;
  184. case 2: /* mov.[bwl] to memory, possibly with pre-decrement */
  185. if (instruction & 4)
  186. *rn -= count;
  187. src = (unsigned char*) rm;
  188. dst = (unsigned char*) *rn;
  189. #if !defined(__LITTLE_ENDIAN__)
  190. src += 4-count;
  191. #endif
  192. if (copy_to_user(dst, src, count))
  193. goto fetch_fault;
  194. ret = 0;
  195. break;
  196. case 5: /* mov.l @(disp,Rm),Rn */
  197. src = (unsigned char*) *rm;
  198. src += (instruction&0x000F)<<2;
  199. dst = (unsigned char*) rn;
  200. *(unsigned long*)dst = 0;
  201. if (copy_from_user(dst,src,4))
  202. goto fetch_fault;
  203. ret = 0;
  204. break;
  205. case 6: /* mov.[bwl] from memory, possibly with post-increment */
  206. src = (unsigned char*) *rm;
  207. if (instruction & 4)
  208. *rm += count;
  209. dst = (unsigned char*) rn;
  210. *(unsigned long*)dst = 0;
  211. #ifdef __LITTLE_ENDIAN__
  212. if (copy_from_user(dst, src, count))
  213. goto fetch_fault;
  214. if ((count == 2) && dst[1] & 0x80) {
  215. dst[2] = 0xff;
  216. dst[3] = 0xff;
  217. }
  218. #else
  219. dst += 4-count;
  220. if (copy_from_user(dst, src, count))
  221. goto fetch_fault;
  222. if ((count == 2) && dst[2] & 0x80) {
  223. dst[0] = 0xff;
  224. dst[1] = 0xff;
  225. }
  226. #endif
  227. ret = 0;
  228. break;
  229. case 8:
  230. switch ((instruction&0xFF00)>>8) {
  231. case 0x81: /* mov.w R0,@(disp,Rn) */
  232. src = (unsigned char*) &regs->regs[0];
  233. #if !defined(__LITTLE_ENDIAN__)
  234. src += 2;
  235. #endif
  236. dst = (unsigned char*) *rm; /* called Rn in the spec */
  237. dst += (instruction&0x000F)<<1;
  238. if (copy_to_user(dst, src, 2))
  239. goto fetch_fault;
  240. ret = 0;
  241. break;
  242. case 0x85: /* mov.w @(disp,Rm),R0 */
  243. src = (unsigned char*) *rm;
  244. src += (instruction&0x000F)<<1;
  245. dst = (unsigned char*) &regs->regs[0];
  246. *(unsigned long*)dst = 0;
  247. #if !defined(__LITTLE_ENDIAN__)
  248. dst += 2;
  249. #endif
  250. if (copy_from_user(dst, src, 2))
  251. goto fetch_fault;
  252. #ifdef __LITTLE_ENDIAN__
  253. if (dst[1] & 0x80) {
  254. dst[2] = 0xff;
  255. dst[3] = 0xff;
  256. }
  257. #else
  258. if (dst[2] & 0x80) {
  259. dst[0] = 0xff;
  260. dst[1] = 0xff;
  261. }
  262. #endif
  263. ret = 0;
  264. break;
  265. }
  266. break;
  267. }
  268. return ret;
  269. fetch_fault:
  270. /* Argh. Address not only misaligned but also non-existent.
  271. * Raise an EFAULT and see if it's trapped
  272. */
  273. return die_if_no_fixup("Fault in unaligned fixup", regs, 0);
  274. }
  275. /*
  276. * emulate the instruction in the delay slot
  277. * - fetches the instruction from PC+2
  278. */
  279. static inline int handle_unaligned_delayslot(struct pt_regs *regs)
  280. {
  281. u16 instruction;
  282. if (copy_from_user(&instruction, (u16 *)(regs->pc+2), 2)) {
  283. /* the instruction-fetch faulted */
  284. if (user_mode(regs))
  285. return -EFAULT;
  286. /* kernel */
  287. die("delay-slot-insn faulting in handle_unaligned_delayslot", regs, 0);
  288. }
  289. return handle_unaligned_ins(instruction,regs);
  290. }
  291. /*
  292. * handle an instruction that does an unaligned memory access
  293. * - have to be careful of branch delay-slot instructions that fault
  294. * SH3:
  295. * - if the branch would be taken PC points to the branch
  296. * - if the branch would not be taken, PC points to delay-slot
  297. * SH4:
  298. * - PC always points to delayed branch
  299. * - return 0 if handled, -EFAULT if failed (may not return if in kernel)
  300. */
  301. /* Macros to determine offset from current PC for branch instructions */
  302. /* Explicit type coercion is used to force sign extension where needed */
  303. #define SH_PC_8BIT_OFFSET(instr) ((((signed char)(instr))*2) + 4)
  304. #define SH_PC_12BIT_OFFSET(instr) ((((signed short)(instr<<4))>>3) + 4)
  305. static int handle_unaligned_access(u16 instruction, struct pt_regs *regs)
  306. {
  307. u_int rm;
  308. int ret, index;
  309. index = (instruction>>8)&15; /* 0x0F00 */
  310. rm = regs->regs[index];
  311. /* shout about the first ten userspace fixups */
  312. if (user_mode(regs) && handle_unaligned_notify_count>0) {
  313. handle_unaligned_notify_count--;
  314. printk("Fixing up unaligned userspace access in \"%s\" pid=%d pc=0x%p ins=0x%04hx\n",
  315. current->comm,current->pid,(u16*)regs->pc,instruction);
  316. }
  317. ret = -EFAULT;
  318. switch (instruction&0xF000) {
  319. case 0x0000:
  320. if (instruction==0x000B) {
  321. /* rts */
  322. ret = handle_unaligned_delayslot(regs);
  323. if (ret==0)
  324. regs->pc = regs->pr;
  325. }
  326. else if ((instruction&0x00FF)==0x0023) {
  327. /* braf @Rm */
  328. ret = handle_unaligned_delayslot(regs);
  329. if (ret==0)
  330. regs->pc += rm + 4;
  331. }
  332. else if ((instruction&0x00FF)==0x0003) {
  333. /* bsrf @Rm */
  334. ret = handle_unaligned_delayslot(regs);
  335. if (ret==0) {
  336. regs->pr = regs->pc + 4;
  337. regs->pc += rm + 4;
  338. }
  339. }
  340. else {
  341. /* mov.[bwl] to/from memory via r0+rn */
  342. goto simple;
  343. }
  344. break;
  345. case 0x1000: /* mov.l Rm,@(disp,Rn) */
  346. goto simple;
  347. case 0x2000: /* mov.[bwl] to memory, possibly with pre-decrement */
  348. goto simple;
  349. case 0x4000:
  350. if ((instruction&0x00FF)==0x002B) {
  351. /* jmp @Rm */
  352. ret = handle_unaligned_delayslot(regs);
  353. if (ret==0)
  354. regs->pc = rm;
  355. }
  356. else if ((instruction&0x00FF)==0x000B) {
  357. /* jsr @Rm */
  358. ret = handle_unaligned_delayslot(regs);
  359. if (ret==0) {
  360. regs->pr = regs->pc + 4;
  361. regs->pc = rm;
  362. }
  363. }
  364. else {
  365. /* mov.[bwl] to/from memory via r0+rn */
  366. goto simple;
  367. }
  368. break;
  369. case 0x5000: /* mov.l @(disp,Rm),Rn */
  370. goto simple;
  371. case 0x6000: /* mov.[bwl] from memory, possibly with post-increment */
  372. goto simple;
  373. case 0x8000: /* bf lab, bf/s lab, bt lab, bt/s lab */
  374. switch (instruction&0x0F00) {
  375. case 0x0100: /* mov.w R0,@(disp,Rm) */
  376. goto simple;
  377. case 0x0500: /* mov.w @(disp,Rm),R0 */
  378. goto simple;
  379. case 0x0B00: /* bf lab - no delayslot*/
  380. break;
  381. case 0x0F00: /* bf/s lab */
  382. ret = handle_unaligned_delayslot(regs);
  383. if (ret==0) {
  384. #if defined(CONFIG_CPU_SH4) || defined(CONFIG_SH7705_CACHE_32KB)
  385. if ((regs->sr & 0x00000001) != 0)
  386. regs->pc += 4; /* next after slot */
  387. else
  388. #endif
  389. regs->pc += SH_PC_8BIT_OFFSET(instruction);
  390. }
  391. break;
  392. case 0x0900: /* bt lab - no delayslot */
  393. break;
  394. case 0x0D00: /* bt/s lab */
  395. ret = handle_unaligned_delayslot(regs);
  396. if (ret==0) {
  397. #if defined(CONFIG_CPU_SH4) || defined(CONFIG_SH7705_CACHE_32KB)
  398. if ((regs->sr & 0x00000001) == 0)
  399. regs->pc += 4; /* next after slot */
  400. else
  401. #endif
  402. regs->pc += SH_PC_8BIT_OFFSET(instruction);
  403. }
  404. break;
  405. }
  406. break;
  407. case 0xA000: /* bra label */
  408. ret = handle_unaligned_delayslot(regs);
  409. if (ret==0)
  410. regs->pc += SH_PC_12BIT_OFFSET(instruction);
  411. break;
  412. case 0xB000: /* bsr label */
  413. ret = handle_unaligned_delayslot(regs);
  414. if (ret==0) {
  415. regs->pr = regs->pc + 4;
  416. regs->pc += SH_PC_12BIT_OFFSET(instruction);
  417. }
  418. break;
  419. }
  420. return ret;
  421. /* handle non-delay-slot instruction */
  422. simple:
  423. ret = handle_unaligned_ins(instruction,regs);
  424. if (ret==0)
  425. regs->pc += 2;
  426. return ret;
  427. }
  428. /*
  429. * Handle various address error exceptions
  430. */
  431. asmlinkage void do_address_error(struct pt_regs *regs,
  432. unsigned long writeaccess,
  433. unsigned long address)
  434. {
  435. unsigned long error_code;
  436. mm_segment_t oldfs;
  437. u16 instruction;
  438. int tmp;
  439. asm volatile("stc r2_bank,%0": "=r" (error_code));
  440. oldfs = get_fs();
  441. if (user_mode(regs)) {
  442. local_irq_enable();
  443. current->thread.error_code = error_code;
  444. current->thread.trap_no = (writeaccess) ? 8 : 7;
  445. /* bad PC is not something we can fix */
  446. if (regs->pc & 1)
  447. goto uspace_segv;
  448. set_fs(USER_DS);
  449. if (copy_from_user(&instruction, (u16 *)(regs->pc), 2)) {
  450. /* Argh. Fault on the instruction itself.
  451. This should never happen non-SMP
  452. */
  453. set_fs(oldfs);
  454. goto uspace_segv;
  455. }
  456. tmp = handle_unaligned_access(instruction, regs);
  457. set_fs(oldfs);
  458. if (tmp==0)
  459. return; /* sorted */
  460. uspace_segv:
  461. printk(KERN_NOTICE "Killing process \"%s\" due to unaligned access\n", current->comm);
  462. force_sig(SIGSEGV, current);
  463. } else {
  464. if (regs->pc & 1)
  465. die("unaligned program counter", regs, error_code);
  466. set_fs(KERNEL_DS);
  467. if (copy_from_user(&instruction, (u16 *)(regs->pc), 2)) {
  468. /* Argh. Fault on the instruction itself.
  469. This should never happen non-SMP
  470. */
  471. set_fs(oldfs);
  472. die("insn faulting in do_address_error", regs, 0);
  473. }
  474. handle_unaligned_access(instruction, regs);
  475. set_fs(oldfs);
  476. }
  477. }
  478. #ifdef CONFIG_SH_DSP
  479. /*
  480. * SH-DSP support gerg@snapgear.com.
  481. */
  482. int is_dsp_inst(struct pt_regs *regs)
  483. {
  484. unsigned short inst;
  485. /*
  486. * Safe guard if DSP mode is already enabled or we're lacking
  487. * the DSP altogether.
  488. */
  489. if (!(cpu_data->flags & CPU_HAS_DSP) || (regs->sr & SR_DSP))
  490. return 0;
  491. get_user(inst, ((unsigned short *) regs->pc));
  492. inst &= 0xf000;
  493. /* Check for any type of DSP or support instruction */
  494. if ((inst == 0xf000) || (inst == 0x4000))
  495. return 1;
  496. return 0;
  497. }
  498. #else
  499. #define is_dsp_inst(regs) (0)
  500. #endif /* CONFIG_SH_DSP */
  501. DO_ERROR(TRAP_RESERVED_INST, SIGILL, "reserved instruction", reserved_inst, current)
  502. DO_ERROR(TRAP_ILLEGAL_SLOT_INST, SIGILL, "illegal slot instruction", illegal_slot_inst, current)
  503. asmlinkage void do_exception_error(unsigned long r4, unsigned long r5,
  504. unsigned long r6, unsigned long r7,
  505. struct pt_regs regs)
  506. {
  507. long ex;
  508. asm volatile("stc r2_bank, %0" : "=r" (ex));
  509. die_if_kernel("exception", &regs, ex);
  510. }
  511. #if defined(CONFIG_SH_STANDARD_BIOS)
  512. void *gdb_vbr_vector;
  513. static inline void __init gdb_vbr_init(void)
  514. {
  515. register unsigned long vbr;
  516. /*
  517. * Read the old value of the VBR register to initialise
  518. * the vector through which debug and BIOS traps are
  519. * delegated by the Linux trap handler.
  520. */
  521. asm volatile("stc vbr, %0" : "=r" (vbr));
  522. gdb_vbr_vector = (void *)(vbr + 0x100);
  523. printk("Setting GDB trap vector to 0x%08lx\n",
  524. (unsigned long)gdb_vbr_vector);
  525. }
  526. #endif
  527. void __init per_cpu_trap_init(void)
  528. {
  529. extern void *vbr_base;
  530. #ifdef CONFIG_SH_STANDARD_BIOS
  531. gdb_vbr_init();
  532. #endif
  533. /* NOTE: The VBR value should be at P1
  534. (or P2, virtural "fixed" address space).
  535. It's definitely should not in physical address. */
  536. asm volatile("ldc %0, vbr"
  537. : /* no output */
  538. : "r" (&vbr_base)
  539. : "memory");
  540. }
  541. void __init trap_init(void)
  542. {
  543. extern void *exception_handling_table[];
  544. exception_handling_table[TRAP_RESERVED_INST]
  545. = (void *)do_reserved_inst;
  546. exception_handling_table[TRAP_ILLEGAL_SLOT_INST]
  547. = (void *)do_illegal_slot_inst;
  548. #ifdef CONFIG_CPU_SH4
  549. if (!(cpu_data->flags & CPU_HAS_FPU)) {
  550. /* For SH-4 lacking an FPU, treat floating point instructions
  551. as reserved. */
  552. /* entry 64 corresponds to EXPEVT=0x800 */
  553. exception_handling_table[64] = (void *)do_reserved_inst;
  554. exception_handling_table[65] = (void *)do_illegal_slot_inst;
  555. }
  556. #endif
  557. /* Setup VBR for boot cpu */
  558. per_cpu_trap_init();
  559. }
  560. void show_stack(struct task_struct *tsk, unsigned long *sp)
  561. {
  562. unsigned long *stack, addr;
  563. unsigned long module_start = VMALLOC_START;
  564. unsigned long module_end = VMALLOC_END;
  565. int i = 1;
  566. if (tsk && !sp) {
  567. sp = (unsigned long *)tsk->thread.sp;
  568. }
  569. if (!sp) {
  570. __asm__ __volatile__ (
  571. "mov r15, %0\n\t"
  572. "stc r7_bank, %1\n\t"
  573. : "=r" (module_start),
  574. "=r" (module_end)
  575. );
  576. sp = (unsigned long *)module_start;
  577. }
  578. stack = sp;
  579. printk("\nCall trace: ");
  580. #ifdef CONFIG_KALLSYMS
  581. printk("\n");
  582. #endif
  583. while (!kstack_end(stack)) {
  584. addr = *stack++;
  585. if (((addr >= (unsigned long)_text) &&
  586. (addr <= (unsigned long)_etext)) ||
  587. ((addr >= module_start) && (addr <= module_end))) {
  588. /*
  589. * For 80-columns display, 6 entry is maximum.
  590. * NOTE: '[<8c00abcd>] ' consumes 13 columns .
  591. */
  592. #ifndef CONFIG_KALLSYMS
  593. if (i && ((i % 6) == 0))
  594. printk("\n ");
  595. #endif
  596. printk("[<%08lx>] ", addr);
  597. print_symbol("%s\n", addr);
  598. i++;
  599. }
  600. }
  601. printk("\n");
  602. }
  603. void show_task(unsigned long *sp)
  604. {
  605. show_stack(NULL, sp);
  606. }
  607. void dump_stack(void)
  608. {
  609. show_stack(NULL, NULL);
  610. }
  611. EXPORT_SYMBOL(dump_stack);