traps.c 31 KB

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