13 #include <linux/sched.h>
14 #include <linux/tty.h>
16 #include <linux/module.h>
22 #include <asm/uaccess.h>
23 #include <asm/unaligned.h>
24 #include <asm/sysinfo.h>
26 #include <asm/mmu_context.h>
27 #include <asm/special_insns.h>
49 " call_pal %[wrent]\n"
54 " cvttq/svm $f31,$f31\n"
56 : [fix]
"=r" (opDEC_fix)
58 :
"$0",
"$1",
"$16",
"$17",
"$22",
"$23",
"$24",
"$25");
61 printk(
"opDEC fixup enabled.\n");
67 printk(
"pc = [<%016lx>] ra = [<%016lx>] ps = %04lx %s\n",
69 print_symbol(
"pc is at %s\n", regs->
pc);
70 print_symbol(
"ra is at %s\n", regs->
r26 );
71 printk(
"v0 = %016lx t0 = %016lx t1 = %016lx\n",
72 regs->
r0, regs->
r1, regs->
r2);
73 printk(
"t2 = %016lx t3 = %016lx t4 = %016lx\n",
74 regs->
r3, regs->
r4, regs->
r5);
75 printk(
"t5 = %016lx t6 = %016lx t7 = %016lx\n",
76 regs->
r6, regs->
r7, regs->
r8);
79 printk(
"s0 = %016lx s1 = %016lx s2 = %016lx\n",
80 r9_15[9], r9_15[10], r9_15[11]);
81 printk(
"s3 = %016lx s4 = %016lx s5 = %016lx\n",
82 r9_15[12], r9_15[13], r9_15[14]);
83 printk(
"s6 = %016lx\n", r9_15[15]);
86 printk(
"a0 = %016lx a1 = %016lx a2 = %016lx\n",
88 printk(
"a3 = %016lx a4 = %016lx a5 = %016lx\n",
90 printk(
"t8 = %016lx t9 = %016lx t10= %016lx\n",
92 printk(
"t11= %016lx pv = %016lx at = %016lx\n",
94 printk(
"gp = %016lx sp = %p\n", regs->
gp, regs+1);
101 static char * ireg_name[] = {
"v0",
"t0",
"t1",
"t2",
"t3",
"t4",
"t5",
"t6",
102 "t7",
"s0",
"s1",
"s2",
"s3",
"s4",
"s5",
"s6",
103 "a0",
"a1",
"a2",
"a3",
"a4",
"a5",
"t8",
"t9",
104 "t10",
"t11",
"ra",
"pv",
"at",
"gp",
"sp",
"zero"};
108 dik_show_code(
unsigned int *
pc)
113 for (i = -6; i < 2; i++) {
115 if (
__get_user(insn, (
unsigned int __user *)pc + i))
117 printk(
"%c%08x%c", i ?
' ' :
'<', insn, i ?
' ' :
'>');
123 dik_show_trace(
unsigned long *
sp)
127 while (0x1ff8 & (
unsigned long) sp) {
129 unsigned long tmp = *
sp;
131 if (tmp < (
unsigned long) &_stext)
133 if (tmp >= (
unsigned long) &_etext)
136 print_symbol(
" %s", tmp);
146 static int kstack_depth_to_print = 24;
150 unsigned long *
stack;
158 sp=(
unsigned long*)&sp;
161 for(i=0; i < kstack_depth_to_print; i++) {
164 if (i && ((i % 4) == 0))
166 printk(
"%016lx ", *stack++);
190 dik_show_trace((
unsigned long *)(regs+1));
191 dik_show_code((
unsigned int *)regs->
pc);
193 if (test_and_set_thread_flag (TIF_DIE_IF_KERNEL)) {
194 printk(
"die_if_kernel recursion detected.\n");
201 #ifndef CONFIG_MATHEMU
202 static long dummy_emul(
void) {
return 0; }
204 = (
void *)dummy_emul;
206 = (
void *)dummy_emul;
235 info.si_addr = (
void __user *) regs->
pc;
247 const unsigned int *
data
248 = (
const unsigned int *) regs->
pc;
249 printk(
"Kernel bug at %s:%d\n",
250 (
const char *)(data[1] | (
long)data[2] << 32),
253 die_if_kernel((type == 1 ?
"Kernel Bug" :
"Instruction fault"),
263 info.si_addr = (
void __user *) regs->
pc;
276 info.si_addr = (
void __user *) regs->
pc;
282 info.si_addr = (
void __user *) regs->
pc;
283 info.si_trapno = regs->
r16;
284 switch ((
long) regs->
r16) {
344 info.si_addr = (
void __user *) regs->
pc;
360 regs->
pc += opDEC_fix;
372 info.si_addr = (
void __user *) regs->
pc;
401 info.si_addr = (
void __user *) regs->
pc;
422 info.si_addr = (
void __user *) regs->
pc;
441 unsigned long regs[32];
451 #define una_reg(r) (_regs[(r) >= 16 && (r) <= 18 ? (r)+19 : (r)])
459 unsigned long pc = regs->
pc - 4;
460 unsigned long *_regs = regs->
regs;
474 "1: ldq_u %1,0(%3)\n"
475 "2: ldq_u %2,1(%3)\n"
479 ".section __ex_table,\"a\"\n"
481 " lda %1,3b-1b(%0)\n"
483 " lda %2,3b-2b(%0)\n"
485 :
"=r"(error),
"=&r"(tmp1),
"=&r"(tmp2)
494 "1: ldq_u %1,0(%3)\n"
495 "2: ldq_u %2,3(%3)\n"
499 ".section __ex_table,\"a\"\n"
501 " lda %1,3b-1b(%0)\n"
503 " lda %2,3b-2b(%0)\n"
505 :
"=r"(error),
"=&r"(tmp1),
"=&r"(tmp2)
514 "1: ldq_u %1,0(%3)\n"
515 "2: ldq_u %2,7(%3)\n"
519 ".section __ex_table,\"a\"\n"
521 " lda %1,3b-1b(%0)\n"
523 " lda %2,3b-2b(%0)\n"
525 :
"=r"(error),
"=&r"(tmp1),
"=&r"(tmp2)
537 "1: ldq_u %2,1(%5)\n"
538 "2: ldq_u %1,0(%5)\n"
545 "3: stq_u %2,1(%5)\n"
546 "4: stq_u %1,0(%5)\n"
548 ".section __ex_table,\"a\"\n"
550 " lda %2,5b-1b(%0)\n"
552 " lda %1,5b-2b(%0)\n"
554 " lda $31,5b-3b(%0)\n"
556 " lda $31,5b-4b(%0)\n"
558 :
"=r"(error),
"=&r"(tmp1),
"=&r"(tmp2),
559 "=&r"(tmp3),
"=&r"(tmp4)
560 :
"r"(va),
"r"(
una_reg(reg)),
"0"(0));
567 "1: ldq_u %2,3(%5)\n"
568 "2: ldq_u %1,0(%5)\n"
575 "3: stq_u %2,3(%5)\n"
576 "4: stq_u %1,0(%5)\n"
578 ".section __ex_table,\"a\"\n"
580 " lda %2,5b-1b(%0)\n"
582 " lda %1,5b-2b(%0)\n"
584 " lda $31,5b-3b(%0)\n"
586 " lda $31,5b-4b(%0)\n"
588 :
"=r"(error),
"=&r"(tmp1),
"=&r"(tmp2),
589 "=&r"(tmp3),
"=&r"(tmp4)
590 :
"r"(va),
"r"(
una_reg(reg)),
"0"(0));
597 "1: ldq_u %2,7(%5)\n"
598 "2: ldq_u %1,0(%5)\n"
605 "3: stq_u %2,7(%5)\n"
606 "4: stq_u %1,0(%5)\n"
608 ".section __ex_table,\"a\"\n\t"
610 " lda %2,5b-1b(%0)\n"
612 " lda %1,5b-2b(%0)\n"
614 " lda $31,5b-3b(%0)\n"
616 " lda $31,5b-4b(%0)\n"
618 :
"=r"(error),
"=&r"(tmp1),
"=&r"(tmp2),
619 "=&r"(tmp3),
"=&r"(tmp4)
620 :
"r"(va),
"r"(
una_reg(reg)),
"0"(0));
626 printk(
"Bad unaligned kernel access at %016lx: %p %lx %lu\n",
627 pc, va, opcode, reg);
637 printk(
"Forwarding unaligned exception at %lx (%lx)\n",
649 printk(
"%s(%d): unhandled unaligned exception\n",
652 printk(
"pc = [<%016lx>] ra = [<%016lx>] ps = %04lx\n",
654 printk(
"r0 = %016lx r1 = %016lx r2 = %016lx\n",
656 printk(
"r3 = %016lx r4 = %016lx r5 = %016lx\n",
658 printk(
"r6 = %016lx r7 = %016lx r8 = %016lx\n",
660 printk(
"r9 = %016lx r10= %016lx r11= %016lx\n",
662 printk(
"r12= %016lx r13= %016lx r14= %016lx\n",
665 printk(
"r16= %016lx r17= %016lx r18= %016lx\n",
667 printk(
"r19= %016lx r20= %016lx r21= %016lx\n",
669 printk(
"r22= %016lx r23= %016lx r24= %016lx\n",
671 printk(
"r25= %016lx r27= %016lx r28= %016lx\n",
673 printk(
"gp = %016lx sp = %p\n", regs->
gp, regs+1);
675 dik_show_code((
unsigned int *)pc);
676 dik_show_trace((
unsigned long *)(regs+1));
678 if (test_and_set_thread_flag (TIF_DIE_IF_KERNEL)) {
679 printk(
"die_if_kernel recursion detected.\n");
692 static inline unsigned long
693 s_mem_to_reg (
unsigned long s_mem)
695 unsigned long frac = (s_mem >> 0) & 0x7fffff;
696 unsigned long sign = (s_mem >> 31) & 0x1;
697 unsigned long exp_msb = (s_mem >> 30) & 0x1;
698 unsigned long exp_low = (s_mem >> 23) & 0x7f;
701 exp = (exp_msb << 10) | exp_low;
703 if (exp_low == 0x7f) {
707 if (exp_low == 0x00) {
713 return (sign << 63) | (exp << 52) | (frac << 29);
720 static inline unsigned long
721 s_reg_to_mem (
unsigned long s_reg)
723 return ((s_reg >> 62) << 30) | ((s_reg << 5) >> 34);
746 #define OP_INT_MASK ( 1L << 0x28 | 1L << 0x2c \
747 | 1L << 0x29 | 1L << 0x2d \
748 | 1L << 0x0c | 1L << 0x0d \
749 | 1L << 0x0a | 1L << 0x0e )
751 #define OP_WRITE_MASK ( 1L << 0x26 | 1L << 0x27 \
752 | 1L << 0x2c | 1L << 0x2d \
753 | 1L << 0x0d | 1L << 0x0e )
755 #define R(x) ((size_t) &((struct pt_regs *)0)->x)
757 static int unauser_reg_offsets[32] = {
760 -56, -48, -40, -32, -24, -16, -8,
775 unsigned long tmp1, tmp2, tmp3, tmp4;
776 unsigned long fake_reg, *
reg_addr = &fake_reg;
785 printk(
"%s(%d): unaligned trap at %016lx: %p %lx %ld\n",
787 regs->
pc - 4, va, opcode, reg);
809 reg_addr = (
unsigned long *)
810 ((
char *)regs + unauser_reg_offsets[
reg]);
811 }
else if (reg == 30) {
827 "1: ldq_u %1,0(%3)\n"
828 "2: ldq_u %2,1(%3)\n"
832 ".section __ex_table,\"a\"\n"
834 " lda %1,3b-1b(%0)\n"
836 " lda %2,3b-2b(%0)\n"
838 :
"=r"(error),
"=&r"(tmp1),
"=&r"(tmp2)
842 *reg_addr = tmp1|tmp2;
847 "1: ldq_u %1,0(%3)\n"
848 "2: ldq_u %2,3(%3)\n"
852 ".section __ex_table,\"a\"\n"
854 " lda %1,3b-1b(%0)\n"
856 " lda %2,3b-2b(%0)\n"
858 :
"=r"(error),
"=&r"(tmp1),
"=&r"(tmp2)
867 "1: ldq_u %1,0(%3)\n"
868 "2: ldq_u %2,7(%3)\n"
872 ".section __ex_table,\"a\"\n"
874 " lda %1,3b-1b(%0)\n"
876 " lda %2,3b-2b(%0)\n"
878 :
"=r"(error),
"=&r"(tmp1),
"=&r"(tmp2)
887 "1: ldq_u %1,0(%3)\n"
888 "2: ldq_u %2,3(%3)\n"
892 ".section __ex_table,\"a\"\n"
894 " lda %1,3b-1b(%0)\n"
896 " lda %2,3b-2b(%0)\n"
898 :
"=r"(error),
"=&r"(tmp1),
"=&r"(tmp2)
902 *reg_addr = (
int)(tmp1|tmp2);
907 "1: ldq_u %1,0(%3)\n"
908 "2: ldq_u %2,7(%3)\n"
912 ".section __ex_table,\"a\"\n"
914 " lda %1,3b-1b(%0)\n"
916 " lda %2,3b-2b(%0)\n"
918 :
"=r"(error),
"=&r"(tmp1),
"=&r"(tmp2)
922 *reg_addr = tmp1|tmp2;
930 "1: ldq_u %2,1(%5)\n"
931 "2: ldq_u %1,0(%5)\n"
938 "3: stq_u %2,1(%5)\n"
939 "4: stq_u %1,0(%5)\n"
941 ".section __ex_table,\"a\"\n"
943 " lda %2,5b-1b(%0)\n"
945 " lda %1,5b-2b(%0)\n"
947 " lda $31,5b-3b(%0)\n"
949 " lda $31,5b-4b(%0)\n"
951 :
"=r"(error),
"=&r"(tmp1),
"=&r"(tmp2),
952 "=&r"(tmp3),
"=&r"(tmp4)
953 :
"r"(va),
"r"(*reg_addr),
"0"(0));
964 "1: ldq_u %2,3(%5)\n"
965 "2: ldq_u %1,0(%5)\n"
972 "3: stq_u %2,3(%5)\n"
973 "4: stq_u %1,0(%5)\n"
975 ".section __ex_table,\"a\"\n"
977 " lda %2,5b-1b(%0)\n"
979 " lda %1,5b-2b(%0)\n"
981 " lda $31,5b-3b(%0)\n"
983 " lda $31,5b-4b(%0)\n"
985 :
"=r"(error),
"=&r"(tmp1),
"=&r"(tmp2),
986 "=&r"(tmp3),
"=&r"(tmp4)
987 :
"r"(va),
"r"(*reg_addr),
"0"(0));
998 "1: ldq_u %2,7(%5)\n"
999 "2: ldq_u %1,0(%5)\n"
1006 "3: stq_u %2,7(%5)\n"
1007 "4: stq_u %1,0(%5)\n"
1009 ".section __ex_table,\"a\"\n\t"
1011 " lda %2,5b-1b(%0)\n"
1013 " lda %1,5b-2b(%0)\n"
1015 " lda $31,5b-3b(%0)\n"
1017 " lda $31,5b-4b(%0)\n"
1019 :
"=r"(error),
"=&r"(tmp1),
"=&r"(tmp2),
1020 "=&r"(tmp3),
"=&r"(tmp4)
1021 :
"r"(va),
"r"(*reg_addr),
"0"(0));
1049 if (
find_vma(mm, (
unsigned long)va))
1073 register unsigned long gptr
__asm__(
"$29");