2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * arch/sh64/kernel/traps.c
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2003, 2004 Paul Mundt
10 * Copyright (C) 2003, 2004 Richard Curnow
15 * 'Traps.c' handles hardware traps and faults after we have saved some
18 #include <linux/sched.h>
19 #include <linux/kernel.h>
20 #include <linux/string.h>
21 #include <linux/errno.h>
22 #include <linux/ptrace.h>
23 #include <linux/timer.h>
25 #include <linux/smp.h>
26 #include <linux/smp_lock.h>
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/spinlock.h>
30 #include <linux/kallsyms.h>
31 #include <linux/interrupt.h>
32 #include <linux/sysctl.h>
33 #include <linux/module.h>
35 #include <asm/system.h>
36 #include <asm/uaccess.h>
38 #include <asm/atomic.h>
39 #include <asm/processor.h>
40 #include <asm/pgtable.h>
42 #undef DEBUG_EXCEPTION
43 #ifdef DEBUG_EXCEPTION
44 /* implemented in ../lib/dbg.c */
45 extern void show_excp_regs(char *fname, int trapnr, int signr,
46 struct pt_regs *regs);
48 #define show_excp_regs(a, b, c, d)
51 static void do_unhandled_exception(int trapnr, int signr, char *str, char *fn_name,
52 unsigned long error_code, struct pt_regs *regs, struct task_struct *tsk);
54 #define DO_ERROR(trapnr, signr, str, name, tsk) \
55 asmlinkage void do_##name(unsigned long error_code, struct pt_regs *regs) \
57 do_unhandled_exception(trapnr, signr, str, __stringify(name), error_code, regs, current); \
62 void die(const char * str, struct pt_regs * regs, long err)
65 spin_lock_irq(&die_lock);
66 printk("%s: %lx\n", str, (err & 0xffffff));
68 spin_unlock_irq(&die_lock);
72 static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err)
78 static void die_if_no_fixup(const char * str, struct pt_regs * regs, long err)
80 if (!user_mode(regs)) {
81 const struct exception_table_entry *fixup;
82 fixup = search_exception_tables(regs->pc);
84 regs->pc = fixup->fixup;
91 DO_ERROR(13, SIGILL, "illegal slot instruction", illegal_slot_inst, current)
92 DO_ERROR(87, SIGSEGV, "address error (exec)", address_error_exec, current)
95 /* Implement misaligned load/store handling for kernel (and optionally for user
96 mode too). Limitation : only SHmedia mode code is handled - there is no
97 handling at all for misaligned accesses occurring in SHcompact code yet. */
99 static int misaligned_fixup(struct pt_regs *regs);
101 asmlinkage void do_address_error_load(unsigned long error_code, struct pt_regs *regs)
103 if (misaligned_fixup(regs) < 0) {
104 do_unhandled_exception(7, SIGSEGV, "address error(load)",
105 "do_address_error_load",
106 error_code, regs, current);
111 asmlinkage void do_address_error_store(unsigned long error_code, struct pt_regs *regs)
113 if (misaligned_fixup(regs) < 0) {
114 do_unhandled_exception(8, SIGSEGV, "address error(store)",
115 "do_address_error_store",
116 error_code, regs, current);
121 #if defined(CONFIG_SH64_ID2815_WORKAROUND)
123 #define OPCODE_INVALID 0
124 #define OPCODE_USER_VALID 1
125 #define OPCODE_PRIV_VALID 2
127 /* getcon/putcon - requires checking which control register is referenced. */
128 #define OPCODE_CTRL_REG 3
130 /* Table of valid opcodes for SHmedia mode.
131 Form a 10-bit value by concatenating the major/minor opcodes i.e.
132 opcode[31:26,20:16]. The 6 MSBs of this value index into the following
133 array. The 4 LSBs select the bit-pair in the entry (bits 1:0 correspond to
134 LSBs==4'b0000 etc). */
135 static unsigned long shmedia_opcode_table[64] = {
136 0x55554044,0x54445055,0x15141514,0x14541414,0x00000000,0x10001000,0x01110055,0x04050015,
137 0x00000444,0xc0000000,0x44545515,0x40405555,0x55550015,0x10005555,0x55555505,0x04050000,
138 0x00000555,0x00000404,0x00040445,0x15151414,0x00000000,0x00000000,0x00000000,0x00000000,
139 0x00000055,0x40404444,0x00000404,0xc0009495,0x00000000,0x00000000,0x00000000,0x00000000,
140 0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
141 0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
142 0x80005050,0x04005055,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
143 0x81055554,0x00000404,0x55555555,0x55555555,0x00000000,0x00000000,0x00000000,0x00000000
146 void do_reserved_inst(unsigned long error_code, struct pt_regs *regs)
148 /* Workaround SH5-101 cut2 silicon defect #2815 :
149 in some situations, inter-mode branches from SHcompact -> SHmedia
150 which should take ITLBMISS or EXECPROT exceptions at the target
151 falsely take RESINST at the target instead. */
153 unsigned long opcode = 0x6ff4fff0; /* guaranteed reserved opcode */
154 unsigned long pc, aligned_pc;
158 char *exception_name = "reserved_instruction";
162 /* SHmedia : check for defect. This requires executable vmas
163 to be readable too. */
164 aligned_pc = pc & ~3;
165 if (!access_ok(VERIFY_READ, aligned_pc, sizeof(unsigned long))) {
166 get_user_error = -EFAULT;
168 get_user_error = __get_user(opcode, (unsigned long *)aligned_pc);
170 if (get_user_error >= 0) {
171 unsigned long index, shift;
172 unsigned long major, minor, combined;
173 unsigned long reserved_field;
174 reserved_field = opcode & 0xf; /* These bits are currently reserved as zero in all valid opcodes */
175 major = (opcode >> 26) & 0x3f;
176 minor = (opcode >> 16) & 0xf;
177 combined = (major << 4) | minor;
180 if (reserved_field == 0) {
181 int opcode_state = (shmedia_opcode_table[index] >> shift) & 0x3;
182 switch (opcode_state) {
186 case OPCODE_USER_VALID:
187 /* Restart the instruction : the branch to the instruction will now be from an RTE
188 not from SHcompact so the silicon defect won't be triggered. */
190 case OPCODE_PRIV_VALID:
191 if (!user_mode(regs)) {
192 /* Should only ever get here if a module has
193 SHcompact code inside it. If so, the same fix up is needed. */
194 return; /* same reason */
196 /* Otherwise, user mode trying to execute a privileged instruction -
197 fall through to trap. */
199 case OPCODE_CTRL_REG:
200 /* If in privileged mode, return as above. */
201 if (!user_mode(regs)) return;
202 /* In user mode ... */
203 if (combined == 0x9f) { /* GETCON */
204 unsigned long regno = (opcode >> 20) & 0x3f;
208 /* Otherwise, reserved or privileged control register, => trap */
209 } else if (combined == 0x1bf) { /* PUTCON */
210 unsigned long regno = (opcode >> 4) & 0x3f;
214 /* Otherwise, reserved or privileged control register, => trap */
220 /* Fall through to trap. */
224 /* fall through to normal resinst processing */
226 /* Error trying to read opcode. This typically means a
227 real fault, not a RESINST any more. So change the
230 exception_name = "address error (exec)";
235 do_unhandled_exception(trapnr, signr, exception_name, "do_reserved_inst", error_code, regs, current);
238 #else /* CONFIG_SH64_ID2815_WORKAROUND */
240 /* If the workaround isn't needed, this is just a straightforward reserved
242 DO_ERROR(12, SIGILL, "reserved instruction", reserved_inst, current)
244 #endif /* CONFIG_SH64_ID2815_WORKAROUND */
247 #include <asm/system.h>
249 /* Called with interrupts disabled */
250 asmlinkage void do_exception_error(unsigned long ex, struct pt_regs *regs)
253 show_excp_regs(__FUNCTION__, -1, -1, regs);
254 die_if_kernel("exception", regs, ex);
257 int do_unknown_trapa(unsigned long scId, struct pt_regs *regs)
260 printk("System call ID error: [0x1#args:8 #syscall:16 0x%lx]\n", scId);
262 die_if_kernel("unknown trapa", regs, scId);
267 void show_stack(struct task_struct *tsk, unsigned long *sp)
269 #ifdef CONFIG_KALLSYMS
270 extern void sh64_unwind(struct pt_regs *regs);
271 struct pt_regs *regs;
273 regs = tsk ? tsk->thread.kregs : NULL;
277 printk(KERN_ERR "Can't backtrace on sh64 without CONFIG_KALLSYMS\n");
281 void show_task(unsigned long *sp)
283 show_stack(NULL, sp);
286 void dump_stack(void)
290 /* Needed by any user of WARN_ON in view of the defn in include/asm-sh/bug.h */
291 EXPORT_SYMBOL(dump_stack);
293 static void do_unhandled_exception(int trapnr, int signr, char *str, char *fn_name,
294 unsigned long error_code, struct pt_regs *regs, struct task_struct *tsk)
296 show_excp_regs(fn_name, trapnr, signr, regs);
297 tsk->thread.error_code = error_code;
298 tsk->thread.trap_no = trapnr;
301 force_sig(signr, tsk);
303 die_if_no_fixup(str, regs, error_code);
306 static int read_opcode(unsigned long long pc, unsigned long *result_opcode, int from_user_mode)
309 unsigned long aligned_pc;
310 unsigned long opcode;
314 aligned_pc = pc & ~3;
315 if (from_user_mode) {
316 if (!access_ok(VERIFY_READ, aligned_pc, sizeof(unsigned long))) {
317 get_user_error = -EFAULT;
319 get_user_error = __get_user(opcode, (unsigned long *)aligned_pc);
320 *result_opcode = opcode;
322 return get_user_error;
324 /* If the fault was in the kernel, we can either read
325 * this directly, or if not, we fault.
327 *result_opcode = *(unsigned long *) aligned_pc;
330 } else if ((pc & 1) == 0) {
332 /* TODO : provide handling for this. We don't really support
333 user-mode SHcompact yet, and for a kernel fault, this would
334 have to come from a module built for SHcompact. */
342 static int address_is_sign_extended(__u64 a)
346 b = (__u64)(__s64)(__s32)(a & 0xffffffffUL);
347 return (b == a) ? 1 : 0;
349 #error "Sign extend check only works for NEFF==32"
353 static int generate_and_check_address(struct pt_regs *regs,
355 int displacement_not_indexed,
359 /* return -1 for fault, 0 for OK */
361 __u64 base_address, addr;
364 basereg = (opcode >> 20) & 0x3f;
365 base_address = regs->regs[basereg];
366 if (displacement_not_indexed) {
368 displacement = (opcode >> 10) & 0x3ff;
369 displacement = ((displacement << 54) >> 54); /* sign extend */
370 addr = (__u64)((__s64)base_address + (displacement << width_shift));
374 offsetreg = (opcode >> 10) & 0x3f;
375 offset = regs->regs[offsetreg];
376 addr = base_address + offset;
379 /* Check sign extended */
380 if (!address_is_sign_extended(addr)) {
384 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
385 /* Check accessible. For misaligned access in the kernel, assume the
386 address is always accessible (and if not, just fault when the
387 load/store gets done.) */
388 if (user_mode(regs)) {
389 if (addr >= TASK_SIZE) {
392 /* Do access_ok check later - it depends on whether it's a load or a store. */
400 /* Default value as for sh */
401 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
402 static int user_mode_unaligned_fixup_count = 10;
403 static int user_mode_unaligned_fixup_enable = 1;
406 static int kernel_mode_unaligned_fixup_count = 32;
408 static void misaligned_kernel_word_load(__u64 address, int do_sign_extend, __u64 *result)
411 unsigned char *p, *q;
412 p = (unsigned char *) (int) address;
413 q = (unsigned char *) &x;
417 if (do_sign_extend) {
418 *result = (__u64)(__s64) *(short *) &x;
424 static void misaligned_kernel_word_store(__u64 address, __u64 value)
427 unsigned char *p, *q;
428 p = (unsigned char *) (int) address;
429 q = (unsigned char *) &x;
436 static int misaligned_load(struct pt_regs *regs,
438 int displacement_not_indexed,
442 /* Return -1 for a fault, 0 for OK */
447 error = generate_and_check_address(regs, opcode,
448 displacement_not_indexed, width_shift, &address);
453 destreg = (opcode >> 4) & 0x3f;
454 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
455 if (user_mode(regs)) {
458 if (!access_ok(VERIFY_READ, (unsigned long) address, 1UL<<width_shift)) {
462 if (__copy_user(&buffer, (const void *)(int)address, (1 << width_shift)) > 0) {
463 return -1; /* fault */
465 switch (width_shift) {
467 if (do_sign_extend) {
468 regs->regs[destreg] = (__u64)(__s64) *(__s16 *) &buffer;
470 regs->regs[destreg] = (__u64) *(__u16 *) &buffer;
474 regs->regs[destreg] = (__u64)(__s64) *(__s32 *) &buffer;
477 regs->regs[destreg] = buffer;
480 printk("Unexpected width_shift %d in misaligned_load, PC=%08lx\n",
481 width_shift, (unsigned long) regs->pc);
487 /* kernel mode - we can take short cuts since if we fault, it's a genuine bug */
490 switch (width_shift) {
492 misaligned_kernel_word_load(address, do_sign_extend, ®s->regs[destreg]);
495 asm ("ldlo.l %1, 0, %0" : "=r" (lo) : "r" (address));
496 asm ("ldhi.l %1, 3, %0" : "=r" (hi) : "r" (address));
497 regs->regs[destreg] = lo | hi;
500 asm ("ldlo.q %1, 0, %0" : "=r" (lo) : "r" (address));
501 asm ("ldhi.q %1, 7, %0" : "=r" (hi) : "r" (address));
502 regs->regs[destreg] = lo | hi;
506 printk("Unexpected width_shift %d in misaligned_load, PC=%08lx\n",
507 width_shift, (unsigned long) regs->pc);
516 static int misaligned_store(struct pt_regs *regs,
518 int displacement_not_indexed,
521 /* Return -1 for a fault, 0 for OK */
526 error = generate_and_check_address(regs, opcode,
527 displacement_not_indexed, width_shift, &address);
532 srcreg = (opcode >> 4) & 0x3f;
533 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
534 if (user_mode(regs)) {
537 if (!access_ok(VERIFY_WRITE, (unsigned long) address, 1UL<<width_shift)) {
541 switch (width_shift) {
543 *(__u16 *) &buffer = (__u16) regs->regs[srcreg];
546 *(__u32 *) &buffer = (__u32) regs->regs[srcreg];
549 buffer = regs->regs[srcreg];
552 printk("Unexpected width_shift %d in misaligned_store, PC=%08lx\n",
553 width_shift, (unsigned long) regs->pc);
557 if (__copy_user((void *)(int)address, &buffer, (1 << width_shift)) > 0) {
558 return -1; /* fault */
563 /* kernel mode - we can take short cuts since if we fault, it's a genuine bug */
564 __u64 val = regs->regs[srcreg];
566 switch (width_shift) {
568 misaligned_kernel_word_store(address, val);
571 asm ("stlo.l %1, 0, %0" : : "r" (val), "r" (address));
572 asm ("sthi.l %1, 3, %0" : : "r" (val), "r" (address));
575 asm ("stlo.q %1, 0, %0" : : "r" (val), "r" (address));
576 asm ("sthi.q %1, 7, %0" : : "r" (val), "r" (address));
580 printk("Unexpected width_shift %d in misaligned_store, PC=%08lx\n",
581 width_shift, (unsigned long) regs->pc);
590 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
591 /* Never need to fix up misaligned FPU accesses within the kernel since that's a real
593 static int misaligned_fpu_load(struct pt_regs *regs,
595 int displacement_not_indexed,
599 /* Return -1 for a fault, 0 for OK */
604 error = generate_and_check_address(regs, opcode,
605 displacement_not_indexed, width_shift, &address);
610 destreg = (opcode >> 4) & 0x3f;
611 if (user_mode(regs)) {
615 if (!access_ok(VERIFY_READ, (unsigned long) address, 1UL<<width_shift)) {
619 if (__copy_user(&buffer, (const void *)(int)address, (1 << width_shift)) > 0) {
620 return -1; /* fault */
622 /* 'current' may be the current owner of the FPU state, so
623 context switch the registers into memory so they can be
624 indexed by register number. */
625 if (last_task_used_math == current) {
627 fpsave(¤t->thread.fpu.hard);
629 last_task_used_math = NULL;
633 buflo = *(__u32*) &buffer;
634 bufhi = *(1 + (__u32*) &buffer);
636 switch (width_shift) {
638 current->thread.fpu.hard.fp_regs[destreg] = buflo;
641 if (do_paired_load) {
642 current->thread.fpu.hard.fp_regs[destreg] = buflo;
643 current->thread.fpu.hard.fp_regs[destreg+1] = bufhi;
645 #if defined(CONFIG_LITTLE_ENDIAN)
646 current->thread.fpu.hard.fp_regs[destreg] = bufhi;
647 current->thread.fpu.hard.fp_regs[destreg+1] = buflo;
649 current->thread.fpu.hard.fp_regs[destreg] = buflo;
650 current->thread.fpu.hard.fp_regs[destreg+1] = bufhi;
655 printk("Unexpected width_shift %d in misaligned_fpu_load, PC=%08lx\n",
656 width_shift, (unsigned long) regs->pc);
661 die ("Misaligned FPU load inside kernel", regs, 0);
668 static int misaligned_fpu_store(struct pt_regs *regs,
670 int displacement_not_indexed,
674 /* Return -1 for a fault, 0 for OK */
679 error = generate_and_check_address(regs, opcode,
680 displacement_not_indexed, width_shift, &address);
685 srcreg = (opcode >> 4) & 0x3f;
686 if (user_mode(regs)) {
688 /* Initialise these to NaNs. */
689 __u32 buflo=0xffffffffUL, bufhi=0xffffffffUL;
691 if (!access_ok(VERIFY_WRITE, (unsigned long) address, 1UL<<width_shift)) {
695 /* 'current' may be the current owner of the FPU state, so
696 context switch the registers into memory so they can be
697 indexed by register number. */
698 if (last_task_used_math == current) {
700 fpsave(¤t->thread.fpu.hard);
702 last_task_used_math = NULL;
706 switch (width_shift) {
708 buflo = current->thread.fpu.hard.fp_regs[srcreg];
711 if (do_paired_load) {
712 buflo = current->thread.fpu.hard.fp_regs[srcreg];
713 bufhi = current->thread.fpu.hard.fp_regs[srcreg+1];
715 #if defined(CONFIG_LITTLE_ENDIAN)
716 bufhi = current->thread.fpu.hard.fp_regs[srcreg];
717 buflo = current->thread.fpu.hard.fp_regs[srcreg+1];
719 buflo = current->thread.fpu.hard.fp_regs[srcreg];
720 bufhi = current->thread.fpu.hard.fp_regs[srcreg+1];
725 printk("Unexpected width_shift %d in misaligned_fpu_store, PC=%08lx\n",
726 width_shift, (unsigned long) regs->pc);
730 *(__u32*) &buffer = buflo;
731 *(1 + (__u32*) &buffer) = bufhi;
732 if (__copy_user((void *)(int)address, &buffer, (1 << width_shift)) > 0) {
733 return -1; /* fault */
737 die ("Misaligned FPU load inside kernel", regs, 0);
743 static int misaligned_fixup(struct pt_regs *regs)
745 unsigned long opcode;
749 #if !defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
750 /* Never fixup user mode misaligned accesses without this option enabled. */
753 if (!user_mode_unaligned_fixup_enable) return -1;
756 error = read_opcode(regs->pc, &opcode, user_mode(regs));
760 major = (opcode >> 26) & 0x3f;
761 minor = (opcode >> 16) & 0xf;
763 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
764 if (user_mode(regs) && (user_mode_unaligned_fixup_count > 0)) {
765 --user_mode_unaligned_fixup_count;
766 /* Only do 'count' worth of these reports, to remove a potential DoS against syslog */
767 printk("Fixing up unaligned userspace access in \"%s\" pid=%d pc=0x%08x ins=0x%08lx\n",
768 current->comm, current->pid, (__u32)regs->pc, opcode);
771 if (!user_mode(regs) && (kernel_mode_unaligned_fixup_count > 0)) {
772 --kernel_mode_unaligned_fixup_count;
773 if (in_interrupt()) {
774 printk("Fixing up unaligned kernelspace access in interrupt pc=0x%08x ins=0x%08lx\n",
775 (__u32)regs->pc, opcode);
777 printk("Fixing up unaligned kernelspace access in \"%s\" pid=%d pc=0x%08x ins=0x%08lx\n",
778 current->comm, current->pid, (__u32)regs->pc, opcode);
784 case (0x84>>2): /* LD.W */
785 error = misaligned_load(regs, opcode, 1, 1, 1);
787 case (0xb0>>2): /* LD.UW */
788 error = misaligned_load(regs, opcode, 1, 1, 0);
790 case (0x88>>2): /* LD.L */
791 error = misaligned_load(regs, opcode, 1, 2, 1);
793 case (0x8c>>2): /* LD.Q */
794 error = misaligned_load(regs, opcode, 1, 3, 0);
797 case (0xa4>>2): /* ST.W */
798 error = misaligned_store(regs, opcode, 1, 1);
800 case (0xa8>>2): /* ST.L */
801 error = misaligned_store(regs, opcode, 1, 2);
803 case (0xac>>2): /* ST.Q */
804 error = misaligned_store(regs, opcode, 1, 3);
807 case (0x40>>2): /* indexed loads */
809 case 0x1: /* LDX.W */
810 error = misaligned_load(regs, opcode, 0, 1, 1);
812 case 0x5: /* LDX.UW */
813 error = misaligned_load(regs, opcode, 0, 1, 0);
815 case 0x2: /* LDX.L */
816 error = misaligned_load(regs, opcode, 0, 2, 1);
818 case 0x3: /* LDX.Q */
819 error = misaligned_load(regs, opcode, 0, 3, 0);
827 case (0x60>>2): /* indexed stores */
829 case 0x1: /* STX.W */
830 error = misaligned_store(regs, opcode, 0, 1);
832 case 0x2: /* STX.L */
833 error = misaligned_store(regs, opcode, 0, 2);
835 case 0x3: /* STX.Q */
836 error = misaligned_store(regs, opcode, 0, 3);
844 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
845 case (0x94>>2): /* FLD.S */
846 error = misaligned_fpu_load(regs, opcode, 1, 2, 0);
848 case (0x98>>2): /* FLD.P */
849 error = misaligned_fpu_load(regs, opcode, 1, 3, 1);
851 case (0x9c>>2): /* FLD.D */
852 error = misaligned_fpu_load(regs, opcode, 1, 3, 0);
854 case (0x1c>>2): /* floating indexed loads */
856 case 0x8: /* FLDX.S */
857 error = misaligned_fpu_load(regs, opcode, 0, 2, 0);
859 case 0xd: /* FLDX.P */
860 error = misaligned_fpu_load(regs, opcode, 0, 3, 1);
862 case 0x9: /* FLDX.D */
863 error = misaligned_fpu_load(regs, opcode, 0, 3, 0);
870 case (0xb4>>2): /* FLD.S */
871 error = misaligned_fpu_store(regs, opcode, 1, 2, 0);
873 case (0xb8>>2): /* FLD.P */
874 error = misaligned_fpu_store(regs, opcode, 1, 3, 1);
876 case (0xbc>>2): /* FLD.D */
877 error = misaligned_fpu_store(regs, opcode, 1, 3, 0);
879 case (0x3c>>2): /* floating indexed stores */
881 case 0x8: /* FSTX.S */
882 error = misaligned_fpu_store(regs, opcode, 0, 2, 0);
884 case 0xd: /* FSTX.P */
885 error = misaligned_fpu_store(regs, opcode, 0, 3, 1);
887 case 0x9: /* FSTX.D */
888 error = misaligned_fpu_store(regs, opcode, 0, 3, 0);
906 regs->pc += 4; /* Skip the instruction that's just been emulated */
912 static ctl_table unaligned_table[] = {
913 {1, "kernel_reports", &kernel_mode_unaligned_fixup_count,
914 sizeof(int), 0644, NULL, &proc_dointvec},
915 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
916 {2, "user_reports", &user_mode_unaligned_fixup_count,
917 sizeof(int), 0644, NULL, &proc_dointvec},
918 {3, "user_enable", &user_mode_unaligned_fixup_enable,
919 sizeof(int), 0644, NULL, &proc_dointvec},
924 static ctl_table unaligned_root[] = {
925 {1, "unaligned_fixup", NULL, 0, 0555, unaligned_table},
929 static ctl_table sh64_root[] = {
930 {1, "sh64", NULL, 0, 0555, unaligned_root},
933 static struct ctl_table_header *sysctl_header;
934 static int __init init_sysctl(void)
936 sysctl_header = register_sysctl_table(sh64_root, 0);
940 __initcall(init_sysctl);
943 asmlinkage void do_debug_interrupt(unsigned long code, struct pt_regs *regs)
945 u64 peek_real_address_q(u64 addr);
946 u64 poke_real_address_q(u64 addr, u64 val);
947 unsigned long long DM_EXP_CAUSE_PHY = 0x0c100010;
948 unsigned long long exp_cause;
949 /* It's not worth ioremapping the debug module registers for the amount
950 of access we make to them - just go direct to their physical
952 exp_cause = peek_real_address_q(DM_EXP_CAUSE_PHY);
953 if (exp_cause & ~4) {
954 printk("DM.EXP_CAUSE had unexpected bits set (=%08lx)\n",
955 (unsigned long)(exp_cause & 0xffffffff));
958 /* Clear all DEBUGINT causes */
959 poke_real_address_q(DM_EXP_CAUSE_PHY, 0x0);