2 * linux/arch/m68k/kernel/traps.c
4 * Copyright (C) 1993, 1994 by Hamish Macdonald
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
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
18 * Sets up all exception vectors
21 #include <linux/config.h>
22 #include <linux/sched.h>
23 #include <linux/signal.h>
24 #include <linux/kernel.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>
35 #include <asm/setup.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>
44 /* assembler routines */
45 asmlinkage void system_call(void);
46 asmlinkage void buserr(void);
47 asmlinkage void trap(void);
48 asmlinkage void nmihandler(void);
49 #ifdef CONFIG_M68KFPU_EMU
50 asmlinkage void fpu_emu(void);
53 e_vector vectors[256] = {
54 [VEC_BUSERR] = buserr,
55 [VEC_SYS] = system_call,
58 /* nmi handler for the Amiga */
64 * this must be called very early as the kernel might
65 * use some instruction that are emulated on the 060
67 void __init base_trap_init(void)
70 extern e_vector *sun3x_prom_vbr;
72 __asm__ volatile ("movec %%vbr, %0" : "=r" (sun3x_prom_vbr));
75 /* setup the exception vector table */
76 __asm__ volatile ("movec %0,%%vbr" : : "r" ((void*)vectors));
79 /* set up ISP entry points */
80 asmlinkage void unimp_vec(void) asm ("_060_isp_unimp");
82 vectors[VEC_UNIMPII] = unimp_vec;
86 void __init trap_init (void)
90 for (i = VEC_SPUR; i <= VEC_INT7; i++)
91 vectors[i] = bad_inthandler;
93 for (i = 0; i < VEC_USER; i++)
97 for (i = VEC_USER; i < 256; i++)
98 vectors[i] = bad_inthandler;
100 #ifdef CONFIG_M68KFPU_EMU
102 vectors[VEC_LINE11] = fpu_emu;
105 if (CPU_IS_040 && !FPU_IS_EMU) {
106 /* set up FPSP entry points */
107 asmlinkage void dz_vec(void) asm ("dz");
108 asmlinkage void inex_vec(void) asm ("inex");
109 asmlinkage void ovfl_vec(void) asm ("ovfl");
110 asmlinkage void unfl_vec(void) asm ("unfl");
111 asmlinkage void snan_vec(void) asm ("snan");
112 asmlinkage void operr_vec(void) asm ("operr");
113 asmlinkage void bsun_vec(void) asm ("bsun");
114 asmlinkage void fline_vec(void) asm ("fline");
115 asmlinkage void unsupp_vec(void) asm ("unsupp");
117 vectors[VEC_FPDIVZ] = dz_vec;
118 vectors[VEC_FPIR] = inex_vec;
119 vectors[VEC_FPOVER] = ovfl_vec;
120 vectors[VEC_FPUNDER] = unfl_vec;
121 vectors[VEC_FPNAN] = snan_vec;
122 vectors[VEC_FPOE] = operr_vec;
123 vectors[VEC_FPBRUC] = bsun_vec;
124 vectors[VEC_LINE11] = fline_vec;
125 vectors[VEC_FPUNSUP] = unsupp_vec;
128 if (CPU_IS_060 && !FPU_IS_EMU) {
129 /* set up IFPSP entry points */
130 asmlinkage void snan_vec6(void) asm ("_060_fpsp_snan");
131 asmlinkage void operr_vec6(void) asm ("_060_fpsp_operr");
132 asmlinkage void ovfl_vec6(void) asm ("_060_fpsp_ovfl");
133 asmlinkage void unfl_vec6(void) asm ("_060_fpsp_unfl");
134 asmlinkage void dz_vec6(void) asm ("_060_fpsp_dz");
135 asmlinkage void inex_vec6(void) asm ("_060_fpsp_inex");
136 asmlinkage void fline_vec6(void) asm ("_060_fpsp_fline");
137 asmlinkage void unsupp_vec6(void) asm ("_060_fpsp_unsupp");
138 asmlinkage void effadd_vec6(void) asm ("_060_fpsp_effadd");
140 vectors[VEC_FPNAN] = snan_vec6;
141 vectors[VEC_FPOE] = operr_vec6;
142 vectors[VEC_FPOVER] = ovfl_vec6;
143 vectors[VEC_FPUNDER] = unfl_vec6;
144 vectors[VEC_FPDIVZ] = dz_vec6;
145 vectors[VEC_FPIR] = inex_vec6;
146 vectors[VEC_LINE11] = fline_vec6;
147 vectors[VEC_FPUNSUP] = unsupp_vec6;
148 vectors[VEC_UNIMPEA] = effadd_vec6;
151 /* if running on an amiga, make the NMI interrupt do nothing */
153 vectors[VEC_INT7] = nmihandler;
158 static const char *vec_names[] = {
159 [VEC_RESETSP] = "RESET SP",
160 [VEC_RESETPC] = "RESET PC",
161 [VEC_BUSERR] = "BUS ERROR",
162 [VEC_ADDRERR] = "ADDRESS ERROR",
163 [VEC_ILLEGAL] = "ILLEGAL INSTRUCTION",
164 [VEC_ZERODIV] = "ZERO DIVIDE",
166 [VEC_TRAP] = "TRAPcc",
167 [VEC_PRIV] = "PRIVILEGE VIOLATION",
168 [VEC_TRACE] = "TRACE",
169 [VEC_LINE10] = "LINE 1010",
170 [VEC_LINE11] = "LINE 1111",
171 [VEC_RESV12] = "UNASSIGNED RESERVED 12",
172 [VEC_COPROC] = "COPROCESSOR PROTOCOL VIOLATION",
173 [VEC_FORMAT] = "FORMAT ERROR",
174 [VEC_UNINT] = "UNINITIALIZED INTERRUPT",
175 [VEC_RESV16] = "UNASSIGNED RESERVED 16",
176 [VEC_RESV17] = "UNASSIGNED RESERVED 17",
177 [VEC_RESV18] = "UNASSIGNED RESERVED 18",
178 [VEC_RESV19] = "UNASSIGNED RESERVED 19",
179 [VEC_RESV20] = "UNASSIGNED RESERVED 20",
180 [VEC_RESV21] = "UNASSIGNED RESERVED 21",
181 [VEC_RESV22] = "UNASSIGNED RESERVED 22",
182 [VEC_RESV23] = "UNASSIGNED RESERVED 23",
183 [VEC_SPUR] = "SPURIOUS INTERRUPT",
184 [VEC_INT1] = "LEVEL 1 INT",
185 [VEC_INT2] = "LEVEL 2 INT",
186 [VEC_INT3] = "LEVEL 3 INT",
187 [VEC_INT4] = "LEVEL 4 INT",
188 [VEC_INT5] = "LEVEL 5 INT",
189 [VEC_INT6] = "LEVEL 6 INT",
190 [VEC_INT7] = "LEVEL 7 INT",
191 [VEC_SYS] = "SYSCALL",
192 [VEC_TRAP1] = "TRAP #1",
193 [VEC_TRAP2] = "TRAP #2",
194 [VEC_TRAP3] = "TRAP #3",
195 [VEC_TRAP4] = "TRAP #4",
196 [VEC_TRAP5] = "TRAP #5",
197 [VEC_TRAP6] = "TRAP #6",
198 [VEC_TRAP7] = "TRAP #7",
199 [VEC_TRAP8] = "TRAP #8",
200 [VEC_TRAP9] = "TRAP #9",
201 [VEC_TRAP10] = "TRAP #10",
202 [VEC_TRAP11] = "TRAP #11",
203 [VEC_TRAP12] = "TRAP #12",
204 [VEC_TRAP13] = "TRAP #13",
205 [VEC_TRAP14] = "TRAP #14",
206 [VEC_TRAP15] = "TRAP #15",
207 [VEC_FPBRUC] = "FPCP BSUN",
208 [VEC_FPIR] = "FPCP INEXACT",
209 [VEC_FPDIVZ] = "FPCP DIV BY 0",
210 [VEC_FPUNDER] = "FPCP UNDERFLOW",
211 [VEC_FPOE] = "FPCP OPERAND ERROR",
212 [VEC_FPOVER] = "FPCP OVERFLOW",
213 [VEC_FPNAN] = "FPCP SNAN",
214 [VEC_FPUNSUP] = "FPCP UNSUPPORTED OPERATION",
215 [VEC_MMUCFG] = "MMU CONFIGURATION ERROR",
216 [VEC_MMUILL] = "MMU ILLEGAL OPERATION ERROR",
217 [VEC_MMUACC] = "MMU ACCESS LEVEL VIOLATION ERROR",
218 [VEC_RESV59] = "UNASSIGNED RESERVED 59",
219 [VEC_UNIMPEA] = "UNASSIGNED RESERVED 60",
220 [VEC_UNIMPII] = "UNASSIGNED RESERVED 61",
221 [VEC_RESV62] = "UNASSIGNED RESERVED 62",
222 [VEC_RESV63] = "UNASSIGNED RESERVED 63",
225 static const char *space_names[] = {
227 [USER_DATA] = "User Data",
228 [USER_PROGRAM] = "User Program",
232 [FC_CONTROL] = "Control",
235 [SUPER_DATA] = "Super Data",
236 [SUPER_PROGRAM] = "Super Program",
240 void die_if_kernel(char *,struct pt_regs *,int);
241 asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address,
242 unsigned long error_code);
243 int send_fault_sig(struct pt_regs *regs);
245 asmlinkage void trap_c(struct frame *fp);
247 #if defined (CONFIG_M68060)
248 static inline void access_error060 (struct frame *fp)
250 unsigned long fslw = fp->un.fmt4.pc; /* is really FSLW for access error */
253 printk("fslw=%#lx, fa=%#lx\n", fslw, fp->un.fmt4.effaddr);
256 if (fslw & MMU060_BPE) {
257 /* branch prediction error -> clear branch cache */
258 __asm__ __volatile__ ("movec %/cacr,%/d0\n\t"
259 "orl #0x00400000,%/d0\n\t"
262 /* return if there's no other error */
263 if (!(fslw & MMU060_ERR_BITS) && !(fslw & MMU060_SEE))
267 if (fslw & (MMU060_DESC_ERR | MMU060_WP | MMU060_SP)) {
268 unsigned long errorcode;
269 unsigned long addr = fp->un.fmt4.effaddr;
271 if (fslw & MMU060_MA)
272 addr = (addr + PAGE_SIZE - 1) & PAGE_MASK;
275 if (fslw & MMU060_DESC_ERR) {
276 __flush_tlb040_one(addr);
282 printk("errorcode = %d\n", errorcode );
284 do_page_fault(&fp->ptregs, addr, errorcode);
285 } else if (fslw & (MMU060_SEE)){
286 /* Software Emulation Error.
287 * fault during mem_read/mem_write in ifpsp060/os.S
289 send_fault_sig(&fp->ptregs);
290 } else if (!(fslw & (MMU060_RE|MMU060_WE)) ||
291 send_fault_sig(&fp->ptregs) > 0) {
292 printk("pc=%#lx, fa=%#lx\n", fp->ptregs.pc, fp->un.fmt4.effaddr);
293 printk( "68060 access error, fslw=%lx\n", fslw );
297 #endif /* CONFIG_M68060 */
299 #if defined (CONFIG_M68040)
300 static inline unsigned long probe040(int iswrite, unsigned long addr, int wbs)
303 mm_segment_t old_fs = get_fs();
305 set_fs(MAKE_MM_SEG(wbs));
308 asm volatile (".chip 68040; ptestw (%0); .chip 68k" : : "a" (addr));
310 asm volatile (".chip 68040; ptestr (%0); .chip 68k" : : "a" (addr));
312 asm volatile (".chip 68040; movec %%mmusr,%0; .chip 68k" : "=r" (mmusr));
319 static inline int do_040writeback1(unsigned short wbs, unsigned long wba,
323 mm_segment_t old_fs = get_fs();
325 /* set_fs can not be moved, otherwise put_user() may oops */
326 set_fs(MAKE_MM_SEG(wbs));
328 switch (wbs & WBSIZ_040) {
330 res = put_user(wbd & 0xff, (char *)wba);
333 res = put_user(wbd & 0xffff, (short *)wba);
336 res = put_user(wbd, (int *)wba);
340 /* set_fs can not be moved, otherwise put_user() may oops */
345 printk("do_040writeback1, res=%d\n",res);
351 /* after an exception in a writeback the stack frame corresponding
352 * to that exception is discarded, set a few bits in the old frame
353 * to simulate what it should look like
355 static inline void fix_xframe040(struct frame *fp, unsigned long wba, unsigned short wbs)
357 fp->un.fmt7.faddr = wba;
358 fp->un.fmt7.ssw = wbs & 0xff;
359 if (wba != current->thread.faddr)
360 fp->un.fmt7.ssw |= MA_040;
363 static inline void do_040writebacks(struct frame *fp)
367 if (fp->un.fmt7.wb1s & WBV_040)
368 printk("access_error040: cannot handle 1st writeback. oops.\n");
371 if ((fp->un.fmt7.wb2s & WBV_040) &&
372 !(fp->un.fmt7.wb2s & WBTT_040)) {
373 res = do_040writeback1(fp->un.fmt7.wb2s, fp->un.fmt7.wb2a,
376 fix_xframe040(fp, fp->un.fmt7.wb2a, fp->un.fmt7.wb2s);
378 fp->un.fmt7.wb2s = 0;
381 /* do the 2nd wb only if the first one was successful (except for a kernel wb) */
382 if (fp->un.fmt7.wb3s & WBV_040 && (!res || fp->un.fmt7.wb3s & 4)) {
383 res = do_040writeback1(fp->un.fmt7.wb3s, fp->un.fmt7.wb3a,
387 fix_xframe040(fp, fp->un.fmt7.wb3a, fp->un.fmt7.wb3s);
389 fp->un.fmt7.wb2s = fp->un.fmt7.wb3s;
390 fp->un.fmt7.wb3s &= (~WBV_040);
391 fp->un.fmt7.wb2a = fp->un.fmt7.wb3a;
392 fp->un.fmt7.wb2d = fp->un.fmt7.wb3d;
395 fp->un.fmt7.wb3s = 0;
399 send_fault_sig(&fp->ptregs);
403 * called from sigreturn(), must ensure userspace code didn't
404 * manipulate exception frame to circumvent protection, then complete
406 * we just clear TM2 to turn it into an userspace access
408 asmlinkage void berr_040cleanup(struct frame *fp)
410 fp->un.fmt7.wb2s &= ~4;
411 fp->un.fmt7.wb3s &= ~4;
413 do_040writebacks(fp);
416 static inline void access_error040(struct frame *fp)
418 unsigned short ssw = fp->un.fmt7.ssw;
422 printk("ssw=%#x, fa=%#lx\n", ssw, fp->un.fmt7.faddr);
423 printk("wb1s=%#x, wb2s=%#x, wb3s=%#x\n", fp->un.fmt7.wb1s,
424 fp->un.fmt7.wb2s, fp->un.fmt7.wb3s);
425 printk ("wb2a=%lx, wb3a=%lx, wb2d=%lx, wb3d=%lx\n",
426 fp->un.fmt7.wb2a, fp->un.fmt7.wb3a,
427 fp->un.fmt7.wb2d, fp->un.fmt7.wb3d);
431 unsigned long addr = fp->un.fmt7.faddr;
432 unsigned long errorcode;
435 * The MMU status has to be determined AFTER the address
436 * has been corrected if there was a misaligned access (MA).
439 addr = (addr + 7) & -8;
441 /* MMU error, get the MMUSR info for this access */
442 mmusr = probe040(!(ssw & RW_040), addr, ssw);
444 printk("mmusr = %lx\n", mmusr);
447 if (!(mmusr & MMU_R_040)) {
448 /* clear the invalid atc entry */
449 __flush_tlb040_one(addr);
453 /* despite what documentation seems to say, RMW
454 * accesses have always both the LK and RW bits set */
455 if (!(ssw & RW_040) || (ssw & LK_040))
458 if (do_page_fault(&fp->ptregs, addr, errorcode)) {
460 printk("do_page_fault() !=0 \n");
462 if (user_mode(&fp->ptregs)){
463 /* delay writebacks after signal delivery */
465 printk(".. was usermode - return\n");
469 /* disable writeback into user space from kernel
470 * (if do_page_fault didn't fix the mapping,
471 * the writeback won't do good)
474 printk(".. disabling wb2\n");
476 if (fp->un.fmt7.wb2a == fp->un.fmt7.faddr)
477 fp->un.fmt7.wb2s &= ~WBV_040;
479 } else if (send_fault_sig(&fp->ptregs) > 0) {
480 printk("68040 access error, ssw=%x\n", ssw);
484 do_040writebacks(fp);
486 #endif /* CONFIG_M68040 */
488 #if defined(CONFIG_SUN3)
489 #include <asm/sun3mmu.h>
491 extern int mmu_emu_handle_fault (unsigned long, int, int);
493 /* sun3 version of bus_error030 */
495 static inline void bus_error030 (struct frame *fp)
497 unsigned char buserr_type = sun3_get_buserr ();
498 unsigned long addr, errorcode;
499 unsigned short ssw = fp->un.fmtb.ssw;
500 extern unsigned long _sun3_map_test_start, _sun3_map_test_end;
504 printk ("Instruction fault at %#010lx\n",
506 fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2
508 fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
510 printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
511 ssw & RW ? "read" : "write",
513 space_names[ssw & DFC], fp->ptregs.pc);
517 * Check if this page should be demand-mapped. This needs to go before
518 * the testing for a bad kernel-space access (demand-mapping applies
519 * to kernel accesses too).
523 && (buserr_type & (SUN3_BUSERR_PROTERR | SUN3_BUSERR_INVALID))) {
524 if (mmu_emu_handle_fault (fp->un.fmtb.daddr, ssw & RW, 0))
528 /* Check for kernel-space pagefault (BAD). */
529 if (fp->ptregs.sr & PS_S) {
530 /* kernel fault must be a data fault to user space */
531 if (! ((ssw & DF) && ((ssw & DFC) == USER_DATA))) {
532 // try checking the kernel mappings before surrender
533 if (mmu_emu_handle_fault (fp->un.fmtb.daddr, ssw & RW, 1))
535 /* instruction fault or kernel data fault! */
537 printk ("Instruction fault at %#010lx\n",
540 /* was this fault incurred testing bus mappings? */
541 if((fp->ptregs.pc >= (unsigned long)&_sun3_map_test_start) &&
542 (fp->ptregs.pc <= (unsigned long)&_sun3_map_test_end)) {
543 send_fault_sig(&fp->ptregs);
547 printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
548 ssw & RW ? "read" : "write",
550 space_names[ssw & DFC], fp->ptregs.pc);
552 printk ("BAD KERNEL BUSERR\n");
554 die_if_kernel("Oops", &fp->ptregs,0);
555 force_sig(SIGKILL, current);
560 if (!(ssw & (FC | FB)) && !(ssw & DF))
561 /* not an instruction fault or data fault! BAD */
562 panic ("USER BUSERR w/o instruction or data fault");
566 /* First handle the data fault, if any. */
568 addr = fp->un.fmtb.daddr;
570 // errorcode bit 0: 0 -> no page 1 -> protection fault
571 // errorcode bit 1: 0 -> read fault 1 -> write fault
573 // (buserr_type & SUN3_BUSERR_PROTERR) -> protection fault
574 // (buserr_type & SUN3_BUSERR_INVALID) -> invalid page fault
576 if (buserr_type & SUN3_BUSERR_PROTERR)
578 else if (buserr_type & SUN3_BUSERR_INVALID)
582 printk ("*** unexpected busfault type=%#04x\n", buserr_type);
583 printk ("invalid %s access at %#lx from pc %#lx\n",
584 !(ssw & RW) ? "write" : "read", addr,
587 die_if_kernel ("Oops", &fp->ptregs, buserr_type);
588 force_sig (SIGBUS, current);
592 //todo: wtf is RM bit? --m
593 if (!(ssw & RW) || ssw & RM)
596 /* Handle page fault. */
597 do_page_fault (&fp->ptregs, addr, errorcode);
599 /* Retry the data fault now. */
603 /* Now handle the instruction fault. */
605 /* Get the fault address. */
606 if (fp->ptregs.format == 0xA)
607 addr = fp->ptregs.pc + 4;
609 addr = fp->un.fmtb.baddr;
613 if (buserr_type & SUN3_BUSERR_INVALID) {
614 if (!mmu_emu_handle_fault (fp->un.fmtb.daddr, 1, 0))
615 do_page_fault (&fp->ptregs, addr, 0);
618 printk ("protection fault on insn access (segv).\n");
620 force_sig (SIGSEGV, current);
624 #if defined(CPU_M68020_OR_M68030)
625 static inline void bus_error030 (struct frame *fp)
627 volatile unsigned short temp;
628 unsigned short mmusr;
629 unsigned long addr, errorcode;
630 unsigned short ssw = fp->un.fmtb.ssw;
634 printk ("pid = %x ", current->pid);
635 printk ("SSW=%#06x ", ssw);
638 printk ("Instruction fault at %#010lx\n",
640 fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2
642 fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
644 printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
645 ssw & RW ? "read" : "write",
647 space_names[ssw & DFC], fp->ptregs.pc);
650 /* ++andreas: If a data fault and an instruction fault happen
651 at the same time map in both pages. */
653 /* First handle the data fault, if any. */
655 addr = fp->un.fmtb.daddr;
658 asm volatile ("ptestr %3,%2@,#7,%0\n\t"
661 : "a" (&temp), "a" (addr), "d" (ssw));
663 asm volatile ("ptestr %2,%1@,#7\n\t"
665 : : "a" (&temp), "a" (addr), "d" (ssw));
670 printk("mmusr is %#x for addr %#lx in task %p\n",
671 mmusr, addr, current);
672 printk("descriptor address is %#lx, contents %#lx\n",
673 __va(desc), *(unsigned long *)__va(desc));
676 errorcode = (mmusr & MMU_I) ? 0 : 1;
677 if (!(ssw & RW) || (ssw & RM))
680 if (mmusr & (MMU_I | MMU_WP)) {
682 printk("Data %s fault at %#010lx in %s (pc=%#lx)\n",
683 ssw & RW ? "read" : "write",
685 space_names[ssw & DFC], fp->ptregs.pc);
688 /* Don't try to do anything further if an exception was
690 if (do_page_fault (&fp->ptregs, addr, errorcode) < 0)
692 } else if (!(mmusr & MMU_I)) {
693 /* probably a 020 cas fault */
694 if (!(ssw & RM) && send_fault_sig(&fp->ptregs) > 0)
695 printk("unexpected bus error (%#x,%#x)\n", ssw, mmusr);
696 } else if (mmusr & (MMU_B|MMU_L|MMU_S)) {
697 printk("invalid %s access at %#lx from pc %#lx\n",
698 !(ssw & RW) ? "write" : "read", addr,
700 die_if_kernel("Oops",&fp->ptregs,mmusr);
701 force_sig(SIGSEGV, current);
705 static volatile long tlong;
708 printk("weird %s access at %#lx from pc %#lx (ssw is %#x)\n",
709 !(ssw & RW) ? "write" : "read", addr,
711 asm volatile ("ptestr #1,%1@,#0\n\t"
714 : "a" (&temp), "a" (addr));
717 printk ("level 0 mmusr is %#x\n", mmusr);
719 asm volatile ("pmove %%tt0,%0@"
722 printk("tt0 is %#lx, ", tlong);
723 asm volatile ("pmove %%tt1,%0@"
726 printk("tt1 is %#lx\n", tlong);
729 printk("Unknown SIGSEGV - 1\n");
731 die_if_kernel("Oops",&fp->ptregs,mmusr);
732 force_sig(SIGSEGV, current);
736 /* setup an ATC entry for the access about to be retried */
737 if (!(ssw & RW) || (ssw & RM))
738 asm volatile ("ploadw %1,%0@" : /* no outputs */
739 : "a" (addr), "d" (ssw));
741 asm volatile ("ploadr %1,%0@" : /* no outputs */
742 : "a" (addr), "d" (ssw));
745 /* Now handle the instruction fault. */
747 if (!(ssw & (FC|FB)))
750 if (fp->ptregs.sr & PS_S) {
751 printk("Instruction fault at %#010lx\n",
754 printk ("BAD KERNEL BUSERR\n");
755 die_if_kernel("Oops",&fp->ptregs,0);
756 force_sig(SIGKILL, current);
760 /* get the fault address */
761 if (fp->ptregs.format == 10)
762 addr = fp->ptregs.pc + 4;
764 addr = fp->un.fmtb.baddr;
768 if ((ssw & DF) && ((addr ^ fp->un.fmtb.daddr) & PAGE_MASK) == 0)
769 /* Insn fault on same page as data fault. But we
770 should still create the ATC entry. */
771 goto create_atc_entry;
774 asm volatile ("ptestr #1,%2@,#7,%0\n\t"
777 : "a" (&temp), "a" (addr));
779 asm volatile ("ptestr #1,%1@,#7\n\t"
781 : : "a" (&temp), "a" (addr));
786 printk ("mmusr is %#x for addr %#lx in task %p\n",
787 mmusr, addr, current);
788 printk ("descriptor address is %#lx, contents %#lx\n",
789 __va(desc), *(unsigned long *)__va(desc));
793 do_page_fault (&fp->ptregs, addr, 0);
794 else if (mmusr & (MMU_B|MMU_L|MMU_S)) {
795 printk ("invalid insn access at %#lx from pc %#lx\n",
796 addr, fp->ptregs.pc);
798 printk("Unknown SIGSEGV - 2\n");
800 die_if_kernel("Oops",&fp->ptregs,mmusr);
801 force_sig(SIGSEGV, current);
806 /* setup an ATC entry for the access about to be retried */
807 asm volatile ("ploadr #2,%0@" : /* no outputs */
810 #endif /* CPU_M68020_OR_M68030 */
811 #endif /* !CONFIG_SUN3 */
813 asmlinkage void buserr_c(struct frame *fp)
815 /* Only set esp0 if coming from user mode */
816 if (user_mode(&fp->ptregs))
817 current->thread.esp0 = (unsigned long) fp;
820 printk ("*** Bus Error *** Format is %x\n", fp->ptregs.format);
823 switch (fp->ptregs.format) {
824 #if defined (CONFIG_M68060)
825 case 4: /* 68060 access error */
826 access_error060 (fp);
829 #if defined (CONFIG_M68040)
830 case 0x7: /* 68040 access error */
831 access_error040 (fp);
834 #if defined (CPU_M68020_OR_M68030)
841 die_if_kernel("bad frame format",&fp->ptregs,0);
843 printk("Unknown SIGSEGV - 4\n");
845 force_sig(SIGSEGV, current);
850 static int kstack_depth_to_print = 48;
852 void show_trace(unsigned long *stack)
854 unsigned long *endstack;
858 printk("Call Trace:");
859 addr = (unsigned long)stack + THREAD_SIZE - 1;
860 endstack = (unsigned long *)(addr & -THREAD_SIZE);
862 while (stack + 1 <= endstack) {
865 * If the address is either in the text segment of the
866 * kernel, or in the region which contains vmalloc'ed
867 * memory, it *may* be the address of a calling
868 * routine; if so, print it so that someone tracing
869 * down the cause of the crash will be able to figure
870 * out the call path that was taken.
872 if (__kernel_text_address(addr)) {
873 #ifndef CONFIG_KALLSYMS
877 printk(" [<%08lx>]", addr);
878 print_symbol(" %s\n", addr);
885 void show_registers(struct pt_regs *regs)
887 struct frame *fp = (struct frame *)regs;
888 mm_segment_t old_fs = get_fs();
894 printk("PC: [<%08lx>]",regs->pc);
895 print_symbol(" %s", regs->pc);
896 printk("\nSR: %04x SP: %p a2: %08lx\n",
897 regs->sr, regs, regs->a2);
898 printk("d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n",
899 regs->d0, regs->d1, regs->d2, regs->d3);
900 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
901 regs->d4, regs->d5, regs->a0, regs->a1);
903 printk("Process %s (pid: %d, task=%p)\n",
904 current->comm, current->pid, current);
905 addr = (unsigned long)&fp->un;
906 printk("Frame format=%X ", regs->format);
907 switch (regs->format) {
909 printk("instr addr=%08lx\n", fp->un.fmt2.iaddr);
910 addr += sizeof(fp->un.fmt2);
913 printk("eff addr=%08lx\n", fp->un.fmt3.effaddr);
914 addr += sizeof(fp->un.fmt3);
917 printk((CPU_IS_060 ? "fault addr=%08lx fslw=%08lx\n"
918 : "eff addr=%08lx pc=%08lx\n"),
919 fp->un.fmt4.effaddr, fp->un.fmt4.pc);
920 addr += sizeof(fp->un.fmt4);
923 printk("eff addr=%08lx ssw=%04x faddr=%08lx\n",
924 fp->un.fmt7.effaddr, fp->un.fmt7.ssw, fp->un.fmt7.faddr);
925 printk("wb 1 stat/addr/data: %04x %08lx %08lx\n",
926 fp->un.fmt7.wb1s, fp->un.fmt7.wb1a, fp->un.fmt7.wb1dpd0);
927 printk("wb 2 stat/addr/data: %04x %08lx %08lx\n",
928 fp->un.fmt7.wb2s, fp->un.fmt7.wb2a, fp->un.fmt7.wb2d);
929 printk("wb 3 stat/addr/data: %04x %08lx %08lx\n",
930 fp->un.fmt7.wb3s, fp->un.fmt7.wb3a, fp->un.fmt7.wb3d);
931 printk("push data: %08lx %08lx %08lx %08lx\n",
932 fp->un.fmt7.wb1dpd0, fp->un.fmt7.pd1, fp->un.fmt7.pd2,
934 addr += sizeof(fp->un.fmt7);
937 printk("instr addr=%08lx\n", fp->un.fmt9.iaddr);
938 addr += sizeof(fp->un.fmt9);
941 printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
942 fp->un.fmta.ssw, fp->un.fmta.isc, fp->un.fmta.isb,
943 fp->un.fmta.daddr, fp->un.fmta.dobuf);
944 addr += sizeof(fp->un.fmta);
947 printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
948 fp->un.fmtb.ssw, fp->un.fmtb.isc, fp->un.fmtb.isb,
949 fp->un.fmtb.daddr, fp->un.fmtb.dobuf);
950 printk("baddr=%08lx dibuf=%08lx ver=%x\n",
951 fp->un.fmtb.baddr, fp->un.fmtb.dibuf, fp->un.fmtb.ver);
952 addr += sizeof(fp->un.fmtb);
957 show_stack(NULL, (unsigned long *)addr);
961 cp = (u16 *)regs->pc;
962 for (i = -8; i < 16; i++) {
963 if (get_user(c, cp + i) && i >= 0) {
964 printk(" Bad PC value.");
967 printk(i ? " %04x" : " <%04x>", c);
973 void show_stack(struct task_struct *task, unsigned long *stack)
976 unsigned long *endstack;
981 stack = (unsigned long *)task->thread.esp0;
983 stack = (unsigned long *)&stack;
985 endstack = (unsigned long *)(((unsigned long)stack + THREAD_SIZE - 1) & -THREAD_SIZE);
987 printk("Stack from %08lx:", (unsigned long)stack);
989 for (i = 0; i < kstack_depth_to_print; i++) {
990 if (p + 1 > endstack)
994 printk(" %08lx", *p++);
1001 * The architecture-independent backtrace generator
1003 void dump_stack(void)
1005 unsigned long stack;
1010 EXPORT_SYMBOL(dump_stack);
1012 void bad_super_trap (struct frame *fp)
1015 if (fp->ptregs.vector < 4*sizeof(vec_names)/sizeof(vec_names[0]))
1016 printk ("*** %s *** FORMAT=%X\n",
1017 vec_names[(fp->ptregs.vector) >> 2],
1020 printk ("*** Exception %d *** FORMAT=%X\n",
1021 (fp->ptregs.vector) >> 2,
1023 if (fp->ptregs.vector >> 2 == VEC_ADDRERR && CPU_IS_020_OR_030) {
1024 unsigned short ssw = fp->un.fmtb.ssw;
1026 printk ("SSW=%#06x ", ssw);
1029 printk ("Pipe stage C instruction fault at %#010lx\n",
1030 (fp->ptregs.format) == 0xA ?
1031 fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2);
1033 printk ("Pipe stage B instruction fault at %#010lx\n",
1034 (fp->ptregs.format) == 0xA ?
1035 fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
1037 printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
1038 ssw & RW ? "read" : "write",
1039 fp->un.fmtb.daddr, space_names[ssw & DFC],
1042 printk ("Current process id is %d\n", current->pid);
1043 die_if_kernel("BAD KERNEL TRAP", &fp->ptregs, 0);
1046 asmlinkage void trap_c(struct frame *fp)
1051 if (fp->ptregs.sr & PS_S) {
1052 if ((fp->ptregs.vector >> 2) == VEC_TRACE) {
1053 /* traced a trapping instruction */
1054 current->ptrace |= PT_DTRACE;
1060 /* send the appropriate signal to the user program */
1061 switch ((fp->ptregs.vector) >> 2) {
1063 info.si_code = BUS_ADRALN;
1069 info.si_code = ILL_ILLOPC;
1073 info.si_code = ILL_PRVOPC;
1077 info.si_code = ILL_COPROC;
1094 info.si_code = ILL_ILLTRP;
1100 info.si_code = FPE_FLTINV;
1104 info.si_code = FPE_FLTRES;
1108 info.si_code = FPE_FLTDIV;
1112 info.si_code = FPE_FLTUND;
1116 info.si_code = FPE_FLTOVF;
1120 info.si_code = FPE_INTDIV;
1125 info.si_code = FPE_INTOVF;
1128 case VEC_TRACE: /* ptrace single step */
1129 info.si_code = TRAP_TRACE;
1132 case VEC_TRAP15: /* breakpoint */
1133 info.si_code = TRAP_BRKPT;
1137 info.si_code = ILL_ILLOPC;
1141 info.si_signo = sig;
1143 switch (fp->ptregs.format) {
1145 info.si_addr = (void *) fp->ptregs.pc;
1148 info.si_addr = (void *) fp->un.fmt2.iaddr;
1151 info.si_addr = (void *) fp->un.fmt7.effaddr;
1154 info.si_addr = (void *) fp->un.fmt9.iaddr;
1157 info.si_addr = (void *) fp->un.fmta.daddr;
1160 info.si_addr = (void *) fp->un.fmtb.daddr;
1163 force_sig_info (sig, &info, current);
1166 void die_if_kernel (char *str, struct pt_regs *fp, int nr)
1168 if (!(fp->sr & PS_S))
1172 printk("%s: %08x\n",str,nr);
1178 * This function is called if an error occur while accessing
1179 * user-space from the fpsp040 code.
1181 asmlinkage void fpsp040_die(void)
1186 #ifdef CONFIG_M68KFPU_EMU
1187 asmlinkage void fpemu_signal(int signal, int code, void *addr)
1191 info.si_signo = signal;
1193 info.si_code = code;
1194 info.si_addr = addr;
1195 force_sig_info(signal, &info, current);