traps.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227
  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" ((void*)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 *endstack;
  884. int i;
  885. if (!stack) {
  886. if (task)
  887. stack = (unsigned long *)task->thread.esp0;
  888. else
  889. stack = (unsigned long *)&stack;
  890. }
  891. endstack = (unsigned long *)(((unsigned long)stack + THREAD_SIZE - 1) & -THREAD_SIZE);
  892. printk("Stack from %08lx:", (unsigned long)stack);
  893. for (i = 0; i < kstack_depth_to_print; i++) {
  894. if (stack + 1 > endstack)
  895. break;
  896. if (i % 8 == 0)
  897. printk("\n ");
  898. printk(" %08lx", *stack++);
  899. }
  900. printk("\n");
  901. show_trace(stack);
  902. }
  903. /*
  904. * The architecture-independent backtrace generator
  905. */
  906. void dump_stack(void)
  907. {
  908. unsigned long stack;
  909. show_trace(&stack);
  910. }
  911. EXPORT_SYMBOL(dump_stack);
  912. void bad_super_trap (struct frame *fp)
  913. {
  914. console_verbose();
  915. if (fp->ptregs.vector < 4*sizeof(vec_names)/sizeof(vec_names[0]))
  916. printk ("*** %s *** FORMAT=%X\n",
  917. vec_names[(fp->ptregs.vector) >> 2],
  918. fp->ptregs.format);
  919. else
  920. printk ("*** Exception %d *** FORMAT=%X\n",
  921. (fp->ptregs.vector) >> 2,
  922. fp->ptregs.format);
  923. if (fp->ptregs.vector >> 2 == VEC_ADDRERR && CPU_IS_020_OR_030) {
  924. unsigned short ssw = fp->un.fmtb.ssw;
  925. printk ("SSW=%#06x ", ssw);
  926. if (ssw & RC)
  927. printk ("Pipe stage C instruction fault at %#010lx\n",
  928. (fp->ptregs.format) == 0xA ?
  929. fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2);
  930. if (ssw & RB)
  931. printk ("Pipe stage B instruction fault at %#010lx\n",
  932. (fp->ptregs.format) == 0xA ?
  933. fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
  934. if (ssw & DF)
  935. printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
  936. ssw & RW ? "read" : "write",
  937. fp->un.fmtb.daddr, space_names[ssw & DFC],
  938. fp->ptregs.pc);
  939. }
  940. printk ("Current process id is %d\n", current->pid);
  941. die_if_kernel("BAD KERNEL TRAP", &fp->ptregs, 0);
  942. }
  943. asmlinkage void trap_c(struct frame *fp)
  944. {
  945. int sig;
  946. siginfo_t info;
  947. if (fp->ptregs.sr & PS_S) {
  948. if ((fp->ptregs.vector >> 2) == VEC_TRACE) {
  949. /* traced a trapping instruction */
  950. current->ptrace |= PT_DTRACE;
  951. } else
  952. bad_super_trap(fp);
  953. return;
  954. }
  955. /* send the appropriate signal to the user program */
  956. switch ((fp->ptregs.vector) >> 2) {
  957. case VEC_ADDRERR:
  958. info.si_code = BUS_ADRALN;
  959. sig = SIGBUS;
  960. break;
  961. case VEC_ILLEGAL:
  962. case VEC_LINE10:
  963. case VEC_LINE11:
  964. info.si_code = ILL_ILLOPC;
  965. sig = SIGILL;
  966. break;
  967. case VEC_PRIV:
  968. info.si_code = ILL_PRVOPC;
  969. sig = SIGILL;
  970. break;
  971. case VEC_COPROC:
  972. info.si_code = ILL_COPROC;
  973. sig = SIGILL;
  974. break;
  975. case VEC_TRAP1:
  976. case VEC_TRAP2:
  977. case VEC_TRAP3:
  978. case VEC_TRAP4:
  979. case VEC_TRAP5:
  980. case VEC_TRAP6:
  981. case VEC_TRAP7:
  982. case VEC_TRAP8:
  983. case VEC_TRAP9:
  984. case VEC_TRAP10:
  985. case VEC_TRAP11:
  986. case VEC_TRAP12:
  987. case VEC_TRAP13:
  988. case VEC_TRAP14:
  989. info.si_code = ILL_ILLTRP;
  990. sig = SIGILL;
  991. break;
  992. case VEC_FPBRUC:
  993. case VEC_FPOE:
  994. case VEC_FPNAN:
  995. info.si_code = FPE_FLTINV;
  996. sig = SIGFPE;
  997. break;
  998. case VEC_FPIR:
  999. info.si_code = FPE_FLTRES;
  1000. sig = SIGFPE;
  1001. break;
  1002. case VEC_FPDIVZ:
  1003. info.si_code = FPE_FLTDIV;
  1004. sig = SIGFPE;
  1005. break;
  1006. case VEC_FPUNDER:
  1007. info.si_code = FPE_FLTUND;
  1008. sig = SIGFPE;
  1009. break;
  1010. case VEC_FPOVER:
  1011. info.si_code = FPE_FLTOVF;
  1012. sig = SIGFPE;
  1013. break;
  1014. case VEC_ZERODIV:
  1015. info.si_code = FPE_INTDIV;
  1016. sig = SIGFPE;
  1017. break;
  1018. case VEC_CHK:
  1019. case VEC_TRAP:
  1020. info.si_code = FPE_INTOVF;
  1021. sig = SIGFPE;
  1022. break;
  1023. case VEC_TRACE: /* ptrace single step */
  1024. info.si_code = TRAP_TRACE;
  1025. sig = SIGTRAP;
  1026. break;
  1027. case VEC_TRAP15: /* breakpoint */
  1028. info.si_code = TRAP_BRKPT;
  1029. sig = SIGTRAP;
  1030. break;
  1031. default:
  1032. info.si_code = ILL_ILLOPC;
  1033. sig = SIGILL;
  1034. break;
  1035. }
  1036. info.si_signo = sig;
  1037. info.si_errno = 0;
  1038. switch (fp->ptregs.format) {
  1039. default:
  1040. info.si_addr = (void *) fp->ptregs.pc;
  1041. break;
  1042. case 2:
  1043. info.si_addr = (void *) fp->un.fmt2.iaddr;
  1044. break;
  1045. case 7:
  1046. info.si_addr = (void *) fp->un.fmt7.effaddr;
  1047. break;
  1048. case 9:
  1049. info.si_addr = (void *) fp->un.fmt9.iaddr;
  1050. break;
  1051. case 10:
  1052. info.si_addr = (void *) fp->un.fmta.daddr;
  1053. break;
  1054. case 11:
  1055. info.si_addr = (void *) fp->un.fmtb.daddr;
  1056. break;
  1057. }
  1058. force_sig_info (sig, &info, current);
  1059. }
  1060. void die_if_kernel (char *str, struct pt_regs *fp, int nr)
  1061. {
  1062. if (!(fp->sr & PS_S))
  1063. return;
  1064. console_verbose();
  1065. printk("%s: %08x\n",str,nr);
  1066. print_modules();
  1067. printk("PC: [<%08lx>]",fp->pc);
  1068. print_symbol(" %s\n", fp->pc);
  1069. printk("\nSR: %04x SP: %p a2: %08lx\n",
  1070. fp->sr, fp, fp->a2);
  1071. printk("d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n",
  1072. fp->d0, fp->d1, fp->d2, fp->d3);
  1073. printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
  1074. fp->d4, fp->d5, fp->a0, fp->a1);
  1075. printk("Process %s (pid: %d, stackpage=%08lx)\n",
  1076. current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
  1077. show_stack(NULL, (unsigned long *)fp);
  1078. do_exit(SIGSEGV);
  1079. }
  1080. /*
  1081. * This function is called if an error occur while accessing
  1082. * user-space from the fpsp040 code.
  1083. */
  1084. asmlinkage void fpsp040_die(void)
  1085. {
  1086. do_exit(SIGSEGV);
  1087. }
  1088. #ifdef CONFIG_M68KFPU_EMU
  1089. asmlinkage void fpemu_signal(int signal, int code, void *addr)
  1090. {
  1091. siginfo_t info;
  1092. info.si_signo = signal;
  1093. info.si_errno = 0;
  1094. info.si_code = code;
  1095. info.si_addr = addr;
  1096. force_sig_info(signal, &info, current);
  1097. }
  1098. #endif