traps_mm.c 31 KB

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