traps.c 30 KB

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