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/sched.h>
22 #include <linux/signal.h>
23 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/a.out.h>
27 #include <linux/user.h>
28 #include <linux/string.h>
29 #include <linux/linkage.h>
30 #include <linux/init.h>
31 #include <linux/ptrace.h>
32 #include <linux/kallsyms.h>
34 #include <asm/setup.h>
36 #include <asm/system.h>
37 #include <asm/uaccess.h>
38 #include <asm/traps.h>
39 #include <asm/pgalloc.h>
40 #include <asm/machdep.h>
41 #include <asm/siginfo.h>
43 /* assembler routines */
44 asmlinkage void system_call(void);
45 asmlinkage void buserr(void);
46 asmlinkage void trap(void);
47 asmlinkage void nmihandler(void);
48 #ifdef CONFIG_M68KFPU_EMU
49 asmlinkage void fpu_emu(void);
52 e_vector vectors[256] = {
53 [VEC_BUSERR] = buserr,
54 [VEC_SYS] = system_call,
57 /* nmi handler for the Amiga */
63 * this must be called very early as the kernel might
64 * use some instruction that are emulated on the 060
66 void __init base_trap_init(void)
69 extern e_vector *sun3x_prom_vbr;
71 __asm__ volatile ("movec %%vbr, %0" : "=r" (sun3x_prom_vbr));
74 /* setup the exception vector table */
75 __asm__ volatile ("movec %0,%%vbr" : : "r" ((void*)vectors));
78 /* set up ISP entry points */
79 asmlinkage void unimp_vec(void) asm ("_060_isp_unimp");
81 vectors[VEC_UNIMPII] = unimp_vec;
85 void __init trap_init (void)
89 for (i = VEC_SPUR; i <= VEC_INT7; i++)
90 vectors[i] = bad_inthandler;
92 for (i = 0; i < VEC_USER; i++)
96 for (i = VEC_USER; i < 256; i++)
97 vectors[i] = bad_inthandler;
99 #ifdef CONFIG_M68KFPU_EMU
101 vectors[VEC_LINE11] = fpu_emu;
104 if (CPU_IS_040 && !FPU_IS_EMU) {
105 /* set up FPSP entry points */
106 asmlinkage void dz_vec(void) asm ("dz");
107 asmlinkage void inex_vec(void) asm ("inex");
108 asmlinkage void ovfl_vec(void) asm ("ovfl");
109 asmlinkage void unfl_vec(void) asm ("unfl");
110 asmlinkage void snan_vec(void) asm ("snan");
111 asmlinkage void operr_vec(void) asm ("operr");
112 asmlinkage void bsun_vec(void) asm ("bsun");
113 asmlinkage void fline_vec(void) asm ("fline");
114 asmlinkage void unsupp_vec(void) asm ("unsupp");
116 vectors[VEC_FPDIVZ] = dz_vec;
117 vectors[VEC_FPIR] = inex_vec;
118 vectors[VEC_FPOVER] = ovfl_vec;
119 vectors[VEC_FPUNDER] = unfl_vec;
120 vectors[VEC_FPNAN] = snan_vec;
121 vectors[VEC_FPOE] = operr_vec;
122 vectors[VEC_FPBRUC] = bsun_vec;
123 vectors[VEC_LINE11] = fline_vec;
124 vectors[VEC_FPUNSUP] = unsupp_vec;
127 if (CPU_IS_060 && !FPU_IS_EMU) {
128 /* set up IFPSP entry points */
129 asmlinkage void snan_vec6(void) asm ("_060_fpsp_snan");
130 asmlinkage void operr_vec6(void) asm ("_060_fpsp_operr");
131 asmlinkage void ovfl_vec6(void) asm ("_060_fpsp_ovfl");
132 asmlinkage void unfl_vec6(void) asm ("_060_fpsp_unfl");
133 asmlinkage void dz_vec6(void) asm ("_060_fpsp_dz");
134 asmlinkage void inex_vec6(void) asm ("_060_fpsp_inex");
135 asmlinkage void fline_vec6(void) asm ("_060_fpsp_fline");
136 asmlinkage void unsupp_vec6(void) asm ("_060_fpsp_unsupp");
137 asmlinkage void effadd_vec6(void) asm ("_060_fpsp_effadd");
139 vectors[VEC_FPNAN] = snan_vec6;
140 vectors[VEC_FPOE] = operr_vec6;
141 vectors[VEC_FPOVER] = ovfl_vec6;
142 vectors[VEC_FPUNDER] = unfl_vec6;
143 vectors[VEC_FPDIVZ] = dz_vec6;
144 vectors[VEC_FPIR] = inex_vec6;
145 vectors[VEC_LINE11] = fline_vec6;
146 vectors[VEC_FPUNSUP] = unsupp_vec6;
147 vectors[VEC_UNIMPEA] = effadd_vec6;
150 /* if running on an amiga, make the NMI interrupt do nothing */
152 vectors[VEC_INT7] = nmihandler;
157 static const char *vec_names[] = {
158 [VEC_RESETSP] = "RESET SP",
159 [VEC_RESETPC] = "RESET PC",
160 [VEC_BUSERR] = "BUS ERROR",
161 [VEC_ADDRERR] = "ADDRESS ERROR",
162 [VEC_ILLEGAL] = "ILLEGAL INSTRUCTION",
163 [VEC_ZERODIV] = "ZERO DIVIDE",
165 [VEC_TRAP] = "TRAPcc",
166 [VEC_PRIV] = "PRIVILEGE VIOLATION",
167 [VEC_TRACE] = "TRACE",
168 [VEC_LINE10] = "LINE 1010",
169 [VEC_LINE11] = "LINE 1111",
170 [VEC_RESV12] = "UNASSIGNED RESERVED 12",
171 [VEC_COPROC] = "COPROCESSOR PROTOCOL VIOLATION",
172 [VEC_FORMAT] = "FORMAT ERROR",
173 [VEC_UNINT] = "UNINITIALIZED INTERRUPT",
174 [VEC_RESV16] = "UNASSIGNED RESERVED 16",
175 [VEC_RESV17] = "UNASSIGNED RESERVED 17",
176 [VEC_RESV18] = "UNASSIGNED RESERVED 18",
177 [VEC_RESV19] = "UNASSIGNED RESERVED 19",
178 [VEC_RESV20] = "UNASSIGNED RESERVED 20",
179 [VEC_RESV21] = "UNASSIGNED RESERVED 21",
180 [VEC_RESV22] = "UNASSIGNED RESERVED 22",
181 [VEC_RESV23] = "UNASSIGNED RESERVED 23",
182 [VEC_SPUR] = "SPURIOUS INTERRUPT",
183 [VEC_INT1] = "LEVEL 1 INT",
184 [VEC_INT2] = "LEVEL 2 INT",
185 [VEC_INT3] = "LEVEL 3 INT",
186 [VEC_INT4] = "LEVEL 4 INT",
187 [VEC_INT5] = "LEVEL 5 INT",
188 [VEC_INT6] = "LEVEL 6 INT",
189 [VEC_INT7] = "LEVEL 7 INT",
190 [VEC_SYS] = "SYSCALL",
191 [VEC_TRAP1] = "TRAP #1",
192 [VEC_TRAP2] = "TRAP #2",
193 [VEC_TRAP3] = "TRAP #3",
194 [VEC_TRAP4] = "TRAP #4",
195 [VEC_TRAP5] = "TRAP #5",
196 [VEC_TRAP6] = "TRAP #6",
197 [VEC_TRAP7] = "TRAP #7",
198 [VEC_TRAP8] = "TRAP #8",
199 [VEC_TRAP9] = "TRAP #9",
200 [VEC_TRAP10] = "TRAP #10",
201 [VEC_TRAP11] = "TRAP #11",
202 [VEC_TRAP12] = "TRAP #12",
203 [VEC_TRAP13] = "TRAP #13",
204 [VEC_TRAP14] = "TRAP #14",
205 [VEC_TRAP15] = "TRAP #15",
206 [VEC_FPBRUC] = "FPCP BSUN",
207 [VEC_FPIR] = "FPCP INEXACT",
208 [VEC_FPDIVZ] = "FPCP DIV BY 0",
209 [VEC_FPUNDER] = "FPCP UNDERFLOW",
210 [VEC_FPOE] = "FPCP OPERAND ERROR",
211 [VEC_FPOVER] = "FPCP OVERFLOW",
212 [VEC_FPNAN] = "FPCP SNAN",
213 [VEC_FPUNSUP] = "FPCP UNSUPPORTED OPERATION",
214 [VEC_MMUCFG] = "MMU CONFIGURATION ERROR",
215 [VEC_MMUILL] = "MMU ILLEGAL OPERATION ERROR",
216 [VEC_MMUACC] = "MMU ACCESS LEVEL VIOLATION ERROR",
217 [VEC_RESV59] = "UNASSIGNED RESERVED 59",
218 [VEC_UNIMPEA] = "UNASSIGNED RESERVED 60",
219 [VEC_UNIMPII] = "UNASSIGNED RESERVED 61",
220 [VEC_RESV62] = "UNASSIGNED RESERVED 62",
221 [VEC_RESV63] = "UNASSIGNED RESERVED 63",
224 static const char *space_names[] = {
226 [USER_DATA] = "User Data",
227 [USER_PROGRAM] = "User Program",
231 [FC_CONTROL] = "Control",
234 [SUPER_DATA] = "Super Data",
235 [SUPER_PROGRAM] = "Super Program",
239 void die_if_kernel(char *,struct pt_regs *,int);
240 asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address,
241 unsigned long error_code);
242 int send_fault_sig(struct pt_regs *regs);
244 asmlinkage void trap_c(struct frame *fp);
246 #if defined (CONFIG_M68060)
247 static inline void access_error060 (struct frame *fp)
249 unsigned long fslw = fp->un.fmt4.pc; /* is really FSLW for access error */
252 printk("fslw=%#lx, fa=%#lx\n", fslw, fp->un.fmt4.effaddr);
255 if (fslw & MMU060_BPE) {
256 /* branch prediction error -> clear branch cache */
257 __asm__ __volatile__ ("movec %/cacr,%/d0\n\t"
258 "orl #0x00400000,%/d0\n\t"
261 /* return if there's no other error */
262 if (!(fslw & MMU060_ERR_BITS) && !(fslw & MMU060_SEE))
266 if (fslw & (MMU060_DESC_ERR | MMU060_WP | MMU060_SP)) {
267 unsigned long errorcode;
268 unsigned long addr = fp->un.fmt4.effaddr;
270 if (fslw & MMU060_MA)
271 addr = (addr + PAGE_SIZE - 1) & PAGE_MASK;
274 if (fslw & MMU060_DESC_ERR) {
275 __flush_tlb040_one(addr);
281 printk("errorcode = %d\n", errorcode );
283 do_page_fault(&fp->ptregs, addr, errorcode);
284 } else if (fslw & (MMU060_SEE)){
285 /* Software Emulation Error.
286 * fault during mem_read/mem_write in ifpsp060/os.S
288 send_fault_sig(&fp->ptregs);
289 } else if (!(fslw & (MMU060_RE|MMU060_WE)) ||
290 send_fault_sig(&fp->ptregs) > 0) {
291 printk("pc=%#lx, fa=%#lx\n", fp->ptregs.pc, fp->un.fmt4.effaddr);
292 printk( "68060 access error, fslw=%lx\n", fslw );
296 #endif /* CONFIG_M68060 */
298 #if defined (CONFIG_M68040)
299 static inline unsigned long probe040(int iswrite, unsigned long addr, int wbs)
302 mm_segment_t old_fs = get_fs();
304 set_fs(MAKE_MM_SEG(wbs));
307 asm volatile (".chip 68040; ptestw (%0); .chip 68k" : : "a" (addr));
309 asm volatile (".chip 68040; ptestr (%0); .chip 68k" : : "a" (addr));
311 asm volatile (".chip 68040; movec %%mmusr,%0; .chip 68k" : "=r" (mmusr));
318 static inline int do_040writeback1(unsigned short wbs, unsigned long wba,
322 mm_segment_t old_fs = get_fs();
324 /* set_fs can not be moved, otherwise put_user() may oops */
325 set_fs(MAKE_MM_SEG(wbs));
327 switch (wbs & WBSIZ_040) {
329 res = put_user(wbd & 0xff, (char __user *)wba);
332 res = put_user(wbd & 0xffff, (short __user *)wba);
335 res = put_user(wbd, (int __user *)wba);
339 /* set_fs can not be moved, otherwise put_user() may oops */
344 printk("do_040writeback1, res=%d\n",res);
350 /* after an exception in a writeback the stack frame corresponding
351 * to that exception is discarded, set a few bits in the old frame
352 * to simulate what it should look like
354 static inline void fix_xframe040(struct frame *fp, unsigned long wba, unsigned short wbs)
356 fp->un.fmt7.faddr = wba;
357 fp->un.fmt7.ssw = wbs & 0xff;
358 if (wba != current->thread.faddr)
359 fp->un.fmt7.ssw |= MA_040;
362 static inline void do_040writebacks(struct frame *fp)
366 if (fp->un.fmt7.wb1s & WBV_040)
367 printk("access_error040: cannot handle 1st writeback. oops.\n");
370 if ((fp->un.fmt7.wb2s & WBV_040) &&
371 !(fp->un.fmt7.wb2s & WBTT_040)) {
372 res = do_040writeback1(fp->un.fmt7.wb2s, fp->un.fmt7.wb2a,
375 fix_xframe040(fp, fp->un.fmt7.wb2a, fp->un.fmt7.wb2s);
377 fp->un.fmt7.wb2s = 0;
380 /* do the 2nd wb only if the first one was successful (except for a kernel wb) */
381 if (fp->un.fmt7.wb3s & WBV_040 && (!res || fp->un.fmt7.wb3s & 4)) {
382 res = do_040writeback1(fp->un.fmt7.wb3s, fp->un.fmt7.wb3a,
386 fix_xframe040(fp, fp->un.fmt7.wb3a, fp->un.fmt7.wb3s);
388 fp->un.fmt7.wb2s = fp->un.fmt7.wb3s;
389 fp->un.fmt7.wb3s &= (~WBV_040);
390 fp->un.fmt7.wb2a = fp->un.fmt7.wb3a;
391 fp->un.fmt7.wb2d = fp->un.fmt7.wb3d;
394 fp->un.fmt7.wb3s = 0;
398 send_fault_sig(&fp->ptregs);
402 * called from sigreturn(), must ensure userspace code didn't
403 * manipulate exception frame to circumvent protection, then complete
405 * we just clear TM2 to turn it into an userspace access
407 asmlinkage void berr_040cleanup(struct frame *fp)
409 fp->un.fmt7.wb2s &= ~4;
410 fp->un.fmt7.wb3s &= ~4;
412 do_040writebacks(fp);
415 static inline void access_error040(struct frame *fp)
417 unsigned short ssw = fp->un.fmt7.ssw;
421 printk("ssw=%#x, fa=%#lx\n", ssw, fp->un.fmt7.faddr);
422 printk("wb1s=%#x, wb2s=%#x, wb3s=%#x\n", fp->un.fmt7.wb1s,
423 fp->un.fmt7.wb2s, fp->un.fmt7.wb3s);
424 printk ("wb2a=%lx, wb3a=%lx, wb2d=%lx, wb3d=%lx\n",
425 fp->un.fmt7.wb2a, fp->un.fmt7.wb3a,
426 fp->un.fmt7.wb2d, fp->un.fmt7.wb3d);
430 unsigned long addr = fp->un.fmt7.faddr;
431 unsigned long errorcode;
434 * The MMU status has to be determined AFTER the address
435 * has been corrected if there was a misaligned access (MA).
438 addr = (addr + 7) & -8;
440 /* MMU error, get the MMUSR info for this access */
441 mmusr = probe040(!(ssw & RW_040), addr, ssw);
443 printk("mmusr = %lx\n", mmusr);
446 if (!(mmusr & MMU_R_040)) {
447 /* clear the invalid atc entry */
448 __flush_tlb040_one(addr);
452 /* despite what documentation seems to say, RMW
453 * accesses have always both the LK and RW bits set */
454 if (!(ssw & RW_040) || (ssw & LK_040))
457 if (do_page_fault(&fp->ptregs, addr, errorcode)) {
459 printk("do_page_fault() !=0 \n");
461 if (user_mode(&fp->ptregs)){
462 /* delay writebacks after signal delivery */
464 printk(".. was usermode - return\n");
468 /* disable writeback into user space from kernel
469 * (if do_page_fault didn't fix the mapping,
470 * the writeback won't do good)
473 printk(".. disabling wb2\n");
475 if (fp->un.fmt7.wb2a == fp->un.fmt7.faddr)
476 fp->un.fmt7.wb2s &= ~WBV_040;
478 } else if (send_fault_sig(&fp->ptregs) > 0) {
479 printk("68040 access error, ssw=%x\n", ssw);
483 do_040writebacks(fp);
485 #endif /* CONFIG_M68040 */
487 #if defined(CONFIG_SUN3)
488 #include <asm/sun3mmu.h>
490 extern int mmu_emu_handle_fault (unsigned long, int, int);
492 /* sun3 version of bus_error030 */
494 static inline void bus_error030 (struct frame *fp)
496 unsigned char buserr_type = sun3_get_buserr ();
497 unsigned long addr, errorcode;
498 unsigned short ssw = fp->un.fmtb.ssw;
499 extern unsigned long _sun3_map_test_start, _sun3_map_test_end;
503 printk ("Instruction fault at %#010lx\n",
505 fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2
507 fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
509 printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
510 ssw & RW ? "read" : "write",
512 space_names[ssw & DFC], fp->ptregs.pc);
516 * Check if this page should be demand-mapped. This needs to go before
517 * the testing for a bad kernel-space access (demand-mapping applies
518 * to kernel accesses too).
522 && (buserr_type & (SUN3_BUSERR_PROTERR | SUN3_BUSERR_INVALID))) {
523 if (mmu_emu_handle_fault (fp->un.fmtb.daddr, ssw & RW, 0))
527 /* Check for kernel-space pagefault (BAD). */
528 if (fp->ptregs.sr & PS_S) {
529 /* kernel fault must be a data fault to user space */
530 if (! ((ssw & DF) && ((ssw & DFC) == USER_DATA))) {
531 // try checking the kernel mappings before surrender
532 if (mmu_emu_handle_fault (fp->un.fmtb.daddr, ssw & RW, 1))
534 /* instruction fault or kernel data fault! */
536 printk ("Instruction fault at %#010lx\n",
539 /* was this fault incurred testing bus mappings? */
540 if((fp->ptregs.pc >= (unsigned long)&_sun3_map_test_start) &&
541 (fp->ptregs.pc <= (unsigned long)&_sun3_map_test_end)) {
542 send_fault_sig(&fp->ptregs);
546 printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
547 ssw & RW ? "read" : "write",
549 space_names[ssw & DFC], fp->ptregs.pc);
551 printk ("BAD KERNEL BUSERR\n");
553 die_if_kernel("Oops", &fp->ptregs,0);
554 force_sig(SIGKILL, current);
559 if (!(ssw & (FC | FB)) && !(ssw & DF))
560 /* not an instruction fault or data fault! BAD */
561 panic ("USER BUSERR w/o instruction or data fault");
565 /* First handle the data fault, if any. */
567 addr = fp->un.fmtb.daddr;
569 // errorcode bit 0: 0 -> no page 1 -> protection fault
570 // errorcode bit 1: 0 -> read fault 1 -> write fault
572 // (buserr_type & SUN3_BUSERR_PROTERR) -> protection fault
573 // (buserr_type & SUN3_BUSERR_INVALID) -> invalid page fault
575 if (buserr_type & SUN3_BUSERR_PROTERR)
577 else if (buserr_type & SUN3_BUSERR_INVALID)
581 printk ("*** unexpected busfault type=%#04x\n", buserr_type);
582 printk ("invalid %s access at %#lx from pc %#lx\n",
583 !(ssw & RW) ? "write" : "read", addr,
586 die_if_kernel ("Oops", &fp->ptregs, buserr_type);
587 force_sig (SIGBUS, current);
591 //todo: wtf is RM bit? --m
592 if (!(ssw & RW) || ssw & RM)
595 /* Handle page fault. */
596 do_page_fault (&fp->ptregs, addr, errorcode);
598 /* Retry the data fault now. */
602 /* Now handle the instruction fault. */
604 /* Get the fault address. */
605 if (fp->ptregs.format == 0xA)
606 addr = fp->ptregs.pc + 4;
608 addr = fp->un.fmtb.baddr;
612 if (buserr_type & SUN3_BUSERR_INVALID) {
613 if (!mmu_emu_handle_fault (fp->un.fmtb.daddr, 1, 0))
614 do_page_fault (&fp->ptregs, addr, 0);
617 printk ("protection fault on insn access (segv).\n");
619 force_sig (SIGSEGV, current);
623 #if defined(CPU_M68020_OR_M68030)
624 static inline void bus_error030 (struct frame *fp)
626 volatile unsigned short temp;
627 unsigned short mmusr;
628 unsigned long addr, errorcode;
629 unsigned short ssw = fp->un.fmtb.ssw;
633 printk ("pid = %x ", current->pid);
634 printk ("SSW=%#06x ", ssw);
637 printk ("Instruction fault at %#010lx\n",
639 fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2
641 fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
643 printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
644 ssw & RW ? "read" : "write",
646 space_names[ssw & DFC], fp->ptregs.pc);
649 /* ++andreas: If a data fault and an instruction fault happen
650 at the same time map in both pages. */
652 /* First handle the data fault, if any. */
654 addr = fp->un.fmtb.daddr;
657 asm volatile ("ptestr %3,%2@,#7,%0\n\t"
660 : "a" (&temp), "a" (addr), "d" (ssw));
662 asm volatile ("ptestr %2,%1@,#7\n\t"
664 : : "a" (&temp), "a" (addr), "d" (ssw));
669 printk("mmusr is %#x for addr %#lx in task %p\n",
670 mmusr, addr, current);
671 printk("descriptor address is %#lx, contents %#lx\n",
672 __va(desc), *(unsigned long *)__va(desc));
675 errorcode = (mmusr & MMU_I) ? 0 : 1;
676 if (!(ssw & RW) || (ssw & RM))
679 if (mmusr & (MMU_I | MMU_WP)) {
681 printk("Data %s fault at %#010lx in %s (pc=%#lx)\n",
682 ssw & RW ? "read" : "write",
684 space_names[ssw & DFC], fp->ptregs.pc);
687 /* Don't try to do anything further if an exception was
689 if (do_page_fault (&fp->ptregs, addr, errorcode) < 0)
691 } else if (!(mmusr & MMU_I)) {
692 /* probably a 020 cas fault */
693 if (!(ssw & RM) && send_fault_sig(&fp->ptregs) > 0)
694 printk("unexpected bus error (%#x,%#x)\n", ssw, mmusr);
695 } else if (mmusr & (MMU_B|MMU_L|MMU_S)) {
696 printk("invalid %s access at %#lx from pc %#lx\n",
697 !(ssw & RW) ? "write" : "read", addr,
699 die_if_kernel("Oops",&fp->ptregs,mmusr);
700 force_sig(SIGSEGV, current);
704 static volatile long tlong;
707 printk("weird %s access at %#lx from pc %#lx (ssw is %#x)\n",
708 !(ssw & RW) ? "write" : "read", addr,
710 asm volatile ("ptestr #1,%1@,#0\n\t"
713 : "a" (&temp), "a" (addr));
716 printk ("level 0 mmusr is %#x\n", mmusr);
718 asm volatile ("pmove %%tt0,%0@"
721 printk("tt0 is %#lx, ", tlong);
722 asm volatile ("pmove %%tt1,%0@"
725 printk("tt1 is %#lx\n", tlong);
728 printk("Unknown SIGSEGV - 1\n");
730 die_if_kernel("Oops",&fp->ptregs,mmusr);
731 force_sig(SIGSEGV, current);
735 /* setup an ATC entry for the access about to be retried */
736 if (!(ssw & RW) || (ssw & RM))
737 asm volatile ("ploadw %1,%0@" : /* no outputs */
738 : "a" (addr), "d" (ssw));
740 asm volatile ("ploadr %1,%0@" : /* no outputs */
741 : "a" (addr), "d" (ssw));
744 /* Now handle the instruction fault. */
746 if (!(ssw & (FC|FB)))
749 if (fp->ptregs.sr & PS_S) {
750 printk("Instruction fault at %#010lx\n",
753 printk ("BAD KERNEL BUSERR\n");
754 die_if_kernel("Oops",&fp->ptregs,0);
755 force_sig(SIGKILL, current);
759 /* get the fault address */
760 if (fp->ptregs.format == 10)
761 addr = fp->ptregs.pc + 4;
763 addr = fp->un.fmtb.baddr;
767 if ((ssw & DF) && ((addr ^ fp->un.fmtb.daddr) & PAGE_MASK) == 0)
768 /* Insn fault on same page as data fault. But we
769 should still create the ATC entry. */
770 goto create_atc_entry;
773 asm volatile ("ptestr #1,%2@,#7,%0\n\t"
776 : "a" (&temp), "a" (addr));
778 asm volatile ("ptestr #1,%1@,#7\n\t"
780 : : "a" (&temp), "a" (addr));
785 printk ("mmusr is %#x for addr %#lx in task %p\n",
786 mmusr, addr, current);
787 printk ("descriptor address is %#lx, contents %#lx\n",
788 __va(desc), *(unsigned long *)__va(desc));
792 do_page_fault (&fp->ptregs, addr, 0);
793 else if (mmusr & (MMU_B|MMU_L|MMU_S)) {
794 printk ("invalid insn access at %#lx from pc %#lx\n",
795 addr, fp->ptregs.pc);
797 printk("Unknown SIGSEGV - 2\n");
799 die_if_kernel("Oops",&fp->ptregs,mmusr);
800 force_sig(SIGSEGV, current);
805 /* setup an ATC entry for the access about to be retried */
806 asm volatile ("ploadr #2,%0@" : /* no outputs */
809 #endif /* CPU_M68020_OR_M68030 */
810 #endif /* !CONFIG_SUN3 */
812 asmlinkage void buserr_c(struct frame *fp)
814 /* Only set esp0 if coming from user mode */
815 if (user_mode(&fp->ptregs))
816 current->thread.esp0 = (unsigned long) fp;
819 printk ("*** Bus Error *** Format is %x\n", fp->ptregs.format);
822 switch (fp->ptregs.format) {
823 #if defined (CONFIG_M68060)
824 case 4: /* 68060 access error */
825 access_error060 (fp);
828 #if defined (CONFIG_M68040)
829 case 0x7: /* 68040 access error */
830 access_error040 (fp);
833 #if defined (CPU_M68020_OR_M68030)
840 die_if_kernel("bad frame format",&fp->ptregs,0);
842 printk("Unknown SIGSEGV - 4\n");
844 force_sig(SIGSEGV, current);
849 static int kstack_depth_to_print = 48;
851 void show_trace(unsigned long *stack)
853 unsigned long *endstack;
857 printk("Call Trace:");
858 addr = (unsigned long)stack + THREAD_SIZE - 1;
859 endstack = (unsigned long *)(addr & -THREAD_SIZE);
861 while (stack + 1 <= endstack) {
864 * If the address is either in the text segment of the
865 * kernel, or in the region which contains vmalloc'ed
866 * memory, it *may* be the address of a calling
867 * routine; if so, print it so that someone tracing
868 * down the cause of the crash will be able to figure
869 * out the call path that was taken.
871 if (__kernel_text_address(addr)) {
872 #ifndef CONFIG_KALLSYMS
876 printk(" [<%08lx>]", addr);
877 print_symbol(" %s\n", addr);
884 void show_registers(struct pt_regs *regs)
886 struct frame *fp = (struct frame *)regs;
887 mm_segment_t old_fs = get_fs();
893 printk("PC: [<%08lx>]",regs->pc);
894 print_symbol(" %s", regs->pc);
895 printk("\nSR: %04x SP: %p a2: %08lx\n",
896 regs->sr, regs, regs->a2);
897 printk("d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n",
898 regs->d0, regs->d1, regs->d2, regs->d3);
899 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
900 regs->d4, regs->d5, regs->a0, regs->a1);
902 printk("Process %s (pid: %d, task=%p)\n",
903 current->comm, current->pid, current);
904 addr = (unsigned long)&fp->un;
905 printk("Frame format=%X ", regs->format);
906 switch (regs->format) {
908 printk("instr addr=%08lx\n", fp->un.fmt2.iaddr);
909 addr += sizeof(fp->un.fmt2);
912 printk("eff addr=%08lx\n", fp->un.fmt3.effaddr);
913 addr += sizeof(fp->un.fmt3);
916 printk((CPU_IS_060 ? "fault addr=%08lx fslw=%08lx\n"
917 : "eff addr=%08lx pc=%08lx\n"),
918 fp->un.fmt4.effaddr, fp->un.fmt4.pc);
919 addr += sizeof(fp->un.fmt4);
922 printk("eff addr=%08lx ssw=%04x faddr=%08lx\n",
923 fp->un.fmt7.effaddr, fp->un.fmt7.ssw, fp->un.fmt7.faddr);
924 printk("wb 1 stat/addr/data: %04x %08lx %08lx\n",
925 fp->un.fmt7.wb1s, fp->un.fmt7.wb1a, fp->un.fmt7.wb1dpd0);
926 printk("wb 2 stat/addr/data: %04x %08lx %08lx\n",
927 fp->un.fmt7.wb2s, fp->un.fmt7.wb2a, fp->un.fmt7.wb2d);
928 printk("wb 3 stat/addr/data: %04x %08lx %08lx\n",
929 fp->un.fmt7.wb3s, fp->un.fmt7.wb3a, fp->un.fmt7.wb3d);
930 printk("push data: %08lx %08lx %08lx %08lx\n",
931 fp->un.fmt7.wb1dpd0, fp->un.fmt7.pd1, fp->un.fmt7.pd2,
933 addr += sizeof(fp->un.fmt7);
936 printk("instr addr=%08lx\n", fp->un.fmt9.iaddr);
937 addr += sizeof(fp->un.fmt9);
940 printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
941 fp->un.fmta.ssw, fp->un.fmta.isc, fp->un.fmta.isb,
942 fp->un.fmta.daddr, fp->un.fmta.dobuf);
943 addr += sizeof(fp->un.fmta);
946 printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
947 fp->un.fmtb.ssw, fp->un.fmtb.isc, fp->un.fmtb.isb,
948 fp->un.fmtb.daddr, fp->un.fmtb.dobuf);
949 printk("baddr=%08lx dibuf=%08lx ver=%x\n",
950 fp->un.fmtb.baddr, fp->un.fmtb.dibuf, fp->un.fmtb.ver);
951 addr += sizeof(fp->un.fmtb);
956 show_stack(NULL, (unsigned long *)addr);
960 cp = (u16 *)regs->pc;
961 for (i = -8; i < 16; i++) {
962 if (get_user(c, cp + i) && i >= 0) {
963 printk(" Bad PC value.");
966 printk(i ? " %04x" : " <%04x>", c);
972 void show_stack(struct task_struct *task, unsigned long *stack)
975 unsigned long *endstack;
980 stack = (unsigned long *)task->thread.esp0;
982 stack = (unsigned long *)&stack;
984 endstack = (unsigned long *)(((unsigned long)stack + THREAD_SIZE - 1) & -THREAD_SIZE);
986 printk("Stack from %08lx:", (unsigned long)stack);
988 for (i = 0; i < kstack_depth_to_print; i++) {
989 if (p + 1 > endstack)
993 printk(" %08lx", *p++);
1000 * The architecture-independent backtrace generator
1002 void dump_stack(void)
1004 unsigned long stack;
1009 EXPORT_SYMBOL(dump_stack);
1011 void bad_super_trap (struct frame *fp)
1014 if (fp->ptregs.vector < 4 * ARRAY_SIZE(vec_names))
1015 printk ("*** %s *** FORMAT=%X\n",
1016 vec_names[(fp->ptregs.vector) >> 2],
1019 printk ("*** Exception %d *** FORMAT=%X\n",
1020 (fp->ptregs.vector) >> 2,
1022 if (fp->ptregs.vector >> 2 == VEC_ADDRERR && CPU_IS_020_OR_030) {
1023 unsigned short ssw = fp->un.fmtb.ssw;
1025 printk ("SSW=%#06x ", ssw);
1028 printk ("Pipe stage C instruction fault at %#010lx\n",
1029 (fp->ptregs.format) == 0xA ?
1030 fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2);
1032 printk ("Pipe stage B instruction fault at %#010lx\n",
1033 (fp->ptregs.format) == 0xA ?
1034 fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
1036 printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
1037 ssw & RW ? "read" : "write",
1038 fp->un.fmtb.daddr, space_names[ssw & DFC],
1041 printk ("Current process id is %d\n", current->pid);
1042 die_if_kernel("BAD KERNEL TRAP", &fp->ptregs, 0);
1045 asmlinkage void trap_c(struct frame *fp)
1050 if (fp->ptregs.sr & PS_S) {
1051 if ((fp->ptregs.vector >> 2) == VEC_TRACE) {
1052 /* traced a trapping instruction */
1053 current->ptrace |= PT_DTRACE;
1059 /* send the appropriate signal to the user program */
1060 switch ((fp->ptregs.vector) >> 2) {
1062 info.si_code = BUS_ADRALN;
1068 info.si_code = ILL_ILLOPC;
1072 info.si_code = ILL_PRVOPC;
1076 info.si_code = ILL_COPROC;
1093 info.si_code = ILL_ILLTRP;
1099 info.si_code = FPE_FLTINV;
1103 info.si_code = FPE_FLTRES;
1107 info.si_code = FPE_FLTDIV;
1111 info.si_code = FPE_FLTUND;
1115 info.si_code = FPE_FLTOVF;
1119 info.si_code = FPE_INTDIV;
1124 info.si_code = FPE_INTOVF;
1127 case VEC_TRACE: /* ptrace single step */
1128 info.si_code = TRAP_TRACE;
1131 case VEC_TRAP15: /* breakpoint */
1132 info.si_code = TRAP_BRKPT;
1136 info.si_code = ILL_ILLOPC;
1140 info.si_signo = sig;
1142 switch (fp->ptregs.format) {
1144 info.si_addr = (void *) fp->ptregs.pc;
1147 info.si_addr = (void *) fp->un.fmt2.iaddr;
1150 info.si_addr = (void *) fp->un.fmt7.effaddr;
1153 info.si_addr = (void *) fp->un.fmt9.iaddr;
1156 info.si_addr = (void *) fp->un.fmta.daddr;
1159 info.si_addr = (void *) fp->un.fmtb.daddr;
1162 force_sig_info (sig, &info, current);
1165 void die_if_kernel (char *str, struct pt_regs *fp, int nr)
1167 if (!(fp->sr & PS_S))
1171 printk("%s: %08x\n",str,nr);
1177 * This function is called if an error occur while accessing
1178 * user-space from the fpsp040 code.
1180 asmlinkage void fpsp040_die(void)
1185 #ifdef CONFIG_M68KFPU_EMU
1186 asmlinkage void fpemu_signal(int signal, int code, void *addr)
1190 info.si_signo = signal;
1192 info.si_code = code;
1193 info.si_addr = addr;
1194 force_sig_info(signal, &info, current);