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