traps.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  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 a 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. disable_wb:
  412. #ifdef DEBUG
  413. printk(".. disabling wb2\n");
  414. #endif
  415. if (fp->un.fmt7.wb2a == fp->un.fmt7.faddr)
  416. fp->un.fmt7.wb2s &= ~WBV_040;
  417. if (fp->un.fmt7.wb3a == fp->un.fmt7.faddr)
  418. fp->un.fmt7.wb3s &= ~WBV_040;
  419. }
  420. } else {
  421. /* In case of a bus error we either kill the process or expect
  422. * the kernel to catch the fault, which then is also responsible
  423. * for cleaning up the mess.
  424. */
  425. current->thread.signo = SIGBUS;
  426. current->thread.faddr = fp->un.fmt7.faddr;
  427. if (send_fault_sig(&fp->ptregs) >= 0)
  428. printk("68040 bus error (ssw=%x, faddr=%lx)\n", ssw,
  429. fp->un.fmt7.faddr);
  430. goto disable_wb;
  431. }
  432. do_040writebacks(fp);
  433. }
  434. #endif /* CONFIG_M68040 */
  435. #if defined(CONFIG_SUN3)
  436. #include <asm/sun3mmu.h>
  437. extern int mmu_emu_handle_fault (unsigned long, int, int);
  438. /* sun3 version of bus_error030 */
  439. static inline void bus_error030 (struct frame *fp)
  440. {
  441. unsigned char buserr_type = sun3_get_buserr ();
  442. unsigned long addr, errorcode;
  443. unsigned short ssw = fp->un.fmtb.ssw;
  444. extern unsigned long _sun3_map_test_start, _sun3_map_test_end;
  445. #ifdef DEBUG
  446. if (ssw & (FC | FB))
  447. printk ("Instruction fault at %#010lx\n",
  448. ssw & FC ?
  449. fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2
  450. :
  451. fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
  452. if (ssw & DF)
  453. printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
  454. ssw & RW ? "read" : "write",
  455. fp->un.fmtb.daddr,
  456. space_names[ssw & DFC], fp->ptregs.pc);
  457. #endif
  458. /*
  459. * Check if this page should be demand-mapped. This needs to go before
  460. * the testing for a bad kernel-space access (demand-mapping applies
  461. * to kernel accesses too).
  462. */
  463. if ((ssw & DF)
  464. && (buserr_type & (SUN3_BUSERR_PROTERR | SUN3_BUSERR_INVALID))) {
  465. if (mmu_emu_handle_fault (fp->un.fmtb.daddr, ssw & RW, 0))
  466. return;
  467. }
  468. /* Check for kernel-space pagefault (BAD). */
  469. if (fp->ptregs.sr & PS_S) {
  470. /* kernel fault must be a data fault to user space */
  471. if (! ((ssw & DF) && ((ssw & DFC) == USER_DATA))) {
  472. // try checking the kernel mappings before surrender
  473. if (mmu_emu_handle_fault (fp->un.fmtb.daddr, ssw & RW, 1))
  474. return;
  475. /* instruction fault or kernel data fault! */
  476. if (ssw & (FC | FB))
  477. printk ("Instruction fault at %#010lx\n",
  478. fp->ptregs.pc);
  479. if (ssw & DF) {
  480. /* was this fault incurred testing bus mappings? */
  481. if((fp->ptregs.pc >= (unsigned long)&_sun3_map_test_start) &&
  482. (fp->ptregs.pc <= (unsigned long)&_sun3_map_test_end)) {
  483. send_fault_sig(&fp->ptregs);
  484. return;
  485. }
  486. printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
  487. ssw & RW ? "read" : "write",
  488. fp->un.fmtb.daddr,
  489. space_names[ssw & DFC], fp->ptregs.pc);
  490. }
  491. printk ("BAD KERNEL BUSERR\n");
  492. die_if_kernel("Oops", &fp->ptregs,0);
  493. force_sig(SIGKILL, current);
  494. return;
  495. }
  496. } else {
  497. /* user fault */
  498. if (!(ssw & (FC | FB)) && !(ssw & DF))
  499. /* not an instruction fault or data fault! BAD */
  500. panic ("USER BUSERR w/o instruction or data fault");
  501. }
  502. /* First handle the data fault, if any. */
  503. if (ssw & DF) {
  504. addr = fp->un.fmtb.daddr;
  505. // errorcode bit 0: 0 -> no page 1 -> protection fault
  506. // errorcode bit 1: 0 -> read fault 1 -> write fault
  507. // (buserr_type & SUN3_BUSERR_PROTERR) -> protection fault
  508. // (buserr_type & SUN3_BUSERR_INVALID) -> invalid page fault
  509. if (buserr_type & SUN3_BUSERR_PROTERR)
  510. errorcode = 0x01;
  511. else if (buserr_type & SUN3_BUSERR_INVALID)
  512. errorcode = 0x00;
  513. else {
  514. #ifdef DEBUG
  515. printk ("*** unexpected busfault type=%#04x\n", buserr_type);
  516. printk ("invalid %s access at %#lx from pc %#lx\n",
  517. !(ssw & RW) ? "write" : "read", addr,
  518. fp->ptregs.pc);
  519. #endif
  520. die_if_kernel ("Oops", &fp->ptregs, buserr_type);
  521. force_sig (SIGBUS, current);
  522. return;
  523. }
  524. //todo: wtf is RM bit? --m
  525. if (!(ssw & RW) || ssw & RM)
  526. errorcode |= 0x02;
  527. /* Handle page fault. */
  528. do_page_fault (&fp->ptregs, addr, errorcode);
  529. /* Retry the data fault now. */
  530. return;
  531. }
  532. /* Now handle the instruction fault. */
  533. /* Get the fault address. */
  534. if (fp->ptregs.format == 0xA)
  535. addr = fp->ptregs.pc + 4;
  536. else
  537. addr = fp->un.fmtb.baddr;
  538. if (ssw & FC)
  539. addr -= 2;
  540. if (buserr_type & SUN3_BUSERR_INVALID) {
  541. if (!mmu_emu_handle_fault (fp->un.fmtb.daddr, 1, 0))
  542. do_page_fault (&fp->ptregs, addr, 0);
  543. } else {
  544. #ifdef DEBUG
  545. printk ("protection fault on insn access (segv).\n");
  546. #endif
  547. force_sig (SIGSEGV, current);
  548. }
  549. }
  550. #else
  551. #if defined(CPU_M68020_OR_M68030)
  552. static inline void bus_error030 (struct frame *fp)
  553. {
  554. volatile unsigned short temp;
  555. unsigned short mmusr;
  556. unsigned long addr, errorcode;
  557. unsigned short ssw = fp->un.fmtb.ssw;
  558. #ifdef DEBUG
  559. unsigned long desc;
  560. printk ("pid = %x ", current->pid);
  561. printk ("SSW=%#06x ", ssw);
  562. if (ssw & (FC | FB))
  563. printk ("Instruction fault at %#010lx\n",
  564. ssw & FC ?
  565. fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2
  566. :
  567. fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
  568. if (ssw & DF)
  569. printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
  570. ssw & RW ? "read" : "write",
  571. fp->un.fmtb.daddr,
  572. space_names[ssw & DFC], fp->ptregs.pc);
  573. #endif
  574. /* ++andreas: If a data fault and an instruction fault happen
  575. at the same time map in both pages. */
  576. /* First handle the data fault, if any. */
  577. if (ssw & DF) {
  578. addr = fp->un.fmtb.daddr;
  579. #ifdef DEBUG
  580. asm volatile ("ptestr %3,%2@,#7,%0\n\t"
  581. "pmove %%psr,%1@"
  582. : "=a&" (desc)
  583. : "a" (&temp), "a" (addr), "d" (ssw));
  584. #else
  585. asm volatile ("ptestr %2,%1@,#7\n\t"
  586. "pmove %%psr,%0@"
  587. : : "a" (&temp), "a" (addr), "d" (ssw));
  588. #endif
  589. mmusr = temp;
  590. #ifdef DEBUG
  591. printk("mmusr is %#x for addr %#lx in task %p\n",
  592. mmusr, addr, current);
  593. printk("descriptor address is %#lx, contents %#lx\n",
  594. __va(desc), *(unsigned long *)__va(desc));
  595. #endif
  596. errorcode = (mmusr & MMU_I) ? 0 : 1;
  597. if (!(ssw & RW) || (ssw & RM))
  598. errorcode |= 2;
  599. if (mmusr & (MMU_I | MMU_WP)) {
  600. if (ssw & 4) {
  601. printk("Data %s fault at %#010lx in %s (pc=%#lx)\n",
  602. ssw & RW ? "read" : "write",
  603. fp->un.fmtb.daddr,
  604. space_names[ssw & DFC], fp->ptregs.pc);
  605. goto buserr;
  606. }
  607. /* Don't try to do anything further if an exception was
  608. handled. */
  609. if (do_page_fault (&fp->ptregs, addr, errorcode) < 0)
  610. return;
  611. } else if (!(mmusr & MMU_I)) {
  612. /* probably a 020 cas fault */
  613. if (!(ssw & RM) && send_fault_sig(&fp->ptregs) > 0)
  614. printk("unexpected bus error (%#x,%#x)\n", ssw, mmusr);
  615. } else if (mmusr & (MMU_B|MMU_L|MMU_S)) {
  616. printk("invalid %s access at %#lx from pc %#lx\n",
  617. !(ssw & RW) ? "write" : "read", addr,
  618. fp->ptregs.pc);
  619. die_if_kernel("Oops",&fp->ptregs,mmusr);
  620. force_sig(SIGSEGV, current);
  621. return;
  622. } else {
  623. #if 0
  624. static volatile long tlong;
  625. #endif
  626. printk("weird %s access at %#lx from pc %#lx (ssw is %#x)\n",
  627. !(ssw & RW) ? "write" : "read", addr,
  628. fp->ptregs.pc, ssw);
  629. asm volatile ("ptestr #1,%1@,#0\n\t"
  630. "pmove %%psr,%0@"
  631. : /* no outputs */
  632. : "a" (&temp), "a" (addr));
  633. mmusr = temp;
  634. printk ("level 0 mmusr is %#x\n", mmusr);
  635. #if 0
  636. asm volatile ("pmove %%tt0,%0@"
  637. : /* no outputs */
  638. : "a" (&tlong));
  639. printk("tt0 is %#lx, ", tlong);
  640. asm volatile ("pmove %%tt1,%0@"
  641. : /* no outputs */
  642. : "a" (&tlong));
  643. printk("tt1 is %#lx\n", tlong);
  644. #endif
  645. #ifdef DEBUG
  646. printk("Unknown SIGSEGV - 1\n");
  647. #endif
  648. die_if_kernel("Oops",&fp->ptregs,mmusr);
  649. force_sig(SIGSEGV, current);
  650. return;
  651. }
  652. /* setup an ATC entry for the access about to be retried */
  653. if (!(ssw & RW) || (ssw & RM))
  654. asm volatile ("ploadw %1,%0@" : /* no outputs */
  655. : "a" (addr), "d" (ssw));
  656. else
  657. asm volatile ("ploadr %1,%0@" : /* no outputs */
  658. : "a" (addr), "d" (ssw));
  659. }
  660. /* Now handle the instruction fault. */
  661. if (!(ssw & (FC|FB)))
  662. return;
  663. if (fp->ptregs.sr & PS_S) {
  664. printk("Instruction fault at %#010lx\n",
  665. fp->ptregs.pc);
  666. buserr:
  667. printk ("BAD KERNEL BUSERR\n");
  668. die_if_kernel("Oops",&fp->ptregs,0);
  669. force_sig(SIGKILL, current);
  670. return;
  671. }
  672. /* get the fault address */
  673. if (fp->ptregs.format == 10)
  674. addr = fp->ptregs.pc + 4;
  675. else
  676. addr = fp->un.fmtb.baddr;
  677. if (ssw & FC)
  678. addr -= 2;
  679. if ((ssw & DF) && ((addr ^ fp->un.fmtb.daddr) & PAGE_MASK) == 0)
  680. /* Insn fault on same page as data fault. But we
  681. should still create the ATC entry. */
  682. goto create_atc_entry;
  683. #ifdef DEBUG
  684. asm volatile ("ptestr #1,%2@,#7,%0\n\t"
  685. "pmove %%psr,%1@"
  686. : "=a&" (desc)
  687. : "a" (&temp), "a" (addr));
  688. #else
  689. asm volatile ("ptestr #1,%1@,#7\n\t"
  690. "pmove %%psr,%0@"
  691. : : "a" (&temp), "a" (addr));
  692. #endif
  693. mmusr = temp;
  694. #ifdef DEBUG
  695. printk ("mmusr is %#x for addr %#lx in task %p\n",
  696. mmusr, addr, current);
  697. printk ("descriptor address is %#lx, contents %#lx\n",
  698. __va(desc), *(unsigned long *)__va(desc));
  699. #endif
  700. if (mmusr & MMU_I)
  701. do_page_fault (&fp->ptregs, addr, 0);
  702. else if (mmusr & (MMU_B|MMU_L|MMU_S)) {
  703. printk ("invalid insn access at %#lx from pc %#lx\n",
  704. addr, fp->ptregs.pc);
  705. #ifdef DEBUG
  706. printk("Unknown SIGSEGV - 2\n");
  707. #endif
  708. die_if_kernel("Oops",&fp->ptregs,mmusr);
  709. force_sig(SIGSEGV, current);
  710. return;
  711. }
  712. create_atc_entry:
  713. /* setup an ATC entry for the access about to be retried */
  714. asm volatile ("ploadr #2,%0@" : /* no outputs */
  715. : "a" (addr));
  716. }
  717. #endif /* CPU_M68020_OR_M68030 */
  718. #endif /* !CONFIG_SUN3 */
  719. asmlinkage void buserr_c(struct frame *fp)
  720. {
  721. /* Only set esp0 if coming from user mode */
  722. if (user_mode(&fp->ptregs))
  723. current->thread.esp0 = (unsigned long) fp;
  724. #ifdef DEBUG
  725. printk ("*** Bus Error *** Format is %x\n", fp->ptregs.format);
  726. #endif
  727. switch (fp->ptregs.format) {
  728. #if defined (CONFIG_M68060)
  729. case 4: /* 68060 access error */
  730. access_error060 (fp);
  731. break;
  732. #endif
  733. #if defined (CONFIG_M68040)
  734. case 0x7: /* 68040 access error */
  735. access_error040 (fp);
  736. break;
  737. #endif
  738. #if defined (CPU_M68020_OR_M68030)
  739. case 0xa:
  740. case 0xb:
  741. bus_error030 (fp);
  742. break;
  743. #endif
  744. default:
  745. die_if_kernel("bad frame format",&fp->ptregs,0);
  746. #ifdef DEBUG
  747. printk("Unknown SIGSEGV - 4\n");
  748. #endif
  749. force_sig(SIGSEGV, current);
  750. }
  751. }
  752. static int kstack_depth_to_print = 48;
  753. void show_trace(unsigned long *stack)
  754. {
  755. unsigned long *endstack;
  756. unsigned long addr;
  757. int i;
  758. printk("Call Trace:");
  759. addr = (unsigned long)stack + THREAD_SIZE - 1;
  760. endstack = (unsigned long *)(addr & -THREAD_SIZE);
  761. i = 0;
  762. while (stack + 1 <= endstack) {
  763. addr = *stack++;
  764. /*
  765. * If the address is either in the text segment of the
  766. * kernel, or in the region which contains vmalloc'ed
  767. * memory, it *may* be the address of a calling
  768. * routine; if so, print it so that someone tracing
  769. * down the cause of the crash will be able to figure
  770. * out the call path that was taken.
  771. */
  772. if (__kernel_text_address(addr)) {
  773. #ifndef CONFIG_KALLSYMS
  774. if (i % 5 == 0)
  775. printk("\n ");
  776. #endif
  777. printk(" [<%08lx>] %pS\n", addr, (void *)addr);
  778. i++;
  779. }
  780. }
  781. printk("\n");
  782. }
  783. void show_registers(struct pt_regs *regs)
  784. {
  785. struct frame *fp = (struct frame *)regs;
  786. mm_segment_t old_fs = get_fs();
  787. u16 c, *cp;
  788. unsigned long addr;
  789. int i;
  790. print_modules();
  791. printk("PC: [<%08lx>] %pS\n", regs->pc, (void *)regs->pc);
  792. printk("SR: %04x SP: %p a2: %08lx\n", regs->sr, regs, regs->a2);
  793. printk("d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n",
  794. regs->d0, regs->d1, regs->d2, regs->d3);
  795. printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
  796. regs->d4, regs->d5, regs->a0, regs->a1);
  797. printk("Process %s (pid: %d, task=%p)\n",
  798. current->comm, task_pid_nr(current), current);
  799. addr = (unsigned long)&fp->un;
  800. printk("Frame format=%X ", regs->format);
  801. switch (regs->format) {
  802. case 0x2:
  803. printk("instr addr=%08lx\n", fp->un.fmt2.iaddr);
  804. addr += sizeof(fp->un.fmt2);
  805. break;
  806. case 0x3:
  807. printk("eff addr=%08lx\n", fp->un.fmt3.effaddr);
  808. addr += sizeof(fp->un.fmt3);
  809. break;
  810. case 0x4:
  811. printk((CPU_IS_060 ? "fault addr=%08lx fslw=%08lx\n"
  812. : "eff addr=%08lx pc=%08lx\n"),
  813. fp->un.fmt4.effaddr, fp->un.fmt4.pc);
  814. addr += sizeof(fp->un.fmt4);
  815. break;
  816. case 0x7:
  817. printk("eff addr=%08lx ssw=%04x faddr=%08lx\n",
  818. fp->un.fmt7.effaddr, fp->un.fmt7.ssw, fp->un.fmt7.faddr);
  819. printk("wb 1 stat/addr/data: %04x %08lx %08lx\n",
  820. fp->un.fmt7.wb1s, fp->un.fmt7.wb1a, fp->un.fmt7.wb1dpd0);
  821. printk("wb 2 stat/addr/data: %04x %08lx %08lx\n",
  822. fp->un.fmt7.wb2s, fp->un.fmt7.wb2a, fp->un.fmt7.wb2d);
  823. printk("wb 3 stat/addr/data: %04x %08lx %08lx\n",
  824. fp->un.fmt7.wb3s, fp->un.fmt7.wb3a, fp->un.fmt7.wb3d);
  825. printk("push data: %08lx %08lx %08lx %08lx\n",
  826. fp->un.fmt7.wb1dpd0, fp->un.fmt7.pd1, fp->un.fmt7.pd2,
  827. fp->un.fmt7.pd3);
  828. addr += sizeof(fp->un.fmt7);
  829. break;
  830. case 0x9:
  831. printk("instr addr=%08lx\n", fp->un.fmt9.iaddr);
  832. addr += sizeof(fp->un.fmt9);
  833. break;
  834. case 0xa:
  835. printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
  836. fp->un.fmta.ssw, fp->un.fmta.isc, fp->un.fmta.isb,
  837. fp->un.fmta.daddr, fp->un.fmta.dobuf);
  838. addr += sizeof(fp->un.fmta);
  839. break;
  840. case 0xb:
  841. printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
  842. fp->un.fmtb.ssw, fp->un.fmtb.isc, fp->un.fmtb.isb,
  843. fp->un.fmtb.daddr, fp->un.fmtb.dobuf);
  844. printk("baddr=%08lx dibuf=%08lx ver=%x\n",
  845. fp->un.fmtb.baddr, fp->un.fmtb.dibuf, fp->un.fmtb.ver);
  846. addr += sizeof(fp->un.fmtb);
  847. break;
  848. default:
  849. printk("\n");
  850. }
  851. show_stack(NULL, (unsigned long *)addr);
  852. printk("Code:");
  853. set_fs(KERNEL_DS);
  854. cp = (u16 *)regs->pc;
  855. for (i = -8; i < 16; i++) {
  856. if (get_user(c, cp + i) && i >= 0) {
  857. printk(" Bad PC value.");
  858. break;
  859. }
  860. printk(i ? " %04x" : " <%04x>", c);
  861. }
  862. set_fs(old_fs);
  863. printk ("\n");
  864. }
  865. void show_stack(struct task_struct *task, unsigned long *stack)
  866. {
  867. unsigned long *p;
  868. unsigned long *endstack;
  869. int i;
  870. if (!stack) {
  871. if (task)
  872. stack = (unsigned long *)task->thread.esp0;
  873. else
  874. stack = (unsigned long *)&stack;
  875. }
  876. endstack = (unsigned long *)(((unsigned long)stack + THREAD_SIZE - 1) & -THREAD_SIZE);
  877. printk("Stack from %08lx:", (unsigned long)stack);
  878. p = stack;
  879. for (i = 0; i < kstack_depth_to_print; i++) {
  880. if (p + 1 > endstack)
  881. break;
  882. if (i % 8 == 0)
  883. printk("\n ");
  884. printk(" %08lx", *p++);
  885. }
  886. printk("\n");
  887. show_trace(stack);
  888. }
  889. /*
  890. * The architecture-independent backtrace generator
  891. */
  892. void dump_stack(void)
  893. {
  894. unsigned long stack;
  895. show_trace(&stack);
  896. }
  897. EXPORT_SYMBOL(dump_stack);
  898. void bad_super_trap (struct frame *fp)
  899. {
  900. console_verbose();
  901. if (fp->ptregs.vector < 4 * ARRAY_SIZE(vec_names))
  902. printk ("*** %s *** FORMAT=%X\n",
  903. vec_names[(fp->ptregs.vector) >> 2],
  904. fp->ptregs.format);
  905. else
  906. printk ("*** Exception %d *** FORMAT=%X\n",
  907. (fp->ptregs.vector) >> 2,
  908. fp->ptregs.format);
  909. if (fp->ptregs.vector >> 2 == VEC_ADDRERR && CPU_IS_020_OR_030) {
  910. unsigned short ssw = fp->un.fmtb.ssw;
  911. printk ("SSW=%#06x ", ssw);
  912. if (ssw & RC)
  913. printk ("Pipe stage C instruction fault at %#010lx\n",
  914. (fp->ptregs.format) == 0xA ?
  915. fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2);
  916. if (ssw & RB)
  917. printk ("Pipe stage B instruction fault at %#010lx\n",
  918. (fp->ptregs.format) == 0xA ?
  919. fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
  920. if (ssw & DF)
  921. printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
  922. ssw & RW ? "read" : "write",
  923. fp->un.fmtb.daddr, space_names[ssw & DFC],
  924. fp->ptregs.pc);
  925. }
  926. printk ("Current process id is %d\n", task_pid_nr(current));
  927. die_if_kernel("BAD KERNEL TRAP", &fp->ptregs, 0);
  928. }
  929. asmlinkage void trap_c(struct frame *fp)
  930. {
  931. int sig;
  932. siginfo_t info;
  933. if (fp->ptregs.sr & PS_S) {
  934. if ((fp->ptregs.vector >> 2) == VEC_TRACE) {
  935. /* traced a trapping instruction */
  936. } else
  937. bad_super_trap(fp);
  938. return;
  939. }
  940. /* send the appropriate signal to the user program */
  941. switch ((fp->ptregs.vector) >> 2) {
  942. case VEC_ADDRERR:
  943. info.si_code = BUS_ADRALN;
  944. sig = SIGBUS;
  945. break;
  946. case VEC_ILLEGAL:
  947. case VEC_LINE10:
  948. case VEC_LINE11:
  949. info.si_code = ILL_ILLOPC;
  950. sig = SIGILL;
  951. break;
  952. case VEC_PRIV:
  953. info.si_code = ILL_PRVOPC;
  954. sig = SIGILL;
  955. break;
  956. case VEC_COPROC:
  957. info.si_code = ILL_COPROC;
  958. sig = SIGILL;
  959. break;
  960. case VEC_TRAP1:
  961. case VEC_TRAP2:
  962. case VEC_TRAP3:
  963. case VEC_TRAP4:
  964. case VEC_TRAP5:
  965. case VEC_TRAP6:
  966. case VEC_TRAP7:
  967. case VEC_TRAP8:
  968. case VEC_TRAP9:
  969. case VEC_TRAP10:
  970. case VEC_TRAP11:
  971. case VEC_TRAP12:
  972. case VEC_TRAP13:
  973. case VEC_TRAP14:
  974. info.si_code = ILL_ILLTRP;
  975. sig = SIGILL;
  976. break;
  977. case VEC_FPBRUC:
  978. case VEC_FPOE:
  979. case VEC_FPNAN:
  980. info.si_code = FPE_FLTINV;
  981. sig = SIGFPE;
  982. break;
  983. case VEC_FPIR:
  984. info.si_code = FPE_FLTRES;
  985. sig = SIGFPE;
  986. break;
  987. case VEC_FPDIVZ:
  988. info.si_code = FPE_FLTDIV;
  989. sig = SIGFPE;
  990. break;
  991. case VEC_FPUNDER:
  992. info.si_code = FPE_FLTUND;
  993. sig = SIGFPE;
  994. break;
  995. case VEC_FPOVER:
  996. info.si_code = FPE_FLTOVF;
  997. sig = SIGFPE;
  998. break;
  999. case VEC_ZERODIV:
  1000. info.si_code = FPE_INTDIV;
  1001. sig = SIGFPE;
  1002. break;
  1003. case VEC_CHK:
  1004. case VEC_TRAP:
  1005. info.si_code = FPE_INTOVF;
  1006. sig = SIGFPE;
  1007. break;
  1008. case VEC_TRACE: /* ptrace single step */
  1009. info.si_code = TRAP_TRACE;
  1010. sig = SIGTRAP;
  1011. break;
  1012. case VEC_TRAP15: /* breakpoint */
  1013. info.si_code = TRAP_BRKPT;
  1014. sig = SIGTRAP;
  1015. break;
  1016. default:
  1017. info.si_code = ILL_ILLOPC;
  1018. sig = SIGILL;
  1019. break;
  1020. }
  1021. info.si_signo = sig;
  1022. info.si_errno = 0;
  1023. switch (fp->ptregs.format) {
  1024. default:
  1025. info.si_addr = (void *) fp->ptregs.pc;
  1026. break;
  1027. case 2:
  1028. info.si_addr = (void *) fp->un.fmt2.iaddr;
  1029. break;
  1030. case 7:
  1031. info.si_addr = (void *) fp->un.fmt7.effaddr;
  1032. break;
  1033. case 9:
  1034. info.si_addr = (void *) fp->un.fmt9.iaddr;
  1035. break;
  1036. case 10:
  1037. info.si_addr = (void *) fp->un.fmta.daddr;
  1038. break;
  1039. case 11:
  1040. info.si_addr = (void *) fp->un.fmtb.daddr;
  1041. break;
  1042. }
  1043. force_sig_info (sig, &info, current);
  1044. }
  1045. void die_if_kernel (char *str, struct pt_regs *fp, int nr)
  1046. {
  1047. if (!(fp->sr & PS_S))
  1048. return;
  1049. console_verbose();
  1050. printk("%s: %08x\n",str,nr);
  1051. show_registers(fp);
  1052. add_taint(TAINT_DIE);
  1053. do_exit(SIGSEGV);
  1054. }
  1055. /*
  1056. * This function is called if an error occur while accessing
  1057. * user-space from the fpsp040 code.
  1058. */
  1059. asmlinkage void fpsp040_die(void)
  1060. {
  1061. do_exit(SIGSEGV);
  1062. }
  1063. #ifdef CONFIG_M68KFPU_EMU
  1064. asmlinkage void fpemu_signal(int signal, int code, void *addr)
  1065. {
  1066. siginfo_t info;
  1067. info.si_signo = signal;
  1068. info.si_errno = 0;
  1069. info.si_code = code;
  1070. info.si_addr = addr;
  1071. force_sig_info(signal, &info, current);
  1072. }
  1073. #endif