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 inthandler(void);
49 asmlinkage
void nmihandler(void);
50 #ifdef CONFIG_M68KFPU_EMU
51 asmlinkage
void fpu_emu(void);
54 e_vector vectors
[256] = {
55 [VEC_BUSERR
] = buserr
,
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
,
103 /* nmi handler for the Amiga */
109 * this must be called very early as the kernel might
110 * use some instruction that are emulated on the 060
112 void __init
base_trap_init(void)
115 extern e_vector
*sun3x_prom_vbr
;
117 __asm__
volatile ("movec %%vbr, %0" : "=r" ((void*)sun3x_prom_vbr
));
120 /* setup the exception vector table */
121 __asm__
volatile ("movec %0,%%vbr" : : "r" ((void*)vectors
));
124 /* set up ISP entry points */
125 asmlinkage
void unimp_vec(void) asm ("_060_isp_unimp");
127 vectors
[VEC_UNIMPII
] = unimp_vec
;
131 void __init
trap_init (void)
135 for (i
= 48; i
< 64; i
++)
139 for (i
= 64; i
< 256; i
++)
140 vectors
[i
] = inthandler
;
142 #ifdef CONFIG_M68KFPU_EMU
144 vectors
[VEC_LINE11
] = fpu_emu
;
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");
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
;
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");
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
;
193 /* if running on an amiga, make the NMI interrupt do nothing */
195 vectors
[VEC_INT7
] = nmihandler
;
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",
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",
267 static const char *space_names
[] = {
269 [USER_DATA
] = "User Data",
270 [USER_PROGRAM
] = "User Program",
274 [FC_CONTROL
] = "Control",
277 [SUPER_DATA
] = "Super Data",
278 [SUPER_PROGRAM
] = "Super Program",
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
);
287 asmlinkage
void trap_c(struct frame
*fp
);
289 #if defined (CONFIG_M68060)
290 static inline void access_error060 (struct frame
*fp
)
292 unsigned long fslw
= fp
->un
.fmt4
.pc
; /* is really FSLW for access error */
295 printk("fslw=%#lx, fa=%#lx\n", fslw
, fp
->un
.fmt4
.effaddr
);
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"
304 /* return if there's no other error */
305 if (!(fslw
& MMU060_ERR_BITS
) && !(fslw
& MMU060_SEE
))
309 if (fslw
& (MMU060_DESC_ERR
| MMU060_WP
| MMU060_SP
)) {
310 unsigned long errorcode
;
311 unsigned long addr
= fp
->un
.fmt4
.effaddr
;
313 if (fslw
& MMU060_MA
)
314 addr
= (addr
+ PAGE_SIZE
- 1) & PAGE_MASK
;
317 if (fslw
& MMU060_DESC_ERR
) {
318 __flush_tlb040_one(addr
);
324 printk("errorcode = %d\n", errorcode
);
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
331 send_fault_sig(&fp
->ptregs
);
332 } else if (!(fslw
& (MMU060_RE
|MMU060_WE
)) ||
333 send_fault_sig(&fp
->ptregs
) > 0) {
334 printk("pc=%#lx, fa=%#lx\n", fp
->ptregs
.pc
, fp
->un
.fmt4
.effaddr
);
335 printk( "68060 access error, fslw=%lx\n", fslw
);
339 #endif /* CONFIG_M68060 */
341 #if defined (CONFIG_M68040)
342 static inline unsigned long probe040(int iswrite
, unsigned long addr
, int wbs
)
345 mm_segment_t old_fs
= get_fs();
347 set_fs(MAKE_MM_SEG(wbs
));
350 asm volatile (".chip 68040; ptestw (%0); .chip 68k" : : "a" (addr
));
352 asm volatile (".chip 68040; ptestr (%0); .chip 68k" : : "a" (addr
));
354 asm volatile (".chip 68040; movec %%mmusr,%0; .chip 68k" : "=r" (mmusr
));
361 static inline int do_040writeback1(unsigned short wbs
, unsigned long wba
,
365 mm_segment_t old_fs
= get_fs();
367 /* set_fs can not be moved, otherwise put_user() may oops */
368 set_fs(MAKE_MM_SEG(wbs
));
370 switch (wbs
& WBSIZ_040
) {
372 res
= put_user(wbd
& 0xff, (char *)wba
);
375 res
= put_user(wbd
& 0xffff, (short *)wba
);
378 res
= put_user(wbd
, (int *)wba
);
382 /* set_fs can not be moved, otherwise put_user() may oops */
387 printk("do_040writeback1, res=%d\n",res
);
393 /* after an exception in a writeback the stack frame corresponding
394 * to that exception is discarded, set a few bits in the old frame
395 * to simulate what it should look like
397 static inline void fix_xframe040(struct frame
*fp
, unsigned long wba
, unsigned short wbs
)
399 fp
->un
.fmt7
.faddr
= wba
;
400 fp
->un
.fmt7
.ssw
= wbs
& 0xff;
401 if (wba
!= current
->thread
.faddr
)
402 fp
->un
.fmt7
.ssw
|= MA_040
;
405 static inline void do_040writebacks(struct frame
*fp
)
409 if (fp
->un
.fmt7
.wb1s
& WBV_040
)
410 printk("access_error040: cannot handle 1st writeback. oops.\n");
413 if ((fp
->un
.fmt7
.wb2s
& WBV_040
) &&
414 !(fp
->un
.fmt7
.wb2s
& WBTT_040
)) {
415 res
= do_040writeback1(fp
->un
.fmt7
.wb2s
, fp
->un
.fmt7
.wb2a
,
418 fix_xframe040(fp
, fp
->un
.fmt7
.wb2a
, fp
->un
.fmt7
.wb2s
);
420 fp
->un
.fmt7
.wb2s
= 0;
423 /* do the 2nd wb only if the first one was successful (except for a kernel wb) */
424 if (fp
->un
.fmt7
.wb3s
& WBV_040
&& (!res
|| fp
->un
.fmt7
.wb3s
& 4)) {
425 res
= do_040writeback1(fp
->un
.fmt7
.wb3s
, fp
->un
.fmt7
.wb3a
,
429 fix_xframe040(fp
, fp
->un
.fmt7
.wb3a
, fp
->un
.fmt7
.wb3s
);
431 fp
->un
.fmt7
.wb2s
= fp
->un
.fmt7
.wb3s
;
432 fp
->un
.fmt7
.wb3s
&= (~WBV_040
);
433 fp
->un
.fmt7
.wb2a
= fp
->un
.fmt7
.wb3a
;
434 fp
->un
.fmt7
.wb2d
= fp
->un
.fmt7
.wb3d
;
437 fp
->un
.fmt7
.wb3s
= 0;
441 send_fault_sig(&fp
->ptregs
);
445 * called from sigreturn(), must ensure userspace code didn't
446 * manipulate exception frame to circumvent protection, then complete
448 * we just clear TM2 to turn it into an userspace access
450 asmlinkage
void berr_040cleanup(struct frame
*fp
)
452 fp
->un
.fmt7
.wb2s
&= ~4;
453 fp
->un
.fmt7
.wb3s
&= ~4;
455 do_040writebacks(fp
);
458 static inline void access_error040(struct frame
*fp
)
460 unsigned short ssw
= fp
->un
.fmt7
.ssw
;
464 printk("ssw=%#x, fa=%#lx\n", ssw
, fp
->un
.fmt7
.faddr
);
465 printk("wb1s=%#x, wb2s=%#x, wb3s=%#x\n", fp
->un
.fmt7
.wb1s
,
466 fp
->un
.fmt7
.wb2s
, fp
->un
.fmt7
.wb3s
);
467 printk ("wb2a=%lx, wb3a=%lx, wb2d=%lx, wb3d=%lx\n",
468 fp
->un
.fmt7
.wb2a
, fp
->un
.fmt7
.wb3a
,
469 fp
->un
.fmt7
.wb2d
, fp
->un
.fmt7
.wb3d
);
473 unsigned long addr
= fp
->un
.fmt7
.faddr
;
474 unsigned long errorcode
;
477 * The MMU status has to be determined AFTER the address
478 * has been corrected if there was a misaligned access (MA).
481 addr
= (addr
+ 7) & -8;
483 /* MMU error, get the MMUSR info for this access */
484 mmusr
= probe040(!(ssw
& RW_040
), addr
, ssw
);
486 printk("mmusr = %lx\n", mmusr
);
489 if (!(mmusr
& MMU_R_040
)) {
490 /* clear the invalid atc entry */
491 __flush_tlb040_one(addr
);
495 /* despite what documentation seems to say, RMW
496 * accesses have always both the LK and RW bits set */
497 if (!(ssw
& RW_040
) || (ssw
& LK_040
))
500 if (do_page_fault(&fp
->ptregs
, addr
, errorcode
)) {
502 printk("do_page_fault() !=0 \n");
504 if (user_mode(&fp
->ptregs
)){
505 /* delay writebacks after signal delivery */
507 printk(".. was usermode - return\n");
511 /* disable writeback into user space from kernel
512 * (if do_page_fault didn't fix the mapping,
513 * the writeback won't do good)
516 printk(".. disabling wb2\n");
518 if (fp
->un
.fmt7
.wb2a
== fp
->un
.fmt7
.faddr
)
519 fp
->un
.fmt7
.wb2s
&= ~WBV_040
;
521 } else if (send_fault_sig(&fp
->ptregs
) > 0) {
522 printk("68040 access error, ssw=%x\n", ssw
);
526 do_040writebacks(fp
);
528 #endif /* CONFIG_M68040 */
530 #if defined(CONFIG_SUN3)
531 #include <asm/sun3mmu.h>
533 extern int mmu_emu_handle_fault (unsigned long, int, int);
535 /* sun3 version of bus_error030 */
537 static inline void bus_error030 (struct frame
*fp
)
539 unsigned char buserr_type
= sun3_get_buserr ();
540 unsigned long addr
, errorcode
;
541 unsigned short ssw
= fp
->un
.fmtb
.ssw
;
542 extern unsigned long _sun3_map_test_start
, _sun3_map_test_end
;
546 printk ("Instruction fault at %#010lx\n",
548 fp
->ptregs
.format
== 0xa ? fp
->ptregs
.pc
+ 2 : fp
->un
.fmtb
.baddr
- 2
550 fp
->ptregs
.format
== 0xa ? fp
->ptregs
.pc
+ 4 : fp
->un
.fmtb
.baddr
);
552 printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
553 ssw
& RW
? "read" : "write",
555 space_names
[ssw
& DFC
], fp
->ptregs
.pc
);
559 * Check if this page should be demand-mapped. This needs to go before
560 * the testing for a bad kernel-space access (demand-mapping applies
561 * to kernel accesses too).
565 && (buserr_type
& (SUN3_BUSERR_PROTERR
| SUN3_BUSERR_INVALID
))) {
566 if (mmu_emu_handle_fault (fp
->un
.fmtb
.daddr
, ssw
& RW
, 0))
570 /* Check for kernel-space pagefault (BAD). */
571 if (fp
->ptregs
.sr
& PS_S
) {
572 /* kernel fault must be a data fault to user space */
573 if (! ((ssw
& DF
) && ((ssw
& DFC
) == USER_DATA
))) {
574 // try checking the kernel mappings before surrender
575 if (mmu_emu_handle_fault (fp
->un
.fmtb
.daddr
, ssw
& RW
, 1))
577 /* instruction fault or kernel data fault! */
579 printk ("Instruction fault at %#010lx\n",
582 /* was this fault incurred testing bus mappings? */
583 if((fp
->ptregs
.pc
>= (unsigned long)&_sun3_map_test_start
) &&
584 (fp
->ptregs
.pc
<= (unsigned long)&_sun3_map_test_end
)) {
585 send_fault_sig(&fp
->ptregs
);
589 printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
590 ssw
& RW
? "read" : "write",
592 space_names
[ssw
& DFC
], fp
->ptregs
.pc
);
594 printk ("BAD KERNEL BUSERR\n");
596 die_if_kernel("Oops", &fp
->ptregs
,0);
597 force_sig(SIGKILL
, current
);
602 if (!(ssw
& (FC
| FB
)) && !(ssw
& DF
))
603 /* not an instruction fault or data fault! BAD */
604 panic ("USER BUSERR w/o instruction or data fault");
608 /* First handle the data fault, if any. */
610 addr
= fp
->un
.fmtb
.daddr
;
612 // errorcode bit 0: 0 -> no page 1 -> protection fault
613 // errorcode bit 1: 0 -> read fault 1 -> write fault
615 // (buserr_type & SUN3_BUSERR_PROTERR) -> protection fault
616 // (buserr_type & SUN3_BUSERR_INVALID) -> invalid page fault
618 if (buserr_type
& SUN3_BUSERR_PROTERR
)
620 else if (buserr_type
& SUN3_BUSERR_INVALID
)
624 printk ("*** unexpected busfault type=%#04x\n", buserr_type
);
625 printk ("invalid %s access at %#lx from pc %#lx\n",
626 !(ssw
& RW
) ? "write" : "read", addr
,
629 die_if_kernel ("Oops", &fp
->ptregs
, buserr_type
);
630 force_sig (SIGBUS
, current
);
634 //todo: wtf is RM bit? --m
635 if (!(ssw
& RW
) || ssw
& RM
)
638 /* Handle page fault. */
639 do_page_fault (&fp
->ptregs
, addr
, errorcode
);
641 /* Retry the data fault now. */
645 /* Now handle the instruction fault. */
647 /* Get the fault address. */
648 if (fp
->ptregs
.format
== 0xA)
649 addr
= fp
->ptregs
.pc
+ 4;
651 addr
= fp
->un
.fmtb
.baddr
;
655 if (buserr_type
& SUN3_BUSERR_INVALID
) {
656 if (!mmu_emu_handle_fault (fp
->un
.fmtb
.daddr
, 1, 0))
657 do_page_fault (&fp
->ptregs
, addr
, 0);
660 printk ("protection fault on insn access (segv).\n");
662 force_sig (SIGSEGV
, current
);
666 #if defined(CPU_M68020_OR_M68030)
667 static inline void bus_error030 (struct frame
*fp
)
669 volatile unsigned short temp
;
670 unsigned short mmusr
;
671 unsigned long addr
, errorcode
;
672 unsigned short ssw
= fp
->un
.fmtb
.ssw
;
676 printk ("pid = %x ", current
->pid
);
677 printk ("SSW=%#06x ", ssw
);
680 printk ("Instruction fault at %#010lx\n",
682 fp
->ptregs
.format
== 0xa ? fp
->ptregs
.pc
+ 2 : fp
->un
.fmtb
.baddr
- 2
684 fp
->ptregs
.format
== 0xa ? fp
->ptregs
.pc
+ 4 : fp
->un
.fmtb
.baddr
);
686 printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
687 ssw
& RW
? "read" : "write",
689 space_names
[ssw
& DFC
], fp
->ptregs
.pc
);
692 /* ++andreas: If a data fault and an instruction fault happen
693 at the same time map in both pages. */
695 /* First handle the data fault, if any. */
697 addr
= fp
->un
.fmtb
.daddr
;
700 asm volatile ("ptestr %3,%2@,#7,%0\n\t"
703 : "a" (&temp
), "a" (addr
), "d" (ssw
));
705 asm volatile ("ptestr %2,%1@,#7\n\t"
707 : : "a" (&temp
), "a" (addr
), "d" (ssw
));
712 printk("mmusr is %#x for addr %#lx in task %p\n",
713 mmusr
, addr
, current
);
714 printk("descriptor address is %#lx, contents %#lx\n",
715 __va(desc
), *(unsigned long *)__va(desc
));
718 errorcode
= (mmusr
& MMU_I
) ? 0 : 1;
719 if (!(ssw
& RW
) || (ssw
& RM
))
722 if (mmusr
& (MMU_I
| MMU_WP
)) {
724 printk("Data %s fault at %#010lx in %s (pc=%#lx)\n",
725 ssw
& RW
? "read" : "write",
727 space_names
[ssw
& DFC
], fp
->ptregs
.pc
);
730 /* Don't try to do anything further if an exception was
732 if (do_page_fault (&fp
->ptregs
, addr
, errorcode
) < 0)
734 } else if (!(mmusr
& MMU_I
)) {
735 /* probably a 020 cas fault */
736 if (!(ssw
& RM
) && send_fault_sig(&fp
->ptregs
) > 0)
737 printk("unexpected bus error (%#x,%#x)\n", ssw
, mmusr
);
738 } else if (mmusr
& (MMU_B
|MMU_L
|MMU_S
)) {
739 printk("invalid %s access at %#lx from pc %#lx\n",
740 !(ssw
& RW
) ? "write" : "read", addr
,
742 die_if_kernel("Oops",&fp
->ptregs
,mmusr
);
743 force_sig(SIGSEGV
, current
);
747 static volatile long tlong
;
750 printk("weird %s access at %#lx from pc %#lx (ssw is %#x)\n",
751 !(ssw
& RW
) ? "write" : "read", addr
,
753 asm volatile ("ptestr #1,%1@,#0\n\t"
756 : "a" (&temp
), "a" (addr
));
759 printk ("level 0 mmusr is %#x\n", mmusr
);
761 asm volatile ("pmove %%tt0,%0@"
764 printk("tt0 is %#lx, ", tlong
);
765 asm volatile ("pmove %%tt1,%0@"
768 printk("tt1 is %#lx\n", tlong
);
771 printk("Unknown SIGSEGV - 1\n");
773 die_if_kernel("Oops",&fp
->ptregs
,mmusr
);
774 force_sig(SIGSEGV
, current
);
778 /* setup an ATC entry for the access about to be retried */
779 if (!(ssw
& RW
) || (ssw
& RM
))
780 asm volatile ("ploadw %1,%0@" : /* no outputs */
781 : "a" (addr
), "d" (ssw
));
783 asm volatile ("ploadr %1,%0@" : /* no outputs */
784 : "a" (addr
), "d" (ssw
));
787 /* Now handle the instruction fault. */
789 if (!(ssw
& (FC
|FB
)))
792 if (fp
->ptregs
.sr
& PS_S
) {
793 printk("Instruction fault at %#010lx\n",
796 printk ("BAD KERNEL BUSERR\n");
797 die_if_kernel("Oops",&fp
->ptregs
,0);
798 force_sig(SIGKILL
, current
);
802 /* get the fault address */
803 if (fp
->ptregs
.format
== 10)
804 addr
= fp
->ptregs
.pc
+ 4;
806 addr
= fp
->un
.fmtb
.baddr
;
810 if ((ssw
& DF
) && ((addr
^ fp
->un
.fmtb
.daddr
) & PAGE_MASK
) == 0)
811 /* Insn fault on same page as data fault. But we
812 should still create the ATC entry. */
813 goto create_atc_entry
;
816 asm volatile ("ptestr #1,%2@,#7,%0\n\t"
819 : "a" (&temp
), "a" (addr
));
821 asm volatile ("ptestr #1,%1@,#7\n\t"
823 : : "a" (&temp
), "a" (addr
));
828 printk ("mmusr is %#x for addr %#lx in task %p\n",
829 mmusr
, addr
, current
);
830 printk ("descriptor address is %#lx, contents %#lx\n",
831 __va(desc
), *(unsigned long *)__va(desc
));
835 do_page_fault (&fp
->ptregs
, addr
, 0);
836 else if (mmusr
& (MMU_B
|MMU_L
|MMU_S
)) {
837 printk ("invalid insn access at %#lx from pc %#lx\n",
838 addr
, fp
->ptregs
.pc
);
840 printk("Unknown SIGSEGV - 2\n");
842 die_if_kernel("Oops",&fp
->ptregs
,mmusr
);
843 force_sig(SIGSEGV
, current
);
848 /* setup an ATC entry for the access about to be retried */
849 asm volatile ("ploadr #2,%0@" : /* no outputs */
852 #endif /* CPU_M68020_OR_M68030 */
853 #endif /* !CONFIG_SUN3 */
855 asmlinkage
void buserr_c(struct frame
*fp
)
857 /* Only set esp0 if coming from user mode */
858 if (user_mode(&fp
->ptregs
))
859 current
->thread
.esp0
= (unsigned long) fp
;
862 printk ("*** Bus Error *** Format is %x\n", fp
->ptregs
.format
);
865 switch (fp
->ptregs
.format
) {
866 #if defined (CONFIG_M68060)
867 case 4: /* 68060 access error */
868 access_error060 (fp
);
871 #if defined (CONFIG_M68040)
872 case 0x7: /* 68040 access error */
873 access_error040 (fp
);
876 #if defined (CPU_M68020_OR_M68030)
883 die_if_kernel("bad frame format",&fp
->ptregs
,0);
885 printk("Unknown SIGSEGV - 4\n");
887 force_sig(SIGSEGV
, current
);
892 static int kstack_depth_to_print
= 48;
894 void show_trace(unsigned long *stack
)
896 unsigned long *endstack
;
900 printk("Call Trace:");
901 addr
= (unsigned long)stack
+ THREAD_SIZE
- 1;
902 endstack
= (unsigned long *)(addr
& -THREAD_SIZE
);
904 while (stack
+ 1 <= endstack
) {
907 * If the address is either in the text segment of the
908 * kernel, or in the region which contains vmalloc'ed
909 * memory, it *may* be the address of a calling
910 * routine; if so, print it so that someone tracing
911 * down the cause of the crash will be able to figure
912 * out the call path that was taken.
914 if (__kernel_text_address(addr
)) {
915 #ifndef CONFIG_KALLSYMS
919 printk(" [<%08lx>]", addr
);
920 print_symbol(" %s\n", addr
);
927 void show_registers(struct pt_regs
*regs
)
929 struct frame
*fp
= (struct frame
*)regs
;
933 addr
= (unsigned long)&fp
->un
;
934 printk("Frame format=%X ", fp
->ptregs
.format
);
935 switch (fp
->ptregs
.format
) {
937 printk("instr addr=%08lx\n", fp
->un
.fmt2
.iaddr
);
938 addr
+= sizeof(fp
->un
.fmt2
);
941 printk("eff addr=%08lx\n", fp
->un
.fmt3
.effaddr
);
942 addr
+= sizeof(fp
->un
.fmt3
);
945 printk((CPU_IS_060
? "fault addr=%08lx fslw=%08lx\n"
946 : "eff addr=%08lx pc=%08lx\n"),
947 fp
->un
.fmt4
.effaddr
, fp
->un
.fmt4
.pc
);
948 addr
+= sizeof(fp
->un
.fmt4
);
951 printk("eff addr=%08lx ssw=%04x faddr=%08lx\n",
952 fp
->un
.fmt7
.effaddr
, fp
->un
.fmt7
.ssw
, fp
->un
.fmt7
.faddr
);
953 printk("wb 1 stat/addr/data: %04x %08lx %08lx\n",
954 fp
->un
.fmt7
.wb1s
, fp
->un
.fmt7
.wb1a
, fp
->un
.fmt7
.wb1dpd0
);
955 printk("wb 2 stat/addr/data: %04x %08lx %08lx\n",
956 fp
->un
.fmt7
.wb2s
, fp
->un
.fmt7
.wb2a
, fp
->un
.fmt7
.wb2d
);
957 printk("wb 3 stat/addr/data: %04x %08lx %08lx\n",
958 fp
->un
.fmt7
.wb3s
, fp
->un
.fmt7
.wb3a
, fp
->un
.fmt7
.wb3d
);
959 printk("push data: %08lx %08lx %08lx %08lx\n",
960 fp
->un
.fmt7
.wb1dpd0
, fp
->un
.fmt7
.pd1
, fp
->un
.fmt7
.pd2
,
962 addr
+= sizeof(fp
->un
.fmt7
);
965 printk("instr addr=%08lx\n", fp
->un
.fmt9
.iaddr
);
966 addr
+= sizeof(fp
->un
.fmt9
);
969 printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
970 fp
->un
.fmta
.ssw
, fp
->un
.fmta
.isc
, fp
->un
.fmta
.isb
,
971 fp
->un
.fmta
.daddr
, fp
->un
.fmta
.dobuf
);
972 addr
+= sizeof(fp
->un
.fmta
);
975 printk("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
976 fp
->un
.fmtb
.ssw
, fp
->un
.fmtb
.isc
, fp
->un
.fmtb
.isb
,
977 fp
->un
.fmtb
.daddr
, fp
->un
.fmtb
.dobuf
);
978 printk("baddr=%08lx dibuf=%08lx ver=%x\n",
979 fp
->un
.fmtb
.baddr
, fp
->un
.fmtb
.dibuf
, fp
->un
.fmtb
.ver
);
980 addr
+= sizeof(fp
->un
.fmtb
);
985 show_stack(NULL
, (unsigned long *)addr
);
988 for (i
= 0; i
< 10; i
++)
989 printk("%04x ", 0xffff & ((short *) fp
->ptregs
.pc
)[i
]);
993 void show_stack(struct task_struct
*task
, unsigned long *stack
)
995 unsigned long *endstack
;
1000 stack
= (unsigned long *)task
->thread
.esp0
;
1002 stack
= (unsigned long *)&stack
;
1004 endstack
= (unsigned long *)(((unsigned long)stack
+ THREAD_SIZE
- 1) & -THREAD_SIZE
);
1006 printk("Stack from %08lx:", (unsigned long)stack
);
1007 for (i
= 0; i
< kstack_depth_to_print
; i
++) {
1008 if (stack
+ 1 > endstack
)
1012 printk(" %08lx", *stack
++);
1019 * The architecture-independent backtrace generator
1021 void dump_stack(void)
1023 unsigned long stack
;
1028 EXPORT_SYMBOL(dump_stack
);
1030 void bad_super_trap (struct frame
*fp
)
1033 if (fp
->ptregs
.vector
< 4*sizeof(vec_names
)/sizeof(vec_names
[0]))
1034 printk ("*** %s *** FORMAT=%X\n",
1035 vec_names
[(fp
->ptregs
.vector
) >> 2],
1038 printk ("*** Exception %d *** FORMAT=%X\n",
1039 (fp
->ptregs
.vector
) >> 2,
1041 if (fp
->ptregs
.vector
>> 2 == VEC_ADDRERR
&& CPU_IS_020_OR_030
) {
1042 unsigned short ssw
= fp
->un
.fmtb
.ssw
;
1044 printk ("SSW=%#06x ", ssw
);
1047 printk ("Pipe stage C instruction fault at %#010lx\n",
1048 (fp
->ptregs
.format
) == 0xA ?
1049 fp
->ptregs
.pc
+ 2 : fp
->un
.fmtb
.baddr
- 2);
1051 printk ("Pipe stage B instruction fault at %#010lx\n",
1052 (fp
->ptregs
.format
) == 0xA ?
1053 fp
->ptregs
.pc
+ 4 : fp
->un
.fmtb
.baddr
);
1055 printk ("Data %s fault at %#010lx in %s (pc=%#lx)\n",
1056 ssw
& RW
? "read" : "write",
1057 fp
->un
.fmtb
.daddr
, space_names
[ssw
& DFC
],
1060 printk ("Current process id is %d\n", current
->pid
);
1061 die_if_kernel("BAD KERNEL TRAP", &fp
->ptregs
, 0);
1064 asmlinkage
void trap_c(struct frame
*fp
)
1069 if (fp
->ptregs
.sr
& PS_S
) {
1070 if ((fp
->ptregs
.vector
>> 2) == VEC_TRACE
) {
1071 /* traced a trapping instruction */
1072 current
->ptrace
|= PT_DTRACE
;
1078 /* send the appropriate signal to the user program */
1079 switch ((fp
->ptregs
.vector
) >> 2) {
1081 info
.si_code
= BUS_ADRALN
;
1087 info
.si_code
= ILL_ILLOPC
;
1091 info
.si_code
= ILL_PRVOPC
;
1095 info
.si_code
= ILL_COPROC
;
1112 info
.si_code
= ILL_ILLTRP
;
1118 info
.si_code
= FPE_FLTINV
;
1122 info
.si_code
= FPE_FLTRES
;
1126 info
.si_code
= FPE_FLTDIV
;
1130 info
.si_code
= FPE_FLTUND
;
1134 info
.si_code
= FPE_FLTOVF
;
1138 info
.si_code
= FPE_INTDIV
;
1143 info
.si_code
= FPE_INTOVF
;
1146 case VEC_TRACE
: /* ptrace single step */
1147 info
.si_code
= TRAP_TRACE
;
1150 case VEC_TRAP15
: /* breakpoint */
1151 info
.si_code
= TRAP_BRKPT
;
1155 info
.si_code
= ILL_ILLOPC
;
1159 info
.si_signo
= sig
;
1161 switch (fp
->ptregs
.format
) {
1163 info
.si_addr
= (void *) fp
->ptregs
.pc
;
1166 info
.si_addr
= (void *) fp
->un
.fmt2
.iaddr
;
1169 info
.si_addr
= (void *) fp
->un
.fmt7
.effaddr
;
1172 info
.si_addr
= (void *) fp
->un
.fmt9
.iaddr
;
1175 info
.si_addr
= (void *) fp
->un
.fmta
.daddr
;
1178 info
.si_addr
= (void *) fp
->un
.fmtb
.daddr
;
1181 force_sig_info (sig
, &info
, current
);
1184 void die_if_kernel (char *str
, struct pt_regs
*fp
, int nr
)
1186 if (!(fp
->sr
& PS_S
))
1190 printk("%s: %08x\n",str
,nr
);
1192 printk("PC: [<%08lx>]",fp
->pc
);
1193 print_symbol(" %s\n", fp
->pc
);
1194 printk("\nSR: %04x SP: %p a2: %08lx\n",
1195 fp
->sr
, fp
, fp
->a2
);
1196 printk("d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n",
1197 fp
->d0
, fp
->d1
, fp
->d2
, fp
->d3
);
1198 printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
1199 fp
->d4
, fp
->d5
, fp
->a0
, fp
->a1
);
1201 printk("Process %s (pid: %d, stackpage=%08lx)\n",
1202 current
->comm
, current
->pid
, PAGE_SIZE
+(unsigned long)current
);
1203 show_stack(NULL
, (unsigned long *)fp
);
1208 * This function is called if an error occur while accessing
1209 * user-space from the fpsp040 code.
1211 asmlinkage
void fpsp040_die(void)
1216 #ifdef CONFIG_M68KFPU_EMU
1217 asmlinkage
void fpemu_signal(int signal
, int code
, void *addr
)
1221 info
.si_signo
= signal
;
1223 info
.si_code
= code
;
1224 info
.si_addr
= addr
;
1225 force_sig_info(signal
, &info
, current
);