traps.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242
  1. /*
  2. * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. *
  9. * Modified by Cort Dougan (cort@cs.nmt.edu)
  10. * and Paul Mackerras (paulus@samba.org)
  11. */
  12. /*
  13. * This file handles the architecture-dependent parts of hardware exceptions
  14. */
  15. #include <linux/errno.h>
  16. #include <linux/sched.h>
  17. #include <linux/kernel.h>
  18. #include <linux/mm.h>
  19. #include <linux/stddef.h>
  20. #include <linux/unistd.h>
  21. #include <linux/ptrace.h>
  22. #include <linux/slab.h>
  23. #include <linux/user.h>
  24. #include <linux/a.out.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/init.h>
  27. #include <linux/module.h>
  28. #include <linux/prctl.h>
  29. #include <linux/delay.h>
  30. #include <linux/kprobes.h>
  31. #include <linux/kexec.h>
  32. #include <linux/backlight.h>
  33. #include <linux/bug.h>
  34. #include <linux/kdebug.h>
  35. #include <asm/pgtable.h>
  36. #include <asm/uaccess.h>
  37. #include <asm/system.h>
  38. #include <asm/io.h>
  39. #include <asm/machdep.h>
  40. #include <asm/rtas.h>
  41. #include <asm/pmc.h>
  42. #ifdef CONFIG_PPC32
  43. #include <asm/reg.h>
  44. #endif
  45. #ifdef CONFIG_PMAC_BACKLIGHT
  46. #include <asm/backlight.h>
  47. #endif
  48. #ifdef CONFIG_PPC64
  49. #include <asm/firmware.h>
  50. #include <asm/processor.h>
  51. #endif
  52. #include <asm/kexec.h>
  53. #if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC)
  54. int (*__debugger)(struct pt_regs *regs);
  55. int (*__debugger_ipi)(struct pt_regs *regs);
  56. int (*__debugger_bpt)(struct pt_regs *regs);
  57. int (*__debugger_sstep)(struct pt_regs *regs);
  58. int (*__debugger_iabr_match)(struct pt_regs *regs);
  59. int (*__debugger_dabr_match)(struct pt_regs *regs);
  60. int (*__debugger_fault_handler)(struct pt_regs *regs);
  61. EXPORT_SYMBOL(__debugger);
  62. EXPORT_SYMBOL(__debugger_ipi);
  63. EXPORT_SYMBOL(__debugger_bpt);
  64. EXPORT_SYMBOL(__debugger_sstep);
  65. EXPORT_SYMBOL(__debugger_iabr_match);
  66. EXPORT_SYMBOL(__debugger_dabr_match);
  67. EXPORT_SYMBOL(__debugger_fault_handler);
  68. #endif
  69. /*
  70. * Trap & Exception support
  71. */
  72. #ifdef CONFIG_PMAC_BACKLIGHT
  73. static void pmac_backlight_unblank(void)
  74. {
  75. mutex_lock(&pmac_backlight_mutex);
  76. if (pmac_backlight) {
  77. struct backlight_properties *props;
  78. props = &pmac_backlight->props;
  79. props->brightness = props->max_brightness;
  80. props->power = FB_BLANK_UNBLANK;
  81. backlight_update_status(pmac_backlight);
  82. }
  83. mutex_unlock(&pmac_backlight_mutex);
  84. }
  85. #else
  86. static inline void pmac_backlight_unblank(void) { }
  87. #endif
  88. int die(const char *str, struct pt_regs *regs, long err)
  89. {
  90. static struct {
  91. spinlock_t lock;
  92. u32 lock_owner;
  93. int lock_owner_depth;
  94. } die = {
  95. .lock = __SPIN_LOCK_UNLOCKED(die.lock),
  96. .lock_owner = -1,
  97. .lock_owner_depth = 0
  98. };
  99. static int die_counter;
  100. unsigned long flags;
  101. if (debugger(regs))
  102. return 1;
  103. oops_enter();
  104. if (die.lock_owner != raw_smp_processor_id()) {
  105. console_verbose();
  106. spin_lock_irqsave(&die.lock, flags);
  107. die.lock_owner = smp_processor_id();
  108. die.lock_owner_depth = 0;
  109. bust_spinlocks(1);
  110. if (machine_is(powermac))
  111. pmac_backlight_unblank();
  112. } else {
  113. local_save_flags(flags);
  114. }
  115. if (++die.lock_owner_depth < 3) {
  116. printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
  117. #ifdef CONFIG_PREEMPT
  118. printk("PREEMPT ");
  119. #endif
  120. #ifdef CONFIG_SMP
  121. printk("SMP NR_CPUS=%d ", NR_CPUS);
  122. #endif
  123. #ifdef CONFIG_DEBUG_PAGEALLOC
  124. printk("DEBUG_PAGEALLOC ");
  125. #endif
  126. #ifdef CONFIG_NUMA
  127. printk("NUMA ");
  128. #endif
  129. printk("%s\n", ppc_md.name ? ppc_md.name : "");
  130. print_modules();
  131. show_regs(regs);
  132. } else {
  133. printk("Recursive die() failure, output suppressed\n");
  134. }
  135. bust_spinlocks(0);
  136. die.lock_owner = -1;
  137. add_taint(TAINT_DIE);
  138. spin_unlock_irqrestore(&die.lock, flags);
  139. if (kexec_should_crash(current) ||
  140. kexec_sr_activated(smp_processor_id()))
  141. crash_kexec(regs);
  142. crash_kexec_secondary(regs);
  143. if (in_interrupt())
  144. panic("Fatal exception in interrupt");
  145. if (panic_on_oops)
  146. panic("Fatal exception");
  147. oops_exit();
  148. do_exit(err);
  149. return 0;
  150. }
  151. void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr)
  152. {
  153. siginfo_t info;
  154. const char fmt32[] = KERN_INFO "%s[%d]: unhandled signal %d " \
  155. "at %08lx nip %08lx lr %08lx code %x\n";
  156. const char fmt64[] = KERN_INFO "%s[%d]: unhandled signal %d " \
  157. "at %016lx nip %016lx lr %016lx code %x\n";
  158. if (!user_mode(regs)) {
  159. if (die("Exception in kernel mode", regs, signr))
  160. return;
  161. } else if (show_unhandled_signals &&
  162. unhandled_signal(current, signr) &&
  163. printk_ratelimit()) {
  164. printk(regs->msr & MSR_SF ? fmt64 : fmt32,
  165. current->comm, current->pid, signr,
  166. addr, regs->nip, regs->link, code);
  167. }
  168. memset(&info, 0, sizeof(info));
  169. info.si_signo = signr;
  170. info.si_code = code;
  171. info.si_addr = (void __user *) addr;
  172. force_sig_info(signr, &info, current);
  173. /*
  174. * Init gets no signals that it doesn't have a handler for.
  175. * That's all very well, but if it has caused a synchronous
  176. * exception and we ignore the resulting signal, it will just
  177. * generate the same exception over and over again and we get
  178. * nowhere. Better to kill it and let the kernel panic.
  179. */
  180. if (is_global_init(current)) {
  181. __sighandler_t handler;
  182. spin_lock_irq(&current->sighand->siglock);
  183. handler = current->sighand->action[signr-1].sa.sa_handler;
  184. spin_unlock_irq(&current->sighand->siglock);
  185. if (handler == SIG_DFL) {
  186. /* init has generated a synchronous exception
  187. and it doesn't have a handler for the signal */
  188. printk(KERN_CRIT "init has generated signal %d "
  189. "but has no handler for it\n", signr);
  190. do_exit(signr);
  191. }
  192. }
  193. }
  194. #ifdef CONFIG_PPC64
  195. void system_reset_exception(struct pt_regs *regs)
  196. {
  197. /* See if any machine dependent calls */
  198. if (ppc_md.system_reset_exception) {
  199. if (ppc_md.system_reset_exception(regs))
  200. return;
  201. }
  202. #ifdef CONFIG_KEXEC
  203. cpu_set(smp_processor_id(), cpus_in_sr);
  204. #endif
  205. die("System Reset", regs, SIGABRT);
  206. /*
  207. * Some CPUs when released from the debugger will execute this path.
  208. * These CPUs entered the debugger via a soft-reset. If the CPU was
  209. * hung before entering the debugger it will return to the hung
  210. * state when exiting this function. This causes a problem in
  211. * kdump since the hung CPU(s) will not respond to the IPI sent
  212. * from kdump. To prevent the problem we call crash_kexec_secondary()
  213. * here. If a kdump had not been initiated or we exit the debugger
  214. * with the "exit and recover" command (x) crash_kexec_secondary()
  215. * will return after 5ms and the CPU returns to its previous state.
  216. */
  217. crash_kexec_secondary(regs);
  218. /* Must die if the interrupt is not recoverable */
  219. if (!(regs->msr & MSR_RI))
  220. panic("Unrecoverable System Reset");
  221. /* What should we do here? We could issue a shutdown or hard reset. */
  222. }
  223. #endif
  224. /*
  225. * I/O accesses can cause machine checks on powermacs.
  226. * Check if the NIP corresponds to the address of a sync
  227. * instruction for which there is an entry in the exception
  228. * table.
  229. * Note that the 601 only takes a machine check on TEA
  230. * (transfer error ack) signal assertion, and does not
  231. * set any of the top 16 bits of SRR1.
  232. * -- paulus.
  233. */
  234. static inline int check_io_access(struct pt_regs *regs)
  235. {
  236. #ifdef CONFIG_PPC32
  237. unsigned long msr = regs->msr;
  238. const struct exception_table_entry *entry;
  239. unsigned int *nip = (unsigned int *)regs->nip;
  240. if (((msr & 0xffff0000) == 0 || (msr & (0x80000 | 0x40000)))
  241. && (entry = search_exception_tables(regs->nip)) != NULL) {
  242. /*
  243. * Check that it's a sync instruction, or somewhere
  244. * in the twi; isync; nop sequence that inb/inw/inl uses.
  245. * As the address is in the exception table
  246. * we should be able to read the instr there.
  247. * For the debug message, we look at the preceding
  248. * load or store.
  249. */
  250. if (*nip == 0x60000000) /* nop */
  251. nip -= 2;
  252. else if (*nip == 0x4c00012c) /* isync */
  253. --nip;
  254. if (*nip == 0x7c0004ac || (*nip >> 26) == 3) {
  255. /* sync or twi */
  256. unsigned int rb;
  257. --nip;
  258. rb = (*nip >> 11) & 0x1f;
  259. printk(KERN_DEBUG "%s bad port %lx at %p\n",
  260. (*nip & 0x100)? "OUT to": "IN from",
  261. regs->gpr[rb] - _IO_BASE, nip);
  262. regs->msr |= MSR_RI;
  263. regs->nip = entry->fixup;
  264. return 1;
  265. }
  266. }
  267. #endif /* CONFIG_PPC32 */
  268. return 0;
  269. }
  270. #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
  271. /* On 4xx, the reason for the machine check or program exception
  272. is in the ESR. */
  273. #define get_reason(regs) ((regs)->dsisr)
  274. #ifndef CONFIG_FSL_BOOKE
  275. #define get_mc_reason(regs) ((regs)->dsisr)
  276. #else
  277. #define get_mc_reason(regs) (mfspr(SPRN_MCSR) & MCSR_MASK)
  278. #endif
  279. #define REASON_FP ESR_FP
  280. #define REASON_ILLEGAL (ESR_PIL | ESR_PUO)
  281. #define REASON_PRIVILEGED ESR_PPR
  282. #define REASON_TRAP ESR_PTR
  283. /* single-step stuff */
  284. #define single_stepping(regs) (current->thread.dbcr0 & DBCR0_IC)
  285. #define clear_single_step(regs) (current->thread.dbcr0 &= ~DBCR0_IC)
  286. #else
  287. /* On non-4xx, the reason for the machine check or program
  288. exception is in the MSR. */
  289. #define get_reason(regs) ((regs)->msr)
  290. #define get_mc_reason(regs) ((regs)->msr)
  291. #define REASON_FP 0x100000
  292. #define REASON_ILLEGAL 0x80000
  293. #define REASON_PRIVILEGED 0x40000
  294. #define REASON_TRAP 0x20000
  295. #define single_stepping(regs) ((regs)->msr & MSR_SE)
  296. #define clear_single_step(regs) ((regs)->msr &= ~MSR_SE)
  297. #endif
  298. #if defined(CONFIG_4xx)
  299. int machine_check_4xx(struct pt_regs *regs)
  300. {
  301. unsigned long reason = get_mc_reason(regs);
  302. if (reason & ESR_IMCP) {
  303. printk("Instruction");
  304. mtspr(SPRN_ESR, reason & ~ESR_IMCP);
  305. } else
  306. printk("Data");
  307. printk(" machine check in kernel mode.\n");
  308. return 0;
  309. }
  310. int machine_check_440A(struct pt_regs *regs)
  311. {
  312. unsigned long reason = get_mc_reason(regs);
  313. printk("Machine check in kernel mode.\n");
  314. if (reason & ESR_IMCP){
  315. printk("Instruction Synchronous Machine Check exception\n");
  316. mtspr(SPRN_ESR, reason & ~ESR_IMCP);
  317. }
  318. else {
  319. u32 mcsr = mfspr(SPRN_MCSR);
  320. if (mcsr & MCSR_IB)
  321. printk("Instruction Read PLB Error\n");
  322. if (mcsr & MCSR_DRB)
  323. printk("Data Read PLB Error\n");
  324. if (mcsr & MCSR_DWB)
  325. printk("Data Write PLB Error\n");
  326. if (mcsr & MCSR_TLBP)
  327. printk("TLB Parity Error\n");
  328. if (mcsr & MCSR_ICP){
  329. flush_instruction_cache();
  330. printk("I-Cache Parity Error\n");
  331. }
  332. if (mcsr & MCSR_DCSP)
  333. printk("D-Cache Search Parity Error\n");
  334. if (mcsr & MCSR_DCFP)
  335. printk("D-Cache Flush Parity Error\n");
  336. if (mcsr & MCSR_IMPE)
  337. printk("Machine Check exception is imprecise\n");
  338. /* Clear MCSR */
  339. mtspr(SPRN_MCSR, mcsr);
  340. }
  341. return 0;
  342. }
  343. #elif defined(CONFIG_E500)
  344. int machine_check_e500(struct pt_regs *regs)
  345. {
  346. unsigned long reason = get_mc_reason(regs);
  347. printk("Machine check in kernel mode.\n");
  348. printk("Caused by (from MCSR=%lx): ", reason);
  349. if (reason & MCSR_MCP)
  350. printk("Machine Check Signal\n");
  351. if (reason & MCSR_ICPERR)
  352. printk("Instruction Cache Parity Error\n");
  353. if (reason & MCSR_DCP_PERR)
  354. printk("Data Cache Push Parity Error\n");
  355. if (reason & MCSR_DCPERR)
  356. printk("Data Cache Parity Error\n");
  357. if (reason & MCSR_BUS_IAERR)
  358. printk("Bus - Instruction Address Error\n");
  359. if (reason & MCSR_BUS_RAERR)
  360. printk("Bus - Read Address Error\n");
  361. if (reason & MCSR_BUS_WAERR)
  362. printk("Bus - Write Address Error\n");
  363. if (reason & MCSR_BUS_IBERR)
  364. printk("Bus - Instruction Data Error\n");
  365. if (reason & MCSR_BUS_RBERR)
  366. printk("Bus - Read Data Bus Error\n");
  367. if (reason & MCSR_BUS_WBERR)
  368. printk("Bus - Read Data Bus Error\n");
  369. if (reason & MCSR_BUS_IPERR)
  370. printk("Bus - Instruction Parity Error\n");
  371. if (reason & MCSR_BUS_RPERR)
  372. printk("Bus - Read Parity Error\n");
  373. return 0;
  374. }
  375. #elif defined(CONFIG_E200)
  376. int machine_check_e200(struct pt_regs *regs)
  377. {
  378. unsigned long reason = get_mc_reason(regs);
  379. printk("Machine check in kernel mode.\n");
  380. printk("Caused by (from MCSR=%lx): ", reason);
  381. if (reason & MCSR_MCP)
  382. printk("Machine Check Signal\n");
  383. if (reason & MCSR_CP_PERR)
  384. printk("Cache Push Parity Error\n");
  385. if (reason & MCSR_CPERR)
  386. printk("Cache Parity Error\n");
  387. if (reason & MCSR_EXCP_ERR)
  388. printk("ISI, ITLB, or Bus Error on first instruction fetch for an exception handler\n");
  389. if (reason & MCSR_BUS_IRERR)
  390. printk("Bus - Read Bus Error on instruction fetch\n");
  391. if (reason & MCSR_BUS_DRERR)
  392. printk("Bus - Read Bus Error on data load\n");
  393. if (reason & MCSR_BUS_WRERR)
  394. printk("Bus - Write Bus Error on buffered store or cache line push\n");
  395. return 0;
  396. }
  397. #else
  398. int machine_check_generic(struct pt_regs *regs)
  399. {
  400. unsigned long reason = get_mc_reason(regs);
  401. printk("Machine check in kernel mode.\n");
  402. printk("Caused by (from SRR1=%lx): ", reason);
  403. switch (reason & 0x601F0000) {
  404. case 0x80000:
  405. printk("Machine check signal\n");
  406. break;
  407. case 0: /* for 601 */
  408. case 0x40000:
  409. case 0x140000: /* 7450 MSS error and TEA */
  410. printk("Transfer error ack signal\n");
  411. break;
  412. case 0x20000:
  413. printk("Data parity error signal\n");
  414. break;
  415. case 0x10000:
  416. printk("Address parity error signal\n");
  417. break;
  418. case 0x20000000:
  419. printk("L1 Data Cache error\n");
  420. break;
  421. case 0x40000000:
  422. printk("L1 Instruction Cache error\n");
  423. break;
  424. case 0x00100000:
  425. printk("L2 data cache parity error\n");
  426. break;
  427. default:
  428. printk("Unknown values in msr\n");
  429. }
  430. return 0;
  431. }
  432. #endif /* everything else */
  433. void machine_check_exception(struct pt_regs *regs)
  434. {
  435. int recover = 0;
  436. /* See if any machine dependent calls. In theory, we would want
  437. * to call the CPU first, and call the ppc_md. one if the CPU
  438. * one returns a positive number. However there is existing code
  439. * that assumes the board gets a first chance, so let's keep it
  440. * that way for now and fix things later. --BenH.
  441. */
  442. if (ppc_md.machine_check_exception)
  443. recover = ppc_md.machine_check_exception(regs);
  444. else if (cur_cpu_spec->machine_check)
  445. recover = cur_cpu_spec->machine_check(regs);
  446. if (recover > 0)
  447. return;
  448. if (user_mode(regs)) {
  449. regs->msr |= MSR_RI;
  450. _exception(SIGBUS, regs, BUS_ADRERR, regs->nip);
  451. return;
  452. }
  453. #if defined(CONFIG_8xx) && defined(CONFIG_PCI)
  454. /* the qspan pci read routines can cause machine checks -- Cort
  455. *
  456. * yuck !!! that totally needs to go away ! There are better ways
  457. * to deal with that than having a wart in the mcheck handler.
  458. * -- BenH
  459. */
  460. bad_page_fault(regs, regs->dar, SIGBUS);
  461. return;
  462. #endif
  463. if (debugger_fault_handler(regs)) {
  464. regs->msr |= MSR_RI;
  465. return;
  466. }
  467. if (check_io_access(regs))
  468. return;
  469. if (debugger_fault_handler(regs))
  470. return;
  471. die("Machine check", regs, SIGBUS);
  472. /* Must die if the interrupt is not recoverable */
  473. if (!(regs->msr & MSR_RI))
  474. panic("Unrecoverable Machine check");
  475. }
  476. void SMIException(struct pt_regs *regs)
  477. {
  478. die("System Management Interrupt", regs, SIGABRT);
  479. }
  480. void unknown_exception(struct pt_regs *regs)
  481. {
  482. printk("Bad trap at PC: %lx, SR: %lx, vector=%lx\n",
  483. regs->nip, regs->msr, regs->trap);
  484. _exception(SIGTRAP, regs, 0, 0);
  485. }
  486. void instruction_breakpoint_exception(struct pt_regs *regs)
  487. {
  488. if (notify_die(DIE_IABR_MATCH, "iabr_match", regs, 5,
  489. 5, SIGTRAP) == NOTIFY_STOP)
  490. return;
  491. if (debugger_iabr_match(regs))
  492. return;
  493. _exception(SIGTRAP, regs, TRAP_BRKPT, regs->nip);
  494. }
  495. void RunModeException(struct pt_regs *regs)
  496. {
  497. _exception(SIGTRAP, regs, 0, 0);
  498. }
  499. void __kprobes single_step_exception(struct pt_regs *regs)
  500. {
  501. regs->msr &= ~(MSR_SE | MSR_BE); /* Turn off 'trace' bits */
  502. if (notify_die(DIE_SSTEP, "single_step", regs, 5,
  503. 5, SIGTRAP) == NOTIFY_STOP)
  504. return;
  505. if (debugger_sstep(regs))
  506. return;
  507. _exception(SIGTRAP, regs, TRAP_TRACE, regs->nip);
  508. }
  509. /*
  510. * After we have successfully emulated an instruction, we have to
  511. * check if the instruction was being single-stepped, and if so,
  512. * pretend we got a single-step exception. This was pointed out
  513. * by Kumar Gala. -- paulus
  514. */
  515. static void emulate_single_step(struct pt_regs *regs)
  516. {
  517. if (single_stepping(regs)) {
  518. clear_single_step(regs);
  519. _exception(SIGTRAP, regs, TRAP_TRACE, 0);
  520. }
  521. }
  522. static inline int __parse_fpscr(unsigned long fpscr)
  523. {
  524. int ret = 0;
  525. /* Invalid operation */
  526. if ((fpscr & FPSCR_VE) && (fpscr & FPSCR_VX))
  527. ret = FPE_FLTINV;
  528. /* Overflow */
  529. else if ((fpscr & FPSCR_OE) && (fpscr & FPSCR_OX))
  530. ret = FPE_FLTOVF;
  531. /* Underflow */
  532. else if ((fpscr & FPSCR_UE) && (fpscr & FPSCR_UX))
  533. ret = FPE_FLTUND;
  534. /* Divide by zero */
  535. else if ((fpscr & FPSCR_ZE) && (fpscr & FPSCR_ZX))
  536. ret = FPE_FLTDIV;
  537. /* Inexact result */
  538. else if ((fpscr & FPSCR_XE) && (fpscr & FPSCR_XX))
  539. ret = FPE_FLTRES;
  540. return ret;
  541. }
  542. static void parse_fpe(struct pt_regs *regs)
  543. {
  544. int code = 0;
  545. flush_fp_to_thread(current);
  546. code = __parse_fpscr(current->thread.fpscr.val);
  547. _exception(SIGFPE, regs, code, regs->nip);
  548. }
  549. /*
  550. * Illegal instruction emulation support. Originally written to
  551. * provide the PVR to user applications using the mfspr rd, PVR.
  552. * Return non-zero if we can't emulate, or -EFAULT if the associated
  553. * memory access caused an access fault. Return zero on success.
  554. *
  555. * There are a couple of ways to do this, either "decode" the instruction
  556. * or directly match lots of bits. In this case, matching lots of
  557. * bits is faster and easier.
  558. *
  559. */
  560. #define INST_MFSPR_PVR 0x7c1f42a6
  561. #define INST_MFSPR_PVR_MASK 0xfc1fffff
  562. #define INST_DCBA 0x7c0005ec
  563. #define INST_DCBA_MASK 0xfc0007fe
  564. #define INST_MCRXR 0x7c000400
  565. #define INST_MCRXR_MASK 0xfc0007fe
  566. #define INST_STRING 0x7c00042a
  567. #define INST_STRING_MASK 0xfc0007fe
  568. #define INST_STRING_GEN_MASK 0xfc00067e
  569. #define INST_LSWI 0x7c0004aa
  570. #define INST_LSWX 0x7c00042a
  571. #define INST_STSWI 0x7c0005aa
  572. #define INST_STSWX 0x7c00052a
  573. #define INST_POPCNTB 0x7c0000f4
  574. #define INST_POPCNTB_MASK 0xfc0007fe
  575. #define INST_ISEL 0x7c00001e
  576. #define INST_ISEL_MASK 0xfc00003e
  577. static int emulate_string_inst(struct pt_regs *regs, u32 instword)
  578. {
  579. u8 rT = (instword >> 21) & 0x1f;
  580. u8 rA = (instword >> 16) & 0x1f;
  581. u8 NB_RB = (instword >> 11) & 0x1f;
  582. u32 num_bytes;
  583. unsigned long EA;
  584. int pos = 0;
  585. /* Early out if we are an invalid form of lswx */
  586. if ((instword & INST_STRING_MASK) == INST_LSWX)
  587. if ((rT == rA) || (rT == NB_RB))
  588. return -EINVAL;
  589. EA = (rA == 0) ? 0 : regs->gpr[rA];
  590. switch (instword & INST_STRING_MASK) {
  591. case INST_LSWX:
  592. case INST_STSWX:
  593. EA += NB_RB;
  594. num_bytes = regs->xer & 0x7f;
  595. break;
  596. case INST_LSWI:
  597. case INST_STSWI:
  598. num_bytes = (NB_RB == 0) ? 32 : NB_RB;
  599. break;
  600. default:
  601. return -EINVAL;
  602. }
  603. while (num_bytes != 0)
  604. {
  605. u8 val;
  606. u32 shift = 8 * (3 - (pos & 0x3));
  607. switch ((instword & INST_STRING_MASK)) {
  608. case INST_LSWX:
  609. case INST_LSWI:
  610. if (get_user(val, (u8 __user *)EA))
  611. return -EFAULT;
  612. /* first time updating this reg,
  613. * zero it out */
  614. if (pos == 0)
  615. regs->gpr[rT] = 0;
  616. regs->gpr[rT] |= val << shift;
  617. break;
  618. case INST_STSWI:
  619. case INST_STSWX:
  620. val = regs->gpr[rT] >> shift;
  621. if (put_user(val, (u8 __user *)EA))
  622. return -EFAULT;
  623. break;
  624. }
  625. /* move EA to next address */
  626. EA += 1;
  627. num_bytes--;
  628. /* manage our position within the register */
  629. if (++pos == 4) {
  630. pos = 0;
  631. if (++rT == 32)
  632. rT = 0;
  633. }
  634. }
  635. return 0;
  636. }
  637. static int emulate_popcntb_inst(struct pt_regs *regs, u32 instword)
  638. {
  639. u32 ra,rs;
  640. unsigned long tmp;
  641. ra = (instword >> 16) & 0x1f;
  642. rs = (instword >> 21) & 0x1f;
  643. tmp = regs->gpr[rs];
  644. tmp = tmp - ((tmp >> 1) & 0x5555555555555555ULL);
  645. tmp = (tmp & 0x3333333333333333ULL) + ((tmp >> 2) & 0x3333333333333333ULL);
  646. tmp = (tmp + (tmp >> 4)) & 0x0f0f0f0f0f0f0f0fULL;
  647. regs->gpr[ra] = tmp;
  648. return 0;
  649. }
  650. static int emulate_isel(struct pt_regs *regs, u32 instword)
  651. {
  652. u8 rT = (instword >> 21) & 0x1f;
  653. u8 rA = (instword >> 16) & 0x1f;
  654. u8 rB = (instword >> 11) & 0x1f;
  655. u8 BC = (instword >> 6) & 0x1f;
  656. u8 bit;
  657. unsigned long tmp;
  658. tmp = (rA == 0) ? 0 : regs->gpr[rA];
  659. bit = (regs->ccr >> (31 - BC)) & 0x1;
  660. regs->gpr[rT] = bit ? tmp : regs->gpr[rB];
  661. return 0;
  662. }
  663. static int emulate_instruction(struct pt_regs *regs)
  664. {
  665. u32 instword;
  666. u32 rd;
  667. if (!user_mode(regs) || (regs->msr & MSR_LE))
  668. return -EINVAL;
  669. CHECK_FULL_REGS(regs);
  670. if (get_user(instword, (u32 __user *)(regs->nip)))
  671. return -EFAULT;
  672. /* Emulate the mfspr rD, PVR. */
  673. if ((instword & INST_MFSPR_PVR_MASK) == INST_MFSPR_PVR) {
  674. rd = (instword >> 21) & 0x1f;
  675. regs->gpr[rd] = mfspr(SPRN_PVR);
  676. return 0;
  677. }
  678. /* Emulating the dcba insn is just a no-op. */
  679. if ((instword & INST_DCBA_MASK) == INST_DCBA)
  680. return 0;
  681. /* Emulate the mcrxr insn. */
  682. if ((instword & INST_MCRXR_MASK) == INST_MCRXR) {
  683. int shift = (instword >> 21) & 0x1c;
  684. unsigned long msk = 0xf0000000UL >> shift;
  685. regs->ccr = (regs->ccr & ~msk) | ((regs->xer >> shift) & msk);
  686. regs->xer &= ~0xf0000000UL;
  687. return 0;
  688. }
  689. /* Emulate load/store string insn. */
  690. if ((instword & INST_STRING_GEN_MASK) == INST_STRING)
  691. return emulate_string_inst(regs, instword);
  692. /* Emulate the popcntb (Population Count Bytes) instruction. */
  693. if ((instword & INST_POPCNTB_MASK) == INST_POPCNTB) {
  694. return emulate_popcntb_inst(regs, instword);
  695. }
  696. /* Emulate isel (Integer Select) instruction */
  697. if ((instword & INST_ISEL_MASK) == INST_ISEL) {
  698. return emulate_isel(regs, instword);
  699. }
  700. return -EINVAL;
  701. }
  702. int is_valid_bugaddr(unsigned long addr)
  703. {
  704. return is_kernel_addr(addr);
  705. }
  706. void __kprobes program_check_exception(struct pt_regs *regs)
  707. {
  708. unsigned int reason = get_reason(regs);
  709. extern int do_mathemu(struct pt_regs *regs);
  710. /* We can now get here via a FP Unavailable exception if the core
  711. * has no FPU, in that case the reason flags will be 0 */
  712. if (reason & REASON_FP) {
  713. /* IEEE FP exception */
  714. parse_fpe(regs);
  715. return;
  716. }
  717. if (reason & REASON_TRAP) {
  718. /* trap exception */
  719. if (notify_die(DIE_BPT, "breakpoint", regs, 5, 5, SIGTRAP)
  720. == NOTIFY_STOP)
  721. return;
  722. if (debugger_bpt(regs))
  723. return;
  724. if (!(regs->msr & MSR_PR) && /* not user-mode */
  725. report_bug(regs->nip, regs) == BUG_TRAP_TYPE_WARN) {
  726. regs->nip += 4;
  727. return;
  728. }
  729. _exception(SIGTRAP, regs, TRAP_BRKPT, regs->nip);
  730. return;
  731. }
  732. local_irq_enable();
  733. #ifdef CONFIG_MATH_EMULATION
  734. /* (reason & REASON_ILLEGAL) would be the obvious thing here,
  735. * but there seems to be a hardware bug on the 405GP (RevD)
  736. * that means ESR is sometimes set incorrectly - either to
  737. * ESR_DST (!?) or 0. In the process of chasing this with the
  738. * hardware people - not sure if it can happen on any illegal
  739. * instruction or only on FP instructions, whether there is a
  740. * pattern to occurences etc. -dgibson 31/Mar/2003 */
  741. switch (do_mathemu(regs)) {
  742. case 0:
  743. emulate_single_step(regs);
  744. return;
  745. case 1: {
  746. int code = 0;
  747. code = __parse_fpscr(current->thread.fpscr.val);
  748. _exception(SIGFPE, regs, code, regs->nip);
  749. return;
  750. }
  751. case -EFAULT:
  752. _exception(SIGSEGV, regs, SEGV_MAPERR, regs->nip);
  753. return;
  754. }
  755. /* fall through on any other errors */
  756. #endif /* CONFIG_MATH_EMULATION */
  757. /* Try to emulate it if we should. */
  758. if (reason & (REASON_ILLEGAL | REASON_PRIVILEGED)) {
  759. switch (emulate_instruction(regs)) {
  760. case 0:
  761. regs->nip += 4;
  762. emulate_single_step(regs);
  763. return;
  764. case -EFAULT:
  765. _exception(SIGSEGV, regs, SEGV_MAPERR, regs->nip);
  766. return;
  767. }
  768. }
  769. if (reason & REASON_PRIVILEGED)
  770. _exception(SIGILL, regs, ILL_PRVOPC, regs->nip);
  771. else
  772. _exception(SIGILL, regs, ILL_ILLOPC, regs->nip);
  773. }
  774. void alignment_exception(struct pt_regs *regs)
  775. {
  776. int sig, code, fixed = 0;
  777. /* we don't implement logging of alignment exceptions */
  778. if (!(current->thread.align_ctl & PR_UNALIGN_SIGBUS))
  779. fixed = fix_alignment(regs);
  780. if (fixed == 1) {
  781. regs->nip += 4; /* skip over emulated instruction */
  782. emulate_single_step(regs);
  783. return;
  784. }
  785. /* Operand address was bad */
  786. if (fixed == -EFAULT) {
  787. sig = SIGSEGV;
  788. code = SEGV_ACCERR;
  789. } else {
  790. sig = SIGBUS;
  791. code = BUS_ADRALN;
  792. }
  793. if (user_mode(regs))
  794. _exception(sig, regs, code, regs->dar);
  795. else
  796. bad_page_fault(regs, regs->dar, sig);
  797. }
  798. void StackOverflow(struct pt_regs *regs)
  799. {
  800. printk(KERN_CRIT "Kernel stack overflow in process %p, r1=%lx\n",
  801. current, regs->gpr[1]);
  802. debugger(regs);
  803. show_regs(regs);
  804. panic("kernel stack overflow");
  805. }
  806. void nonrecoverable_exception(struct pt_regs *regs)
  807. {
  808. printk(KERN_ERR "Non-recoverable exception at PC=%lx MSR=%lx\n",
  809. regs->nip, regs->msr);
  810. debugger(regs);
  811. die("nonrecoverable exception", regs, SIGKILL);
  812. }
  813. void trace_syscall(struct pt_regs *regs)
  814. {
  815. printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
  816. current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
  817. regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
  818. }
  819. void kernel_fp_unavailable_exception(struct pt_regs *regs)
  820. {
  821. printk(KERN_EMERG "Unrecoverable FP Unavailable Exception "
  822. "%lx at %lx\n", regs->trap, regs->nip);
  823. die("Unrecoverable FP Unavailable Exception", regs, SIGABRT);
  824. }
  825. void altivec_unavailable_exception(struct pt_regs *regs)
  826. {
  827. if (user_mode(regs)) {
  828. /* A user program has executed an altivec instruction,
  829. but this kernel doesn't support altivec. */
  830. _exception(SIGILL, regs, ILL_ILLOPC, regs->nip);
  831. return;
  832. }
  833. printk(KERN_EMERG "Unrecoverable VMX/Altivec Unavailable Exception "
  834. "%lx at %lx\n", regs->trap, regs->nip);
  835. die("Unrecoverable VMX/Altivec Unavailable Exception", regs, SIGABRT);
  836. }
  837. void vsx_unavailable_exception(struct pt_regs *regs)
  838. {
  839. if (user_mode(regs)) {
  840. /* A user program has executed an vsx instruction,
  841. but this kernel doesn't support vsx. */
  842. _exception(SIGILL, regs, ILL_ILLOPC, regs->nip);
  843. return;
  844. }
  845. printk(KERN_EMERG "Unrecoverable VSX Unavailable Exception "
  846. "%lx at %lx\n", regs->trap, regs->nip);
  847. die("Unrecoverable VSX Unavailable Exception", regs, SIGABRT);
  848. }
  849. void performance_monitor_exception(struct pt_regs *regs)
  850. {
  851. perf_irq(regs);
  852. }
  853. #ifdef CONFIG_8xx
  854. void SoftwareEmulation(struct pt_regs *regs)
  855. {
  856. extern int do_mathemu(struct pt_regs *);
  857. extern int Soft_emulate_8xx(struct pt_regs *);
  858. #if defined(CONFIG_MATH_EMULATION) || defined(CONFIG_8XX_MINIMAL_FPEMU)
  859. int errcode;
  860. #endif
  861. CHECK_FULL_REGS(regs);
  862. if (!user_mode(regs)) {
  863. debugger(regs);
  864. die("Kernel Mode Software FPU Emulation", regs, SIGFPE);
  865. }
  866. #ifdef CONFIG_MATH_EMULATION
  867. errcode = do_mathemu(regs);
  868. switch (errcode) {
  869. case 0:
  870. emulate_single_step(regs);
  871. return;
  872. case 1: {
  873. int code = 0;
  874. code = __parse_fpscr(current->thread.fpscr.val);
  875. _exception(SIGFPE, regs, code, regs->nip);
  876. return;
  877. }
  878. case -EFAULT:
  879. _exception(SIGSEGV, regs, SEGV_MAPERR, regs->nip);
  880. return;
  881. default:
  882. _exception(SIGILL, regs, ILL_ILLOPC, regs->nip);
  883. return;
  884. }
  885. #elif defined(CONFIG_8XX_MINIMAL_FPEMU)
  886. errcode = Soft_emulate_8xx(regs);
  887. switch (errcode) {
  888. case 0:
  889. emulate_single_step(regs);
  890. return;
  891. case 1:
  892. _exception(SIGILL, regs, ILL_ILLOPC, regs->nip);
  893. return;
  894. case -EFAULT:
  895. _exception(SIGSEGV, regs, SEGV_MAPERR, regs->nip);
  896. return;
  897. }
  898. #else
  899. _exception(SIGILL, regs, ILL_ILLOPC, regs->nip);
  900. #endif
  901. }
  902. #endif /* CONFIG_8xx */
  903. #if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
  904. void __kprobes DebugException(struct pt_regs *regs, unsigned long debug_status)
  905. {
  906. if (debug_status & DBSR_IC) { /* instruction completion */
  907. regs->msr &= ~MSR_DE;
  908. /* Disable instruction completion */
  909. mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) & ~DBCR0_IC);
  910. /* Clear the instruction completion event */
  911. mtspr(SPRN_DBSR, DBSR_IC);
  912. if (notify_die(DIE_SSTEP, "single_step", regs, 5,
  913. 5, SIGTRAP) == NOTIFY_STOP) {
  914. return;
  915. }
  916. if (debugger_sstep(regs))
  917. return;
  918. if (user_mode(regs)) {
  919. current->thread.dbcr0 &= ~DBCR0_IC;
  920. }
  921. _exception(SIGTRAP, regs, TRAP_TRACE, regs->nip);
  922. } else if (debug_status & (DBSR_DAC1R | DBSR_DAC1W)) {
  923. regs->msr &= ~MSR_DE;
  924. if (user_mode(regs)) {
  925. current->thread.dbcr0 &= ~(DBSR_DAC1R | DBSR_DAC1W |
  926. DBCR0_IDM);
  927. } else {
  928. /* Disable DAC interupts */
  929. mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) & ~(DBSR_DAC1R |
  930. DBSR_DAC1W | DBCR0_IDM));
  931. /* Clear the DAC event */
  932. mtspr(SPRN_DBSR, (DBSR_DAC1R | DBSR_DAC1W));
  933. }
  934. /* Setup and send the trap to the handler */
  935. do_dabr(regs, mfspr(SPRN_DAC1), debug_status);
  936. }
  937. }
  938. #endif /* CONFIG_4xx || CONFIG_BOOKE */
  939. #if !defined(CONFIG_TAU_INT)
  940. void TAUException(struct pt_regs *regs)
  941. {
  942. printk("TAU trap at PC: %lx, MSR: %lx, vector=%lx %s\n",
  943. regs->nip, regs->msr, regs->trap, print_tainted());
  944. }
  945. #endif /* CONFIG_INT_TAU */
  946. #ifdef CONFIG_ALTIVEC
  947. void altivec_assist_exception(struct pt_regs *regs)
  948. {
  949. int err;
  950. if (!user_mode(regs)) {
  951. printk(KERN_EMERG "VMX/Altivec assist exception in kernel mode"
  952. " at %lx\n", regs->nip);
  953. die("Kernel VMX/Altivec assist exception", regs, SIGILL);
  954. }
  955. flush_altivec_to_thread(current);
  956. err = emulate_altivec(regs);
  957. if (err == 0) {
  958. regs->nip += 4; /* skip emulated instruction */
  959. emulate_single_step(regs);
  960. return;
  961. }
  962. if (err == -EFAULT) {
  963. /* got an error reading the instruction */
  964. _exception(SIGSEGV, regs, SEGV_ACCERR, regs->nip);
  965. } else {
  966. /* didn't recognize the instruction */
  967. /* XXX quick hack for now: set the non-Java bit in the VSCR */
  968. if (printk_ratelimit())
  969. printk(KERN_ERR "Unrecognized altivec instruction "
  970. "in %s at %lx\n", current->comm, regs->nip);
  971. current->thread.vscr.u[3] |= 0x10000;
  972. }
  973. }
  974. #endif /* CONFIG_ALTIVEC */
  975. #ifdef CONFIG_VSX
  976. void vsx_assist_exception(struct pt_regs *regs)
  977. {
  978. if (!user_mode(regs)) {
  979. printk(KERN_EMERG "VSX assist exception in kernel mode"
  980. " at %lx\n", regs->nip);
  981. die("Kernel VSX assist exception", regs, SIGILL);
  982. }
  983. flush_vsx_to_thread(current);
  984. printk(KERN_INFO "VSX assist not supported at %lx\n", regs->nip);
  985. _exception(SIGILL, regs, ILL_ILLOPC, regs->nip);
  986. }
  987. #endif /* CONFIG_VSX */
  988. #ifdef CONFIG_FSL_BOOKE
  989. void CacheLockingException(struct pt_regs *regs, unsigned long address,
  990. unsigned long error_code)
  991. {
  992. /* We treat cache locking instructions from the user
  993. * as priv ops, in the future we could try to do
  994. * something smarter
  995. */
  996. if (error_code & (ESR_DLK|ESR_ILK))
  997. _exception(SIGILL, regs, ILL_PRVOPC, regs->nip);
  998. return;
  999. }
  1000. #endif /* CONFIG_FSL_BOOKE */
  1001. #ifdef CONFIG_SPE
  1002. void SPEFloatingPointException(struct pt_regs *regs)
  1003. {
  1004. unsigned long spefscr;
  1005. int fpexc_mode;
  1006. int code = 0;
  1007. spefscr = current->thread.spefscr;
  1008. fpexc_mode = current->thread.fpexc_mode;
  1009. /* Hardware does not neccessarily set sticky
  1010. * underflow/overflow/invalid flags */
  1011. if ((spefscr & SPEFSCR_FOVF) && (fpexc_mode & PR_FP_EXC_OVF)) {
  1012. code = FPE_FLTOVF;
  1013. spefscr |= SPEFSCR_FOVFS;
  1014. }
  1015. else if ((spefscr & SPEFSCR_FUNF) && (fpexc_mode & PR_FP_EXC_UND)) {
  1016. code = FPE_FLTUND;
  1017. spefscr |= SPEFSCR_FUNFS;
  1018. }
  1019. else if ((spefscr & SPEFSCR_FDBZ) && (fpexc_mode & PR_FP_EXC_DIV))
  1020. code = FPE_FLTDIV;
  1021. else if ((spefscr & SPEFSCR_FINV) && (fpexc_mode & PR_FP_EXC_INV)) {
  1022. code = FPE_FLTINV;
  1023. spefscr |= SPEFSCR_FINVS;
  1024. }
  1025. else if ((spefscr & (SPEFSCR_FG | SPEFSCR_FX)) && (fpexc_mode & PR_FP_EXC_RES))
  1026. code = FPE_FLTRES;
  1027. current->thread.spefscr = spefscr;
  1028. _exception(SIGFPE, regs, code, regs->nip);
  1029. return;
  1030. }
  1031. #endif
  1032. /*
  1033. * We enter here if we get an unrecoverable exception, that is, one
  1034. * that happened at a point where the RI (recoverable interrupt) bit
  1035. * in the MSR is 0. This indicates that SRR0/1 are live, and that
  1036. * we therefore lost state by taking this exception.
  1037. */
  1038. void unrecoverable_exception(struct pt_regs *regs)
  1039. {
  1040. printk(KERN_EMERG "Unrecoverable exception %lx at %lx\n",
  1041. regs->trap, regs->nip);
  1042. die("Unrecoverable exception", regs, SIGABRT);
  1043. }
  1044. #ifdef CONFIG_BOOKE_WDT
  1045. /*
  1046. * Default handler for a Watchdog exception,
  1047. * spins until a reboot occurs
  1048. */
  1049. void __attribute__ ((weak)) WatchdogHandler(struct pt_regs *regs)
  1050. {
  1051. /* Generic WatchdogHandler, implement your own */
  1052. mtspr(SPRN_TCR, mfspr(SPRN_TCR)&(~TCR_WIE));
  1053. return;
  1054. }
  1055. void WatchdogException(struct pt_regs *regs)
  1056. {
  1057. printk (KERN_EMERG "PowerPC Book-E Watchdog Exception\n");
  1058. WatchdogHandler(regs);
  1059. }
  1060. #endif
  1061. /*
  1062. * We enter here if we discover during exception entry that we are
  1063. * running in supervisor mode with a userspace value in the stack pointer.
  1064. */
  1065. void kernel_bad_stack(struct pt_regs *regs)
  1066. {
  1067. printk(KERN_EMERG "Bad kernel stack pointer %lx at %lx\n",
  1068. regs->gpr[1], regs->nip);
  1069. die("Bad kernel stack pointer", regs, SIGABRT);
  1070. }
  1071. void __init trap_init(void)
  1072. {
  1073. }