traps.c 31 KB

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