traps.c 17 KB

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