traps.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196
  1. /*
  2. * linux/arch/m68k/kernel/traps.c
  3. *
  4. * Copyright (C) 1993, 1994 by Hamish Macdonald
  5. *
  6. * 68040 fixes by Michael Rausch
  7. * 68040 fixes by Martin Apel
  8. * 68040 fixes and writeback by Richard Zidlicky
  9. * 68060 fixes by Roman Hodek
  10. * 68060 fixes by Jesper Skov
  11. *
  12. * This file is subject to the terms and conditions of the GNU General Public
  13. * License. See the file COPYING in the main directory of this archive
  14. * for more details.
  15. */
  16. /*
  17. * Sets up all exception vectors
  18. */
  19. #include <linux/sched.h>
  20. #include <linux/signal.h>
  21. #include <linux/kernel.h>
  22. #include <linux/mm.h>
  23. #include <linux/module.h>
  24. #include <linux/user.h>
  25. #include <linux/string.h>
  26. #include <linux/linkage.h>
  27. #include <linux/init.h>
  28. #include <linux/ptrace.h>
  29. #include <linux/kallsyms.h>
  30. #include <asm/setup.h>
  31. #include <asm/fpu.h>
  32. #include <asm/system.h>
  33. #include <asm/uaccess.h>
  34. #include <asm/traps.h>
  35. #include <asm/pgalloc.h>
  36. #include <asm/machdep.h>
  37. #include <asm/siginfo.h>
  38. /* assembler routines */
  39. asmlinkage void system_call(void);
  40. asmlinkage void buserr(void);
  41. asmlinkage void trap(void);
  42. asmlinkage void nmihandler(void);
  43. #ifdef CONFIG_M68KFPU_EMU
  44. asmlinkage void fpu_emu(void);
  45. #endif
  46. e_vector vectors[256] = {
  47. [VEC_BUSERR] = buserr,
  48. [VEC_SYS] = system_call,
  49. };
  50. /* nmi handler for the Amiga */
  51. asm(".text\n"
  52. __ALIGN_STR "\n"
  53. "nmihandler: rte");
  54. /*
  55. * this must be called very early as the kernel might
  56. * use some instruction that are emulated on the 060
  57. */
  58. void __init base_trap_init(void)
  59. {
  60. if(MACH_IS_SUN3X) {
  61. extern e_vector *sun3x_prom_vbr;
  62. __asm__ volatile ("movec %%vbr, %0" : "=r" (sun3x_prom_vbr));
  63. }
  64. /* setup the exception vector table */
  65. __asm__ volatile ("movec %0,%%vbr" : : "r" ((void*)vectors));
  66. if (CPU_IS_060) {
  67. /* set up ISP entry points */
  68. asmlinkage void unimp_vec(void) asm ("_060_isp_unimp");
  69. vectors[VEC_UNIMPII] = unimp_vec;
  70. }
  71. }
  72. void __init trap_init (void)
  73. {
  74. int i;
  75. for (i = VEC_SPUR; i <= VEC_INT7; i++)
  76. vectors[i] = bad_inthandler;
  77. for (i = 0; i < VEC_USER; i++)
  78. if (!vectors[i])
  79. vectors[i] = trap;
  80. for (i = VEC_USER; i < 256; i++)
  81. vectors[i] = bad_inthandler;
  82. #ifdef CONFIG_M68KFPU_EMU
  83. if (FPU_IS_EMU)
  84. vectors[VEC_LINE11] = fpu_emu;
  85. #endif
  86. if (CPU_IS_040 && !FPU_IS_EMU) {
  87. /* set up FPSP entry points */
  88. asmlinkage void dz_vec(void) asm ("dz");
  89. asmlinkage void inex_vec(void) asm ("inex");
  90. asmlinkage void ovfl_vec(void) asm ("ovfl");
  91. asmlinkage void unfl_vec(void) asm ("unfl");
  92. asmlinkage void snan_vec(void) asm ("snan");
  93. asmlinkage void operr_vec(void) asm ("operr");
  94. asmlinkage void bsun_vec(void) asm ("bsun");
  95. asmlinkage void fline_vec(void) asm ("fline");
  96. asmlinkage void unsupp_vec(void) asm ("unsupp");
  97. vectors[VEC_FPDIVZ] = dz_vec;
  98. vectors[VEC_FPIR] = inex_vec;
  99. vectors[VEC_FPOVER] = ovfl_vec;
  100. vectors[VEC_FPUNDER] = unfl_vec;
  101. vectors[VEC_FPNAN] = snan_vec;
  102. vectors[VEC_FPOE] = operr_vec;
  103. vectors[VEC_FPBRUC] = bsun_vec;
  104. vectors[VEC_LINE11] = fline_vec;
  105. vectors[VEC_FPUNSUP] = unsupp_vec;
  106. }
  107. if (CPU_IS_060 && !FPU_IS_EMU) {
  108. /* set up IFPSP entry points */
  109. asmlinkage void snan_vec6(void) asm ("_060_fpsp_snan");
  110. asmlinkage void operr_vec6(void) asm ("_060_fpsp_operr");
  111. asmlinkage void ovfl_vec6(void) asm ("_060_fpsp_ovfl");
  112. asmlinkage void unfl_vec6(void) asm ("_060_fpsp_unfl");
  113. asmlinkage void dz_vec6(void) asm ("_060_fpsp_dz");
  114. asmlinkage void inex_vec6(void) asm ("_060_fpsp_inex");
  115. asmlinkage void fline_vec6(void) asm ("_060_fpsp_fline");
  116. asmlinkage void unsupp_vec6(void) asm ("_060_fpsp_unsupp");
  117. asmlinkage void effadd_vec6(void) asm ("_060_fpsp_effadd");
  118. vectors[VEC_FPNAN] = snan_vec6;
  119. vectors[VEC_FPOE] = operr_vec6;
  120. vectors[VEC_FPOVER] = ovfl_vec6;
  121. vectors[VEC_FPUNDER] = unfl_vec6;
  122. vectors[VEC_FPDIVZ] = dz_vec6;
  123. vectors[VEC_FPIR] = inex_vec6;
  124. vectors[VEC_LINE11] = fline_vec6;
  125. vectors[VEC_FPUNSUP] = unsupp_vec6;
  126. vectors[VEC_UNIMPEA] = effadd_vec6;
  127. }
  128. /* if running on an amiga, make the NMI interrupt do nothing */
  129. if (MACH_IS_AMIGA) {
  130. vectors[VEC_INT7] = nmihandler;
  131. }
  132. }
  133. static const char *vec_names[] = {
  134. [VEC_RESETSP] = "RESET SP",
  135. [VEC_RESETPC] = "RESET PC",
  136. [VEC_BUSERR] = "BUS ERROR",
  137. [VEC_ADDRERR] = "ADDRESS ERROR",
  138. [VEC_ILLEGAL] = "ILLEGAL INSTRUCTION",
  139. [VEC_ZERODIV] = "ZERO DIVIDE",
  140. [VEC_CHK] = "CHK",
  141. [VEC_TRAP] = "TRAPcc",
  142. [VEC_PRIV] = "PRIVILEGE VIOLATION",
  143. [VEC_TRACE] = "TRACE",
  144. [VEC_LINE10] = "LINE 1010",
  145. [VEC_LINE11] = "LINE 1111",
  146. [VEC_RESV12] = "UNASSIGNED RESERVED 12",
  147. [VEC_COPROC] = "COPROCESSOR PROTOCOL VIOLATION",
  148. [VEC_FORMAT] = "FORMAT ERROR",
  149. [VEC_UNINT] = "UNINITIALIZED INTERRUPT",
  150. [VEC_RESV16] = "UNASSIGNED RESERVED 16",
  151. [VEC_RESV17] = "UNASSIGNED RESERVED 17",
  152. [VEC_RESV18] = "UNASSIGNED RESERVED 18",
  153. [VEC_RESV19] = "UNASSIGNED RESERVED 19",
  154. [VEC_RESV20] = "UNASSIGNED RESERVED 20",
  155. [VEC_RESV21] = "UNASSIGNED RESERVED 21",
  156. [VEC_RESV22] = "UNASSIGNED RESERVED 22",
  157. [VEC_RESV23] = "UNASSIGNED RESERVED 23",
  158. [VEC_SPUR] = "SPURIOUS INTERRUPT",
  159. [VEC_INT1] = "LEVEL 1 INT",
  160. [VEC_INT2] = "LEVEL 2 INT",
  161. [VEC_INT3] = "LEVEL 3 INT",
  162. [VEC_INT4] = "LEVEL 4 INT",
  163. [VEC_INT5] = "LEVEL 5 INT",
  164. [VEC_INT6] = "LEVEL 6 INT",
  165. [VEC_INT7] = "LEVEL 7 INT",
  166. [VEC_SYS] = "SYSCALL",
  167. [VEC_TRAP1] = "TRAP #1",
  168. [VEC_TRAP2] = "TRAP #2",
  169. [VEC_TRAP3] = "TRAP #3",
  170. [VEC_TRAP4] = "TRAP #4",
  171. [VEC_TRAP5] = "TRAP #5",
  172. [VEC_TRAP6] = "TRAP #6",
  173. [VEC_TRAP7] = "TRAP #7",
  174. [VEC_TRAP8] = "TRAP #8",
  175. [VEC_TRAP9] = "TRAP #9",
  176. [VEC_TRAP10] = "TRAP #10",
  177. [VEC_TRAP11] = "TRAP #11",
  178. [VEC_TRAP12] = "TRAP #12",
  179. [VEC_TRAP13] = "TRAP #13",
  180. [VEC_TRAP14] = "TRAP #14",
  181. [VEC_TRAP15] = "TRAP #15",
  182. [VEC_FPBRUC] = "FPCP BSUN",
  183. [VEC_FPIR] = "FPCP INEXACT",
  184. [VEC_FPDIVZ] = "FPCP DIV BY 0",
  185. [VEC_FPUNDER] = "FPCP UNDERFLOW",
  186. [VEC_FPOE] = "FPCP OPERAND ERROR",
  187. [VEC_FPOVER] = "FPCP OVERFLOW",
  188. [VEC_FPNAN] = "FPCP SNAN",
  189. [VEC_FPUNSUP] = "FPCP UNSUPPORTED OPERATION",
  190. [VEC_MMUCFG] = "MMU CONFIGURATION ERROR",
  191. [VEC_MMUILL] = "MMU ILLEGAL OPERATION ERROR",
  192. [VEC_MMUACC] = "MMU ACCESS LEVEL VIOLATION ERROR",
  193. [VEC_RESV59] = "UNASSIGNED RESERVED 59",
  194. [VEC_UNIMPEA] = "UNASSIGNED RESERVED 60",
  195. [VEC_UNIMPII] = "UNASSIGNED RESERVED 61",
  196. [VEC_RESV62] = "UNASSIGNED RESERVED 62",
  197. [VEC_RESV63] = "UNASSIGNED RESERVED 63",
  198. };
  199. static const char *space_names[] = {
  200. [0] = "Space 0",
  201. [USER_DATA] = "User Data",
  202. [USER_PROGRAM] = "User Program",
  203. #ifndef CONFIG_SUN3
  204. [3] = "Space 3",
  205. #else
  206. [FC_CONTROL] = "Control",
  207. #endif
  208. [4] = "Space 4",
  209. [SUPER_DATA] = "Super Data",
  210. [SUPER_PROGRAM] = "Super Program",
  211. [CPU_SPACE] = "CPU"
  212. };
  213. void die_if_kernel(char *,struct pt_regs *,int);
  214. asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address,
  215. unsigned long error_code);
  216. int send_fault_sig(struct pt_regs *regs);
  217. asmlinkage void trap_c(struct frame *fp);
  218. #if defined (CONFIG_M68060)
  219. static inline void access_error060 (struct frame *fp)
  220. {
  221. unsigned long fslw = fp->un.fmt4.pc; /* is really FSLW for access error */
  222. #ifdef DEBUG
  223. printk("fslw=%#lx, fa=%#lx\n", fslw, fp->un.fmt4.effaddr);
  224. #endif
  225. if (fslw & MMU060_BPE) {
  226. /* branch prediction error -> clear branch cache */
  227. __asm__ __volatile__ ("movec %/cacr,%/d0\n\t"
  228. "orl #0x00400000,%/d0\n\t"
  229. "movec %/d0,%/cacr"
  230. : : : "d0" );
  231. /* return if there's no other error */
  232. if (!(fslw & MMU060_ERR_BITS) && !(fslw & MMU060_SEE))
  233. return;
  234. }
  235. if (fslw & (MMU060_DESC_ERR | MMU060_WP | MMU060_SP)) {
  236. unsigned long errorcode;
  237. unsigned long addr = fp->un.fmt4.effaddr;
  238. if (fslw & MMU060_MA)
  239. addr = (addr + PAGE_SIZE - 1) & PAGE_MASK;
  240. errorcode = 1;
  241. if (fslw & MMU060_DESC_ERR) {
  242. __flush_tlb040_one(addr);
  243. errorcode = 0;
  244. }
  245. if (fslw & MMU060_W)
  246. errorcode |= 2;
  247. #ifdef DEBUG
  248. printk("errorcode = %d\n", errorcode );
  249. #endif
  250. do_page_fault(&fp->ptregs, addr, errorcode);
  251. } else if (fslw & (MMU060_SEE)){
  252. /* Software Emulation Error.
  253. * fault during mem_read/mem_write in ifpsp060/os.S
  254. */
  255. send_fault_sig(&fp->ptregs);
  256. } else if (!(fslw & (MMU060_RE|MMU060_WE)) ||
  257. send_fault_sig(&fp->ptregs) > 0) {
  258. printk("pc=%#lx, fa=%#lx\n", fp->ptregs.pc, fp->un.fmt4.effaddr);
  259. printk( "68060 access error, fslw=%lx\n", fslw );
  260. trap_c( fp );
  261. }
  262. }
  263. #endif /* CONFIG_M68060 */
  264. #if defined (CONFIG_M68040)
  265. static inline unsigned long probe040(int iswrite, unsigned long addr, int wbs)
  266. {
  267. unsigned long mmusr;
  268. mm_segment_t old_fs = get_fs();
  269. set_fs(MAKE_MM_SEG(wbs));
  270. if (iswrite)
  271. asm volatile (".chip 68040; ptestw (%0); .chip 68k" : : "a" (addr));
  272. else
  273. asm volatile (".chip 68040; ptestr (%0); .chip 68k" : : "a" (addr));
  274. asm volatile (".chip 68040; movec %%mmusr,%0; .chip 68k" : "=r" (mmusr));
  275. set_fs(old_fs);
  276. return mmusr;
  277. }
  278. static inline int do_040writeback1(unsigned short wbs, unsigned long wba,
  279. unsigned long wbd)
  280. {
  281. int res = 0;
  282. mm_segment_t old_fs = get_fs();
  283. /* set_fs can not be moved, otherwise put_user() may oops */
  284. set_fs(MAKE_MM_SEG(wbs));
  285. switch (wbs & WBSIZ_040) {
  286. case BA_SIZE_BYTE:
  287. res = put_user(wbd & 0xff, (char __user *)wba);
  288. break;
  289. case BA_SIZE_WORD:
  290. res = put_user(wbd & 0xffff, (short __user *)wba);
  291. break;
  292. case BA_SIZE_LONG:
  293. res = put_user(wbd, (int __user *)wba);
  294. break;
  295. }
  296. /* set_fs can not be moved, otherwise put_user() may oops */
  297. set_fs(old_fs);
  298. #ifdef DEBUG
  299. printk("do_040writeback1, res=%d\n",res);
  300. #endif
  301. return res;
  302. }
  303. /* after an exception in a writeback the stack frame corresponding
  304. * to that exception is discarded, set a few bits in the old frame
  305. * to simulate what it should look like
  306. */
  307. static inline void fix_xframe040(struct frame *fp, unsigned long wba, unsigned short wbs)
  308. {
  309. fp->un.fmt7.faddr = wba;
  310. fp->un.fmt7.ssw = wbs & 0xff;
  311. if (wba != current->thread.faddr)
  312. fp->un.fmt7.ssw |= MA_040;
  313. }
  314. static inline void do_040writebacks(struct frame *fp)
  315. {
  316. int res = 0;
  317. #if 0
  318. if (fp->un.fmt7.wb1s & WBV_040)
  319. printk("access_error040: cannot handle 1st writeback. oops.\n");
  320. #endif
  321. if ((fp->un.fmt7.wb2s & WBV_040) &&
  322. !(fp->un.fmt7.wb2s & WBTT_040)) {
  323. res = do_040writeback1(fp->un.fmt7.wb2s, fp->un.fmt7.wb2a,
  324. fp->un.fmt7.wb2d);
  325. if (res)
  326. fix_xframe040(fp, fp->un.fmt7.wb2a, fp->un.fmt7.wb2s);
  327. else
  328. fp->un.fmt7.wb2s = 0;
  329. }
  330. /* do the 2nd wb only if the first one was successful (except for a kernel wb) */
  331. if (fp->un.fmt7.wb3s & WBV_040 && (!res || fp->un.fmt7.wb3s & 4)) {
  332. res = do_040writeback1(fp->un.fmt7.wb3s, fp->un.fmt7.wb3a,
  333. fp->un.fmt7.wb3d);
  334. if (res)
  335. {
  336. fix_xframe040(fp, fp->un.fmt7.wb3a, fp->un.fmt7.wb3s);
  337. fp->un.fmt7.wb2s = fp->un.fmt7.wb3s;
  338. fp->un.fmt7.wb3s &= (~WBV_040);
  339. fp->un.fmt7.wb2a = fp->un.fmt7.wb3a;
  340. fp->un.fmt7.wb2d = fp->un.fmt7.wb3d;
  341. }
  342. else
  343. fp->un.fmt7.wb3s = 0;
  344. }
  345. if (res)
  346. send_fault_sig(&fp->ptregs);
  347. }
  348. /*
  349. * called from sigreturn(), must ensure userspace code didn't
  350. * manipulate exception frame to circumvent protection, then complete
  351. * pending writebacks
  352. * we just clear TM2 to turn it into an userspace access
  353. */
  354. asmlinkage void berr_040cleanup(struct frame *fp)
  355. {
  356. fp->un.fmt7.wb2s &= ~4;
  357. fp->un.fmt7.wb3s &= ~4;
  358. do_040writebacks(fp);
  359. }
  360. static inline void access_error040(struct frame *fp)
  361. {
  362. unsigned short ssw = fp->un.fmt7.ssw;
  363. unsigned long mmusr;
  364. #ifdef DEBUG
  365. printk("ssw=%#x, fa=%#lx\n", ssw, fp->un.fmt7.faddr);
  366. printk("wb1s=%#x, wb2s=%#x, wb3s=%#x\n", fp->un.fmt7.wb1s,
  367. fp->un.fmt7.wb2s, fp->un.fmt7.wb3s);
  368. printk ("wb2a=%lx, wb3a=%lx, wb2d=%lx, wb3d=%lx\n",
  369. fp->un.fmt7.wb2a, fp->un.fmt7.wb3a,
  370. fp->un.fmt7.wb2d, fp->un.fmt7.wb3d);
  371. #endif
  372. if (ssw & ATC_040) {
  373. unsigned long addr = fp->un.fmt7.faddr;
  374. unsigned long errorcode;
  375. /*
  376. * The MMU status has to be determined AFTER the address
  377. * has been corrected if there was a misaligned access (MA).
  378. */
  379. if (ssw & MA_040)
  380. addr = (addr + 7) & -8;
  381. /* MMU error, get the MMUSR info for this access */
  382. mmusr = probe040(!(ssw & RW_040), addr, ssw);
  383. #ifdef DEBUG
  384. printk("mmusr = %lx\n", mmusr);
  385. #endif
  386. errorcode = 1;
  387. if (!(mmusr & MMU_R_040)) {
  388. /* clear the invalid atc entry */
  389. __flush_tlb040_one(addr);
  390. errorcode = 0;
  391. }
  392. /* despite what documentation seems to say, RMW
  393. * accesses have always both the LK and RW bits set */
  394. if (!(ssw & RW_040) || (ssw & LK_040))
  395. errorcode |= 2;
  396. if (do_page_fault(&fp->ptregs, addr, errorcode)) {
  397. #ifdef DEBUG
  398. printk("do_page_fault() !=0 \n");
  399. #endif
  400. if (user_mode(&fp->ptregs)){
  401. /* delay writebacks after signal delivery */
  402. #ifdef DEBUG
  403. printk(".. was usermode - return\n");
  404. #endif
  405. return;
  406. }
  407. /* disable writeback into user space from kernel
  408. * (if do_page_fault didn't fix the mapping,
  409. * the writeback won't do good)
  410. */
  411. #ifdef DEBUG
  412. printk(".. disabling wb2\n");
  413. #endif
  414. if (fp->un.fmt7.wb2a == fp->un.fmt7.faddr)
  415. fp->un.fmt7.wb2s &= ~WBV_040;
  416. }
  417. } else if (send_fault_sig(&fp->ptregs) > 0) {
  418. printk("68040 access error, ssw=%x\n", ssw);
  419. trap_c(fp);
  420. }
  421. do_040writebacks(fp);
  422. }
  423. #endif /* CONFIG_M68040 */
  424. #if defined(CONFIG_SUN3)
  425. #include <asm/sun3mmu.h>
  426. extern int mmu_emu_handle_fault (unsigned long, int, int);
  427. /* sun3 version of bus_error030 */
  428. static inline void bus_error030 (struct frame *fp)
  429. {
  430. unsigned char buserr_type = sun3_get_buserr ();
  431. unsigned long addr, errorcode;
  432. unsigned short ssw = fp->un.fmtb.ssw;
  433. extern unsigned long _sun3_map_test_start, _sun3_map_test_end;
  434. #ifdef DEBUG
  435. if (ssw & (FC | FB))
  436. printk ("Instruction fault at %#010lx\n",
  437. ssw & FC ?
  438. fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2
  439. :
  440. fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
  441. if (ssw & DF)
  442. printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
  443. ssw & RW ? "read" : "write",
  444. fp->un.fmtb.daddr,
  445. space_names[ssw & DFC], fp->ptregs.pc);
  446. #endif
  447. /*
  448. * Check if this page should be demand-mapped. This needs to go before
  449. * the testing for a bad kernel-space access (demand-mapping applies
  450. * to kernel accesses too).
  451. */
  452. if ((ssw & DF)
  453. && (buserr_type & (SUN3_BUSERR_PROTERR | SUN3_BUSERR_INVALID))) {
  454. if (mmu_emu_handle_fault (fp->un.fmtb.daddr, ssw & RW, 0))
  455. return;
  456. }
  457. /* Check for kernel-space pagefault (BAD). */
  458. if (fp->ptregs.sr & PS_S) {
  459. /* kernel fault must be a data fault to user space */
  460. if (! ((ssw & DF) && ((ssw & DFC) == USER_DATA))) {
  461. // try checking the kernel mappings before surrender
  462. if (mmu_emu_handle_fault (fp->un.fmtb.daddr, ssw & RW, 1))
  463. return;
  464. /* instruction fault or kernel data fault! */
  465. if (ssw & (FC | FB))
  466. printk ("Instruction fault at %#010lx\n",
  467. fp->ptregs.pc);
  468. if (ssw & DF) {
  469. /* was this fault incurred testing bus mappings? */
  470. if((fp->ptregs.pc >= (unsigned long)&_sun3_map_test_start) &&
  471. (fp->ptregs.pc <= (unsigned long)&_sun3_map_test_end)) {
  472. send_fault_sig(&fp->ptregs);
  473. return;
  474. }
  475. printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
  476. ssw & RW ? "read" : "write",
  477. fp->un.fmtb.daddr,
  478. space_names[ssw & DFC], fp->ptregs.pc);
  479. }
  480. printk ("BAD KERNEL BUSERR\n");
  481. die_if_kernel("Oops", &fp->ptregs,0);
  482. force_sig(SIGKILL, current);
  483. return;
  484. }
  485. } else {
  486. /* user fault */
  487. if (!(ssw & (FC | FB)) && !(ssw & DF))
  488. /* not an instruction fault or data fault! BAD */
  489. panic ("USER BUSERR w/o instruction or data fault");
  490. }
  491. /* First handle the data fault, if any. */
  492. if (ssw & DF) {
  493. addr = fp->un.fmtb.daddr;
  494. // errorcode bit 0: 0 -> no page 1 -> protection fault
  495. // errorcode bit 1: 0 -> read fault 1 -> write fault
  496. // (buserr_type & SUN3_BUSERR_PROTERR) -> protection fault
  497. // (buserr_type & SUN3_BUSERR_INVALID) -> invalid page fault
  498. if (buserr_type & SUN3_BUSERR_PROTERR)
  499. errorcode = 0x01;
  500. else if (buserr_type & SUN3_BUSERR_INVALID)
  501. errorcode = 0x00;
  502. else {
  503. #ifdef DEBUG
  504. printk ("*** unexpected busfault type=%#04x\n", buserr_type);
  505. printk ("invalid %s access at %#lx from pc %#lx\n",
  506. !(ssw & RW) ? "write" : "read", addr,
  507. fp->ptregs.pc);
  508. #endif
  509. die_if_kernel ("Oops", &fp->ptregs, buserr_type);
  510. force_sig (SIGBUS, current);
  511. return;
  512. }
  513. //todo: wtf is RM bit? --m
  514. if (!(ssw & RW) || ssw & RM)
  515. errorcode |= 0x02;
  516. /* Handle page fault. */
  517. do_page_fault (&fp->ptregs, addr, errorcode);
  518. /* Retry the data fault now. */
  519. return;
  520. }
  521. /* Now handle the instruction fault. */
  522. /* Get the fault address. */
  523. if (fp->ptregs.format == 0xA)
  524. addr = fp->ptregs.pc + 4;
  525. else
  526. addr = fp->un.fmtb.baddr;
  527. if (ssw & FC)
  528. addr -= 2;
  529. if (buserr_type & SUN3_BUSERR_INVALID) {
  530. if (!mmu_emu_handle_fault (fp->un.fmtb.daddr, 1, 0))
  531. do_page_fault (&fp->ptregs, addr, 0);
  532. } else {
  533. #ifdef DEBUG
  534. printk ("protection fault on insn access (segv).\n");
  535. #endif
  536. force_sig (SIGSEGV, current);
  537. }
  538. }
  539. #else
  540. #if defined(CPU_M68020_OR_M68030)
  541. static inline void bus_error030 (struct frame *fp)
  542. {
  543. volatile unsigned short temp;
  544. unsigned short mmusr;
  545. unsigned long addr, errorcode;
  546. unsigned short ssw = fp->un.fmtb.ssw;
  547. #ifdef DEBUG
  548. unsigned long desc;
  549. printk ("pid = %x ", current->pid);
  550. printk ("SSW=%#06x ", ssw);
  551. if (ssw & (FC | FB))
  552. printk ("Instruction fault at %#010lx\n",
  553. ssw & FC ?
  554. fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2
  555. :
  556. fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
  557. if (ssw & DF)
  558. printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
  559. ssw & RW ? "read" : "write",
  560. fp->un.fmtb.daddr,
  561. space_names[ssw & DFC], fp->ptregs.pc);
  562. #endif
  563. /* ++andreas: If a data fault and an instruction fault happen
  564. at the same time map in both pages. */
  565. /* First handle the data fault, if any. */
  566. if (ssw & DF) {
  567. addr = fp->un.fmtb.daddr;
  568. #ifdef DEBUG
  569. asm volatile ("ptestr %3,%2@,#7,%0\n\t"
  570. "pmove %%psr,%1@"
  571. : "=a&" (desc)
  572. : "a" (&temp), "a" (addr), "d" (ssw));
  573. #else
  574. asm volatile ("ptestr %2,%1@,#7\n\t"
  575. "pmove %%psr,%0@"
  576. : : "a" (&temp), "a" (addr), "d" (ssw));
  577. #endif
  578. mmusr = temp;
  579. #ifdef DEBUG
  580. printk("mmusr is %#x for addr %#lx in task %p\n",
  581. mmusr, addr, current);
  582. printk("descriptor address is %#lx, contents %#lx\n",
  583. __va(desc), *(unsigned long *)__va(desc));
  584. #endif
  585. errorcode = (mmusr & MMU_I) ? 0 : 1;
  586. if (!(ssw & RW) || (ssw & RM))
  587. errorcode |= 2;
  588. if (mmusr & (MMU_I | MMU_WP)) {
  589. if (ssw & 4) {
  590. printk("Data %s fault at %#010lx in %s (pc=%#lx)\n",
  591. ssw & RW ? "read" : "write",
  592. fp->un.fmtb.daddr,
  593. space_names[ssw & DFC], fp->ptregs.pc);
  594. goto buserr;
  595. }
  596. /* Don't try to do anything further if an exception was
  597. handled. */
  598. if (do_page_fault (&fp->ptregs, addr, errorcode) < 0)
  599. return;
  600. } else if (!(mmusr & MMU_I)) {
  601. /* probably a 020 cas fault */
  602. if (!(ssw & RM) && send_fault_sig(&fp->ptregs) > 0)
  603. printk("unexpected bus error (%#x,%#x)\n", ssw, mmusr);
  604. } else if (mmusr & (MMU_B|MMU_L|MMU_S)) {
  605. printk("invalid %s access at %#lx from pc %#lx\n",
  606. !(ssw & RW) ? "write" : "read", addr,
  607. fp->ptregs.pc);
  608. die_if_kernel("Oops",&fp->ptregs,mmusr);
  609. force_sig(SIGSEGV, current);
  610. return;
  611. } else {
  612. #if 0
  613. static volatile long tlong;
  614. #endif
  615. printk("weird %s access at %#lx from pc %#lx (ssw is %#x)\n",
  616. !(ssw & RW) ? "write" : "read", addr,
  617. fp->ptregs.pc, ssw);
  618. asm volatile ("ptestr #1,%1@,#0\n\t"
  619. "pmove %%psr,%0@"
  620. : /* no outputs */
  621. : "a" (&temp), "a" (addr));
  622. mmusr = temp;
  623. printk ("level 0 mmusr is %#x\n", mmusr);
  624. #if 0
  625. asm volatile ("pmove %%tt0,%0@"
  626. : /* no outputs */
  627. : "a" (&tlong));
  628. printk("tt0 is %#lx, ", tlong);
  629. asm volatile ("pmove %%tt1,%0@"
  630. : /* no outputs */
  631. : "a" (&tlong));
  632. printk("tt1 is %#lx\n", tlong);
  633. #endif
  634. #ifdef DEBUG
  635. printk("Unknown SIGSEGV - 1\n");
  636. #endif
  637. die_if_kernel("Oops",&fp->ptregs,mmusr);
  638. force_sig(SIGSEGV, current);
  639. return;
  640. }
  641. /* setup an ATC entry for the access about to be retried */
  642. if (!(ssw & RW) || (ssw & RM))
  643. asm volatile ("ploadw %1,%0@" : /* no outputs */
  644. : "a" (addr), "d" (ssw));
  645. else
  646. asm volatile ("ploadr %1,%0@" : /* no outputs */
  647. : "a" (addr), "d" (ssw));
  648. }
  649. /* Now handle the instruction fault. */
  650. if (!(ssw & (FC|FB)))
  651. return;
  652. if (fp->ptregs.sr & PS_S) {
  653. printk("Instruction fault at %#010lx\n",
  654. fp->ptregs.pc);
  655. buserr:
  656. printk ("BAD KERNEL BUSERR\n");
  657. die_if_kernel("Oops",&fp->ptregs,0);
  658. force_sig(SIGKILL, current);
  659. return;
  660. }
  661. /* get the fault address */
  662. if (fp->ptregs.format == 10)
  663. addr = fp->ptregs.pc + 4;
  664. else
  665. addr = fp->un.fmtb.baddr;
  666. if (ssw & FC)
  667. addr -= 2;
  668. if ((ssw & DF) && ((addr ^ fp->un.fmtb.daddr) & PAGE_MASK) == 0)
  669. /* Insn fault on same page as data fault. But we
  670. should still create the ATC entry. */
  671. goto create_atc_entry;
  672. #ifdef DEBUG
  673. asm volatile ("ptestr #1,%2@,#7,%0\n\t"
  674. "pmove %%psr,%1@"
  675. : "=a&" (desc)
  676. : "a" (&temp), "a" (addr));
  677. #else
  678. asm volatile ("ptestr #1,%1@,#7\n\t"
  679. "pmove %%psr,%0@"
  680. : : "a" (&temp), "a" (addr));
  681. #endif
  682. mmusr = temp;
  683. #ifdef DEBUG
  684. printk ("mmusr is %#x for addr %#lx in task %p\n",
  685. mmusr, addr, current);
  686. printk ("descriptor address is %#lx, contents %#lx\n",
  687. __va(desc), *(unsigned long *)__va(desc));
  688. #endif
  689. if (mmusr & MMU_I)
  690. do_page_fault (&fp->ptregs, addr, 0);
  691. else if (mmusr & (MMU_B|MMU_L|MMU_S)) {
  692. printk ("invalid insn access at %#lx from pc %#lx\n",
  693. addr, fp->ptregs.pc);
  694. #ifdef DEBUG
  695. printk("Unknown SIGSEGV - 2\n");
  696. #endif
  697. die_if_kernel("Oops",&fp->ptregs,mmusr);
  698. force_sig(SIGSEGV, current);
  699. return;
  700. }
  701. create_atc_entry:
  702. /* setup an ATC entry for the access about to be retried */
  703. asm volatile ("ploadr #2,%0@" : /* no outputs */
  704. : "a" (addr));
  705. }
  706. #endif /* CPU_M68020_OR_M68030 */
  707. #endif /* !CONFIG_SUN3 */
  708. asmlinkage void buserr_c(struct frame *fp)
  709. {
  710. /* Only set esp0 if coming from user mode */
  711. if (user_mode(&fp->ptregs))
  712. current->thread.esp0 = (unsigned long) fp;
  713. #ifdef DEBUG
  714. printk ("*** Bus Error *** Format is %x\n", fp->ptregs.format);
  715. #endif
  716. switch (fp->ptregs.format) {
  717. #if defined (CONFIG_M68060)
  718. case 4: /* 68060 access error */
  719. access_error060 (fp);
  720. break;
  721. #endif
  722. #if defined (CONFIG_M68040)
  723. case 0x7: /* 68040 access error */
  724. access_error040 (fp);
  725. break;
  726. #endif
  727. #if defined (CPU_M68020_OR_M68030)
  728. case 0xa:
  729. case 0xb:
  730. bus_error030 (fp);
  731. break;
  732. #endif
  733. default:
  734. die_if_kernel("bad frame format",&fp->ptregs,0);
  735. #ifdef DEBUG
  736. printk("Unknown SIGSEGV - 4\n");
  737. #endif
  738. force_sig(SIGSEGV, current);
  739. }
  740. }
  741. static int kstack_depth_to_print = 48;
  742. void show_trace(unsigned long *stack)
  743. {
  744. unsigned long *endstack;
  745. unsigned long addr;
  746. int i;
  747. printk("Call Trace:");
  748. addr = (unsigned long)stack + THREAD_SIZE - 1;
  749. endstack = (unsigned long *)(addr & -THREAD_SIZE);
  750. i = 0;
  751. while (stack + 1 <= endstack) {
  752. addr = *stack++;
  753. /*
  754. * If the address is either in the text segment of the
  755. * kernel, or in the region which contains vmalloc'ed
  756. * memory, it *may* be the address of a calling
  757. * routine; if so, print it so that someone tracing
  758. * down the cause of the crash will be able to figure
  759. * out the call path that was taken.
  760. */
  761. if (__kernel_text_address(addr)) {
  762. #ifndef CONFIG_KALLSYMS
  763. if (i % 5 == 0)
  764. printk("\n ");
  765. #endif
  766. printk(" [<%08lx>]", addr);
  767. print_symbol(" %s\n", addr);
  768. i++;
  769. }
  770. }
  771. printk("\n");
  772. }
  773. void show_registers(struct pt_regs *regs)
  774. {
  775. struct frame *fp = (struct frame *)regs;
  776. mm_segment_t old_fs = get_fs();
  777. u16 c, *cp;
  778. unsigned long addr;
  779. int i;
  780. print_modules();
  781. printk("PC: [<%08lx>]",regs->pc);
  782. print_symbol(" %s", regs->pc);
  783. printk("\nSR: %04x SP: %p a2: %08lx\n",
  784. regs->sr, regs, regs->a2);
  785. printk("d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n",
  786. regs->d0, regs->d1, regs->d2, regs->d3);
  787. printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
  788. regs->d4, regs->d5, regs->a0, regs->a1);
  789. printk("Process %s (pid: %d, task=%p)\n",
  790. current->comm, task_pid_nr(current), current);
  791. addr = (unsigned long)&fp->un;
  792. printk("Frame format=%X ", regs->format);
  793. switch (regs->format) {
  794. case 0x2:
  795. printk("instr addr=%08lx\n", fp->un.fmt2.iaddr);
  796. addr += sizeof(fp->un.fmt2);
  797. break;
  798. case 0x3:
  799. printk("eff addr=%08lx\n", fp->un.fmt3.effaddr);
  800. addr += sizeof(fp->un.fmt3);
  801. break;
  802. case 0x4:
  803. printk((CPU_IS_060 ? "fault addr=%08lx fslw=%08lx\n"
  804. : "eff addr=%08lx pc=%08lx\n"),
  805. fp->un.fmt4.effaddr, fp->un.fmt4.pc);
  806. addr += sizeof(fp->un.fmt4);
  807. break;
  808. case 0x7:
  809. printk("eff addr=%08lx ssw=%04x faddr=%08lx\n",
  810. fp->un.fmt7.effaddr, fp->un.fmt7.ssw, fp->un.fmt7.faddr);
  811. printk("wb 1 stat/addr/data: %04x %08lx %08lx\n",
  812. fp->un.fmt7.wb1s, fp->un.fmt7.wb1a, fp->un.fmt7.wb1dpd0);
  813. printk("wb 2 stat/addr/data: %04x %08lx %08lx\n",
  814. fp->un.fmt7.wb2s, fp->un.fmt7.wb2a, fp->un.fmt7.wb2d);
  815. printk("wb 3 stat/addr/data: %04x %08lx %08lx\n",
  816. fp->un.fmt7.wb3s, fp->un.fmt7.wb3a, fp->un.fmt7.wb3d);
  817. printk("push data: %08lx %08lx %08lx %08lx\n",
  818. fp->un.fmt7.wb1dpd0, fp->un.fmt7.pd1, fp->un.fmt7.pd2,
  819. fp->un.fmt7.pd3);
  820. addr += sizeof(fp->un.fmt7);
  821. break;
  822. case 0x9:
  823. printk("instr addr=%08lx\n", fp->un.fmt9.iaddr);
  824. addr += sizeof(fp->un.fmt9);
  825. break;
  826. case 0xa:
  827. printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
  828. fp->un.fmta.ssw, fp->un.fmta.isc, fp->un.fmta.isb,
  829. fp->un.fmta.daddr, fp->un.fmta.dobuf);
  830. addr += sizeof(fp->un.fmta);
  831. break;
  832. case 0xb:
  833. printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
  834. fp->un.fmtb.ssw, fp->un.fmtb.isc, fp->un.fmtb.isb,
  835. fp->un.fmtb.daddr, fp->un.fmtb.dobuf);
  836. printk("baddr=%08lx dibuf=%08lx ver=%x\n",
  837. fp->un.fmtb.baddr, fp->un.fmtb.dibuf, fp->un.fmtb.ver);
  838. addr += sizeof(fp->un.fmtb);
  839. break;
  840. default:
  841. printk("\n");
  842. }
  843. show_stack(NULL, (unsigned long *)addr);
  844. printk("Code:");
  845. set_fs(KERNEL_DS);
  846. cp = (u16 *)regs->pc;
  847. for (i = -8; i < 16; i++) {
  848. if (get_user(c, cp + i) && i >= 0) {
  849. printk(" Bad PC value.");
  850. break;
  851. }
  852. printk(i ? " %04x" : " <%04x>", c);
  853. }
  854. set_fs(old_fs);
  855. printk ("\n");
  856. }
  857. void show_stack(struct task_struct *task, unsigned long *stack)
  858. {
  859. unsigned long *p;
  860. unsigned long *endstack;
  861. int i;
  862. if (!stack) {
  863. if (task)
  864. stack = (unsigned long *)task->thread.esp0;
  865. else
  866. stack = (unsigned long *)&stack;
  867. }
  868. endstack = (unsigned long *)(((unsigned long)stack + THREAD_SIZE - 1) & -THREAD_SIZE);
  869. printk("Stack from %08lx:", (unsigned long)stack);
  870. p = stack;
  871. for (i = 0; i < kstack_depth_to_print; i++) {
  872. if (p + 1 > endstack)
  873. break;
  874. if (i % 8 == 0)
  875. printk("\n ");
  876. printk(" %08lx", *p++);
  877. }
  878. printk("\n");
  879. show_trace(stack);
  880. }
  881. /*
  882. * The architecture-independent backtrace generator
  883. */
  884. void dump_stack(void)
  885. {
  886. unsigned long stack;
  887. show_trace(&stack);
  888. }
  889. EXPORT_SYMBOL(dump_stack);
  890. void bad_super_trap (struct frame *fp)
  891. {
  892. console_verbose();
  893. if (fp->ptregs.vector < 4 * ARRAY_SIZE(vec_names))
  894. printk ("*** %s *** FORMAT=%X\n",
  895. vec_names[(fp->ptregs.vector) >> 2],
  896. fp->ptregs.format);
  897. else
  898. printk ("*** Exception %d *** FORMAT=%X\n",
  899. (fp->ptregs.vector) >> 2,
  900. fp->ptregs.format);
  901. if (fp->ptregs.vector >> 2 == VEC_ADDRERR && CPU_IS_020_OR_030) {
  902. unsigned short ssw = fp->un.fmtb.ssw;
  903. printk ("SSW=%#06x ", ssw);
  904. if (ssw & RC)
  905. printk ("Pipe stage C instruction fault at %#010lx\n",
  906. (fp->ptregs.format) == 0xA ?
  907. fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2);
  908. if (ssw & RB)
  909. printk ("Pipe stage B instruction fault at %#010lx\n",
  910. (fp->ptregs.format) == 0xA ?
  911. fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
  912. if (ssw & DF)
  913. printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
  914. ssw & RW ? "read" : "write",
  915. fp->un.fmtb.daddr, space_names[ssw & DFC],
  916. fp->ptregs.pc);
  917. }
  918. printk ("Current process id is %d\n", task_pid_nr(current));
  919. die_if_kernel("BAD KERNEL TRAP", &fp->ptregs, 0);
  920. }
  921. asmlinkage void trap_c(struct frame *fp)
  922. {
  923. int sig;
  924. siginfo_t info;
  925. if (fp->ptregs.sr & PS_S) {
  926. if ((fp->ptregs.vector >> 2) == VEC_TRACE) {
  927. /* traced a trapping instruction */
  928. current->ptrace |= PT_DTRACE;
  929. } else
  930. bad_super_trap(fp);
  931. return;
  932. }
  933. /* send the appropriate signal to the user program */
  934. switch ((fp->ptregs.vector) >> 2) {
  935. case VEC_ADDRERR:
  936. info.si_code = BUS_ADRALN;
  937. sig = SIGBUS;
  938. break;
  939. case VEC_ILLEGAL:
  940. case VEC_LINE10:
  941. case VEC_LINE11:
  942. info.si_code = ILL_ILLOPC;
  943. sig = SIGILL;
  944. break;
  945. case VEC_PRIV:
  946. info.si_code = ILL_PRVOPC;
  947. sig = SIGILL;
  948. break;
  949. case VEC_COPROC:
  950. info.si_code = ILL_COPROC;
  951. sig = SIGILL;
  952. break;
  953. case VEC_TRAP1:
  954. case VEC_TRAP2:
  955. case VEC_TRAP3:
  956. case VEC_TRAP4:
  957. case VEC_TRAP5:
  958. case VEC_TRAP6:
  959. case VEC_TRAP7:
  960. case VEC_TRAP8:
  961. case VEC_TRAP9:
  962. case VEC_TRAP10:
  963. case VEC_TRAP11:
  964. case VEC_TRAP12:
  965. case VEC_TRAP13:
  966. case VEC_TRAP14:
  967. info.si_code = ILL_ILLTRP;
  968. sig = SIGILL;
  969. break;
  970. case VEC_FPBRUC:
  971. case VEC_FPOE:
  972. case VEC_FPNAN:
  973. info.si_code = FPE_FLTINV;
  974. sig = SIGFPE;
  975. break;
  976. case VEC_FPIR:
  977. info.si_code = FPE_FLTRES;
  978. sig = SIGFPE;
  979. break;
  980. case VEC_FPDIVZ:
  981. info.si_code = FPE_FLTDIV;
  982. sig = SIGFPE;
  983. break;
  984. case VEC_FPUNDER:
  985. info.si_code = FPE_FLTUND;
  986. sig = SIGFPE;
  987. break;
  988. case VEC_FPOVER:
  989. info.si_code = FPE_FLTOVF;
  990. sig = SIGFPE;
  991. break;
  992. case VEC_ZERODIV:
  993. info.si_code = FPE_INTDIV;
  994. sig = SIGFPE;
  995. break;
  996. case VEC_CHK:
  997. case VEC_TRAP:
  998. info.si_code = FPE_INTOVF;
  999. sig = SIGFPE;
  1000. break;
  1001. case VEC_TRACE: /* ptrace single step */
  1002. info.si_code = TRAP_TRACE;
  1003. sig = SIGTRAP;
  1004. break;
  1005. case VEC_TRAP15: /* breakpoint */
  1006. info.si_code = TRAP_BRKPT;
  1007. sig = SIGTRAP;
  1008. break;
  1009. default:
  1010. info.si_code = ILL_ILLOPC;
  1011. sig = SIGILL;
  1012. break;
  1013. }
  1014. info.si_signo = sig;
  1015. info.si_errno = 0;
  1016. switch (fp->ptregs.format) {
  1017. default:
  1018. info.si_addr = (void *) fp->ptregs.pc;
  1019. break;
  1020. case 2:
  1021. info.si_addr = (void *) fp->un.fmt2.iaddr;
  1022. break;
  1023. case 7:
  1024. info.si_addr = (void *) fp->un.fmt7.effaddr;
  1025. break;
  1026. case 9:
  1027. info.si_addr = (void *) fp->un.fmt9.iaddr;
  1028. break;
  1029. case 10:
  1030. info.si_addr = (void *) fp->un.fmta.daddr;
  1031. break;
  1032. case 11:
  1033. info.si_addr = (void *) fp->un.fmtb.daddr;
  1034. break;
  1035. }
  1036. force_sig_info (sig, &info, current);
  1037. }
  1038. void die_if_kernel (char *str, struct pt_regs *fp, int nr)
  1039. {
  1040. if (!(fp->sr & PS_S))
  1041. return;
  1042. console_verbose();
  1043. printk("%s: %08x\n",str,nr);
  1044. show_registers(fp);
  1045. add_taint(TAINT_DIE);
  1046. do_exit(SIGSEGV);
  1047. }
  1048. /*
  1049. * This function is called if an error occur while accessing
  1050. * user-space from the fpsp040 code.
  1051. */
  1052. asmlinkage void fpsp040_die(void)
  1053. {
  1054. do_exit(SIGSEGV);
  1055. }
  1056. #ifdef CONFIG_M68KFPU_EMU
  1057. asmlinkage void fpemu_signal(int signal, int code, void *addr)
  1058. {
  1059. siginfo_t info;
  1060. info.si_signo = signal;
  1061. info.si_errno = 0;
  1062. info.si_code = code;
  1063. info.si_addr = addr;
  1064. force_sig_info(signal, &info, current);
  1065. }
  1066. #endif