21 #include <linux/sched.h>
22 #include <linux/signal.h>
23 #include <linux/kernel.h>
25 #include <linux/module.h>
27 #include <linux/string.h>
28 #include <linux/linkage.h>
30 #include <linux/ptrace.h>
33 #include <asm/setup.h>
35 #include <asm/uaccess.h>
36 #include <asm/traps.h>
37 #include <asm/pgalloc.h>
38 #include <asm/machdep.h>
39 #include <asm/siginfo.h>
42 static const char *vec_names[] = {
56 [
VEC_COPROC] =
"COPROCESSOR PROTOCOL VIOLATION",
101 [
VEC_MMUACC] =
"MMU ACCESS LEVEL VIOLATION ERROR",
109 static const char *space_names[] = {
131 #if defined (CONFIG_M68060)
132 static inline void access_error060 (
struct frame *
fp)
134 unsigned long fslw = fp->
un.
fmt4.pc;
137 printk(
"fslw=%#lx, fa=%#lx\n", fslw, fp->
un.
fmt4.effaddr);
142 __asm__ __volatile__ (
"movec %/cacr,%/d0\n\t"
143 "orl #0x00400000,%/d0\n\t"
152 unsigned long errorcode;
160 __flush_tlb040_one(addr);
166 printk(
"errorcode = %d\n", errorcode );
177 printk(
"68060 access error, fslw=%lx\n", fslw );
183 #if defined (CONFIG_M68040)
184 static inline unsigned long probe040(
int iswrite,
unsigned long addr,
int wbs)
192 asm volatile (
".chip 68040; ptestw (%0); .chip 68k" : :
"a" (
addr));
194 asm volatile (
".chip 68040; ptestr (%0); .chip 68k" : :
"a" (
addr));
196 asm volatile (
".chip 68040; movec %%mmusr,%0; .chip 68k" :
"=r" (mmusr));
203 static inline int do_040writeback1(
unsigned short wbs,
unsigned long wba,
214 res =
put_user(wbd & 0xff, (
char __user *)wba);
217 res =
put_user(wbd & 0xffff, (
short __user *)wba);
220 res =
put_user(wbd, (
int __user *)wba);
229 printk(
"do_040writeback1, res=%d\n",res);
239 static inline void fix_xframe040(
struct frame *fp,
unsigned long wba,
unsigned short wbs)
242 fp->
un.
fmt7.ssw = wbs & 0xff;
243 if (wba !=
current->thread.faddr)
247 static inline void do_040writebacks(
struct frame *fp)
252 printk(
"access_error040: cannot handle 1st writeback. oops.\n");
257 res = do_040writeback1(fp->
un.
fmt7.wb2s, fp->
un.
fmt7.wb2a,
267 res = do_040writeback1(fp->
un.
fmt7.wb3s, fp->
un.
fmt7.wb3a,
297 do_040writebacks(fp);
300 static inline void access_error040(
struct frame *fp)
302 unsigned short ssw = fp->
un.
fmt7.ssw;
307 printk(
"wb1s=%#x, wb2s=%#x, wb3s=%#x\n", fp->
un.
fmt7.wb1s,
309 printk (
"wb2a=%lx, wb3a=%lx, wb2d=%lx, wb3d=%lx\n",
315 unsigned long addr = fp->
un.
fmt7.faddr;
316 unsigned long errorcode;
323 addr = (addr + 7) & -8;
326 mmusr = probe040(!(ssw &
RW_040), addr, ssw);
328 printk(
"mmusr = %lx\n", mmusr);
333 __flush_tlb040_one(addr);
344 printk(
"do_page_fault() !=0\n");
349 printk(
".. was usermode - return\n");
359 printk(
".. disabling wb2\n");
374 printk(
"68040 bus error (ssw=%x, faddr=%lx)\n", ssw,
379 do_040writebacks(fp);
383 #if defined(CONFIG_SUN3)
390 static inline void bus_error030 (
struct frame *fp)
392 unsigned char buserr_type = sun3_get_buserr ();
393 unsigned long addr, errorcode;
394 unsigned short ssw = fp->
un.
fmtb.ssw;
395 extern unsigned long _sun3_map_test_start, _sun3_map_test_end;
399 printk (
"Instruction fault at %#010lx\n",
405 printk (
"Data %s fault at %#010lx in %s (pc=%#lx)\n",
406 ssw &
RW ?
"read" :
"write",
432 printk (
"Instruction fault at %#010lx\n",
436 if((fp->
ptregs.pc >= (
unsigned long)&_sun3_map_test_start) &&
437 (fp->
ptregs.pc <= (
unsigned long)&_sun3_map_test_end)) {
442 printk (
"Data %s fault at %#010lx in %s (pc=%#lx)\n",
443 ssw & RW ?
"read" :
"write",
445 space_names[ssw & DFC], fp->
ptregs.pc);
447 printk (
"BAD KERNEL BUSERR\n");
455 if (!(ssw & (
FC |
FB)) && !(ssw & DF))
457 panic (
"USER BUSERR w/o instruction or data fault");
477 printk (
"*** unexpected busfault type=%#04x\n", buserr_type);
478 printk (
"invalid %s access at %#lx from pc %#lx\n",
479 !(ssw & RW) ?
"write" :
"read", addr,
488 if (!(ssw & RW) || ssw &
RM)
501 if (fp->
ptregs.format == 0xA)
508 if (buserr_type & SUN3_BUSERR_INVALID) {
513 printk (
"protection fault on insn access (segv).\n");
519 #if defined(CPU_M68020_OR_M68030)
520 static inline void bus_error030 (
struct frame *fp)
522 volatile unsigned short temp;
523 unsigned short mmusr;
524 unsigned long addr, errorcode;
525 unsigned short ssw = fp->
un.
fmtb.ssw;
530 printk (
"SSW=%#06x ", ssw);
533 printk (
"Instruction fault at %#010lx\n",
539 printk (
"Data %s fault at %#010lx in %s (pc=%#lx)\n",
540 ssw & RW ?
"read" :
"write",
542 space_names[ssw & DFC], fp->
ptregs.pc);
553 asm volatile (
"ptestr %3,%2@,#7,%0\n\t"
555 :
"=a&" (desc),
"=m" (temp)
556 :
"a" (
addr),
"d" (ssw));
558 asm volatile (
"ptestr %2,%1@,#7\n\t"
560 :
"=m" (
temp) :
"a" (addr),
"d" (ssw));
565 printk(
"mmusr is %#x for addr %#lx in task %p\n",
567 printk(
"descriptor address is %#lx, contents %#lx\n",
568 __va(desc), *(
unsigned long *)
__va(desc));
571 errorcode = (mmusr &
MMU_I) ? 0 : 1;
572 if (!(ssw & RW) || (ssw &
RM))
577 printk(
"Data %s fault at %#010lx in %s (pc=%#lx)\n",
578 ssw & RW ?
"read" :
"write",
580 space_names[ssw & DFC], fp->
ptregs.pc);
587 }
else if (!(mmusr &
MMU_I)) {
590 printk(
"unexpected bus error (%#x,%#x)\n", ssw, mmusr);
592 printk(
"invalid %s access at %#lx from pc %#lx\n",
593 !(ssw & RW) ?
"write" :
"read", addr,
600 static volatile long tlong;
603 printk(
"weird %s access at %#lx from pc %#lx (ssw is %#x)\n",
604 !(ssw & RW) ?
"write" :
"read", addr,
606 asm volatile (
"ptestr #1,%1@,#0\n\t"
612 printk (
"level 0 mmusr is %#x\n", mmusr);
614 asm volatile (
"pmove %%tt0,%0"
616 printk(
"tt0 is %#lx, ", tlong);
617 asm volatile (
"pmove %%tt1,%0"
619 printk(
"tt1 is %#lx\n", tlong);
622 printk(
"Unknown SIGSEGV - 1\n");
630 if (!(ssw & RW) || (ssw & RM))
631 asm volatile (
"ploadw %1,%0@" :
632 :
"a" (
addr),
"d" (ssw));
634 asm volatile (
"ploadr %1,%0@" :
635 :
"a" (
addr),
"d" (ssw));
640 if (!(ssw & (FC|
FB)))
644 printk(
"Instruction fault at %#010lx\n",
647 printk (
"BAD KERNEL BUSERR\n");
654 if (fp->
ptregs.format == 10)
664 goto create_atc_entry;
667 asm volatile (
"ptestr #1,%2@,#7,%0\n\t"
669 :
"=a&" (desc),
"=m" (temp)
672 asm volatile (
"ptestr #1,%1@,#7\n\t"
674 :
"=m" (
temp) :
"a" (addr));
679 printk (
"mmusr is %#x for addr %#lx in task %p\n",
681 printk (
"descriptor address is %#lx, contents %#lx\n",
682 __va(desc), *(
unsigned long *)
__va(desc));
688 printk (
"invalid insn access at %#lx from pc %#lx\n",
691 printk(
"Unknown SIGSEGV - 2\n");
700 asm volatile (
"ploadr #2,%0@" :
706 #if defined(CONFIG_COLDFIRE) && defined(CONFIG_MMU)
714 static const unsigned char fs_err_code[] = {
733 static inline void access_errorcf(
unsigned int fs,
struct frame *fp)
735 unsigned long mmusr,
addr;
739 mmusr = mmu_read(
MMUSR);
740 addr = mmu_read(
MMUAR);
779 if (need_page_fault) {
780 err_code = fs_err_code[
fs];
781 if ((fs == 13) && (mmusr &
MMUSR_WF))
795 printk (
"*** Bus Error *** Format is %x\n", fp->
ptregs.format);
798 #if defined(CONFIG_COLDFIRE) && defined(CONFIG_MMU)
801 fs = (fp->
ptregs.vector & 0x3) |
802 ((fp->
ptregs.vector & 0xc00) >> 8);
812 access_errorcf(fs, fp);
820 switch (fp->
ptregs.format) {
821 #if defined (CONFIG_M68060)
823 access_error060 (fp);
826 #if defined (CONFIG_M68040)
828 access_error040 (fp);
831 #if defined (CPU_M68020_OR_M68030)
840 printk(
"Unknown SIGSEGV - 4\n");
847 static int kstack_depth_to_print = 48;
851 unsigned long *endstack;
859 while (stack + 1 <= endstack) {
870 #ifndef CONFIG_KALLSYMS
874 printk(
" [<%08lx>] %pS\n", addr, (
void *)addr);
890 printk(
"PC: [<%08lx>] %pS\n", regs->
pc, (
void *)regs->
pc);
891 printk(
"SR: %04x SP: %p a2: %08lx\n", regs->
sr, regs, regs->
a2);
892 printk(
"d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n",
893 regs->
d0, regs->
d1, regs->
d2, regs->
d3);
894 printk(
"d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
895 regs->
d4, regs->
d5, regs->
a0, regs->
a1);
897 printk(
"Process %s (pid: %d, task=%p)\n",
899 addr = (
unsigned long)&fp->
un;
904 addr +=
sizeof(fp->
un.
fmt2);
908 addr +=
sizeof(fp->
un.
fmt3);
912 :
"eff addr=%08lx pc=%08lx\n"),
914 addr +=
sizeof(fp->
un.
fmt4);
917 printk(
"eff addr=%08lx ssw=%04x faddr=%08lx\n",
919 printk(
"wb 1 stat/addr/data: %04x %08lx %08lx\n",
921 printk(
"wb 2 stat/addr/data: %04x %08lx %08lx\n",
923 printk(
"wb 3 stat/addr/data: %04x %08lx %08lx\n",
925 printk(
"push data: %08lx %08lx %08lx %08lx\n",
928 addr +=
sizeof(fp->
un.
fmt7);
932 addr +=
sizeof(fp->
un.
fmt9);
935 printk(
"ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
938 addr +=
sizeof(fp->
un.
fmta);
941 printk(
"ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
944 printk(
"baddr=%08lx dibuf=%08lx ver=%x\n",
946 addr +=
sizeof(fp->
un.
fmtb);
955 cp = (
u16 *)regs->
pc;
956 for (i = -8; i < 16; i++) {
957 if (
get_user(c, cp + i) && i >= 0) {
961 printk(i ?
" %04x" :
" <%04x>", c);
970 unsigned long *endstack;
975 stack = (
unsigned long *)task->
thread.esp0;
977 stack = (
unsigned long *)&
stack;
981 printk(
"Stack from %08lx:", (
unsigned long)stack);
983 for (i = 0; i < kstack_depth_to_print; i++) {
984 if (p + 1 > endstack)
1020 printk (
"*** %s *** FORMAT=%X\n",
1024 printk (
"*** Exception %d *** FORMAT=%X\n",
1025 vector, fp->
ptregs.format);
1027 unsigned short ssw = fp->
un.
fmtb.ssw;
1029 printk (
"SSW=%#06x ", ssw);
1032 printk (
"Pipe stage C instruction fault at %#010lx\n",
1033 (fp->
ptregs.format) == 0xA ?
1036 printk (
"Pipe stage B instruction fault at %#010lx\n",
1037 (fp->
ptregs.format) == 0xA ?
1040 printk (
"Data %s fault at %#010lx in %s (pc=%#lx)\n",
1041 ssw & RW ?
"read" :
"write",
1042 fp->
un.
fmtb.daddr, space_names[ssw & DFC],
1045 printk (
"Current process id is %d\n", task_pid_nr(
current));
1060 }
else if (!handle_kernel_fault(&fp->
ptregs))
1148 switch (fp->
ptregs.format) {
1150 info.si_addr = (
void *) fp->
ptregs.pc;
1153 info.si_addr = (
void *) fp->
un.
fmt2.iaddr;
1156 info.si_addr = (
void *) fp->
un.
fmt7.effaddr;
1159 info.si_addr = (
void *) fp->
un.
fmt9.iaddr;
1162 info.si_addr = (
void *) fp->
un.
fmta.daddr;
1165 info.si_addr = (
void *) fp->
un.
fmtb.daddr;
1177 printk(
"%s: %08x\n",str,nr);
1197 #ifdef CONFIG_M68KFPU_EMU
1205 info.si_addr =
addr;