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>
34 #include <asm/system.h>
35 #include <asm/uaccess.h>
37 #include <asm/atomic.h>
38 #include <asm/processor.h>
39 #include <asm/pgtable.h>
41 #undef DEBUG_EXCEPTION
42 #ifdef DEBUG_EXCEPTION
43 /* implemented in ../lib/dbg.c */
44 extern void show_excp_regs(char *fname, int trapnr, int signr,
45 struct pt_regs *regs);
47 #define show_excp_regs(a, b, c, d)
50 static void do_unhandled_exception(int trapnr, int signr, char *str, char *fn_name,
51 unsigned long error_code, struct pt_regs *regs, struct task_struct *tsk);
53 #define DO_ERROR(trapnr, signr, str, name, tsk) \
54 asmlinkage void do_##name(unsigned long error_code, struct pt_regs *regs) \
56 do_unhandled_exception(trapnr, signr, str, __stringify(name), error_code, regs, current); \
61 void die(const char * str, struct pt_regs * regs, long err)
64 spin_lock_irq(&die_lock);
65 printk("%s: %lx\n", str, (err & 0xffffff));
67 spin_unlock_irq(&die_lock);
71 static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err)
77 static void die_if_no_fixup(const char * str, struct pt_regs * regs, long err)
79 if (!user_mode(regs)) {
80 const struct exception_table_entry *fixup;
81 fixup = search_exception_tables(regs->pc);
83 regs->pc = fixup->fixup;
90 DO_ERROR(13, SIGILL, "illegal slot instruction", illegal_slot_inst, current)
91 DO_ERROR(87, SIGSEGV, "address error (exec)", address_error_exec, current)
94 /* Implement misaligned load/store handling for kernel (and optionally for user
95 mode too). Limitation : only SHmedia mode code is handled - there is no
96 handling at all for misaligned accesses occurring in SHcompact code yet. */
98 static int misaligned_fixup(struct pt_regs *regs);
100 asmlinkage void do_address_error_load(unsigned long error_code, struct pt_regs *regs)
102 if (misaligned_fixup(regs) < 0) {
103 do_unhandled_exception(7, SIGSEGV, "address error(load)",
104 "do_address_error_load",
105 error_code, regs, current);
110 asmlinkage void do_address_error_store(unsigned long error_code, struct pt_regs *regs)
112 if (misaligned_fixup(regs) < 0) {
113 do_unhandled_exception(8, SIGSEGV, "address error(store)",
114 "do_address_error_store",
115 error_code, regs, current);
120 #if defined(CONFIG_SH64_ID2815_WORKAROUND)
122 #define OPCODE_INVALID 0
123 #define OPCODE_USER_VALID 1
124 #define OPCODE_PRIV_VALID 2
126 /* getcon/putcon - requires checking which control register is referenced. */
127 #define OPCODE_CTRL_REG 3
129 /* Table of valid opcodes for SHmedia mode.
130 Form a 10-bit value by concatenating the major/minor opcodes i.e.
131 opcode[31:26,20:16]. The 6 MSBs of this value index into the following
132 array. The 4 LSBs select the bit-pair in the entry (bits 1:0 correspond to
133 LSBs==4'b0000 etc). */
134 static unsigned long shmedia_opcode_table[64] = {
135 0x55554044,0x54445055,0x15141514,0x14541414,0x00000000,0x10001000,0x01110055,0x04050015,
136 0x00000444,0xc0000000,0x44545515,0x40405555,0x55550015,0x10005555,0x55555505,0x04050000,
137 0x00000555,0x00000404,0x00040445,0x15151414,0x00000000,0x00000000,0x00000000,0x00000000,
138 0x00000055,0x40404444,0x00000404,0xc0009495,0x00000000,0x00000000,0x00000000,0x00000000,
139 0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
140 0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
141 0x80005050,0x04005055,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
142 0x81055554,0x00000404,0x55555555,0x55555555,0x00000000,0x00000000,0x00000000,0x00000000
145 void do_reserved_inst(unsigned long error_code, struct pt_regs *regs)
147 /* Workaround SH5-101 cut2 silicon defect #2815 :
148 in some situations, inter-mode branches from SHcompact -> SHmedia
149 which should take ITLBMISS or EXECPROT exceptions at the target
150 falsely take RESINST at the target instead. */
152 unsigned long opcode = 0x6ff4fff0; /* guaranteed reserved opcode */
153 unsigned long pc, aligned_pc;
157 char *exception_name = "reserved_instruction";
161 /* SHmedia : check for defect. This requires executable vmas
162 to be readable too. */
163 aligned_pc = pc & ~3;
164 if (!access_ok(VERIFY_READ, aligned_pc, sizeof(unsigned long))) {
165 get_user_error = -EFAULT;
167 get_user_error = __get_user(opcode, (unsigned long *)aligned_pc);
169 if (get_user_error >= 0) {
170 unsigned long index, shift;
171 unsigned long major, minor, combined;
172 unsigned long reserved_field;
173 reserved_field = opcode & 0xf; /* These bits are currently reserved as zero in all valid opcodes */
174 major = (opcode >> 26) & 0x3f;
175 minor = (opcode >> 16) & 0xf;
176 combined = (major << 4) | minor;
179 if (reserved_field == 0) {
180 int opcode_state = (shmedia_opcode_table[index] >> shift) & 0x3;
181 switch (opcode_state) {
185 case OPCODE_USER_VALID:
186 /* Restart the instruction : the branch to the instruction will now be from an RTE
187 not from SHcompact so the silicon defect won't be triggered. */
189 case OPCODE_PRIV_VALID:
190 if (!user_mode(regs)) {
191 /* Should only ever get here if a module has
192 SHcompact code inside it. If so, the same fix up is needed. */
193 return; /* same reason */
195 /* Otherwise, user mode trying to execute a privileged instruction -
196 fall through to trap. */
198 case OPCODE_CTRL_REG:
199 /* If in privileged mode, return as above. */
200 if (!user_mode(regs)) return;
201 /* In user mode ... */
202 if (combined == 0x9f) { /* GETCON */
203 unsigned long regno = (opcode >> 20) & 0x3f;
207 /* Otherwise, reserved or privileged control register, => trap */
208 } else if (combined == 0x1bf) { /* PUTCON */
209 unsigned long regno = (opcode >> 4) & 0x3f;
213 /* Otherwise, reserved or privileged control register, => trap */
219 /* Fall through to trap. */
223 /* fall through to normal resinst processing */
225 /* Error trying to read opcode. This typically means a
226 real fault, not a RESINST any more. So change the
229 exception_name = "address error (exec)";
234 do_unhandled_exception(trapnr, signr, exception_name, "do_reserved_inst", error_code, regs, current);
237 #else /* CONFIG_SH64_ID2815_WORKAROUND */
239 /* If the workaround isn't needed, this is just a straightforward reserved
241 DO_ERROR(12, SIGILL, "reserved instruction", reserved_inst, current)
243 #endif /* CONFIG_SH64_ID2815_WORKAROUND */
246 #include <asm/system.h>
248 /* Called with interrupts disabled */
249 asmlinkage void do_exception_error(unsigned long ex, struct pt_regs *regs)
252 show_excp_regs(__FUNCTION__, -1, -1, regs);
253 die_if_kernel("exception", regs, ex);
256 int do_unknown_trapa(unsigned long scId, struct pt_regs *regs)
259 printk("System call ID error: [0x1#args:8 #syscall:16 0x%lx]\n", scId);
261 die_if_kernel("unknown trapa", regs, scId);
266 void show_stack(struct task_struct *tsk, unsigned long *sp)
268 #ifdef CONFIG_KALLSYMS
269 extern void sh64_unwind(struct pt_regs *regs);
270 struct pt_regs *regs;
272 regs = tsk ? tsk->thread.kregs : NULL;
276 printk(KERN_ERR "Can't backtrace on sh64 without CONFIG_KALLSYMS\n");
280 void show_task(unsigned long *sp)
282 show_stack(NULL, sp);
285 void dump_stack(void)
290 static void do_unhandled_exception(int trapnr, int signr, char *str, char *fn_name,
291 unsigned long error_code, struct pt_regs *regs, struct task_struct *tsk)
293 show_excp_regs(fn_name, trapnr, signr, regs);
294 tsk->thread.error_code = error_code;
295 tsk->thread.trap_no = trapnr;
298 force_sig(signr, tsk);
300 die_if_no_fixup(str, regs, error_code);
303 static int read_opcode(unsigned long long pc, unsigned long *result_opcode, int from_user_mode)
306 unsigned long aligned_pc;
307 unsigned long opcode;
311 aligned_pc = pc & ~3;
312 if (from_user_mode) {
313 if (!access_ok(VERIFY_READ, aligned_pc, sizeof(unsigned long))) {
314 get_user_error = -EFAULT;
316 get_user_error = __get_user(opcode, (unsigned long *)aligned_pc);
317 *result_opcode = opcode;
319 return get_user_error;
321 /* If the fault was in the kernel, we can either read
322 * this directly, or if not, we fault.
324 *result_opcode = *(unsigned long *) aligned_pc;
327 } else if ((pc & 1) == 0) {
329 /* TODO : provide handling for this. We don't really support
330 user-mode SHcompact yet, and for a kernel fault, this would
331 have to come from a module built for SHcompact. */
339 static int address_is_sign_extended(__u64 a)
343 b = (__u64)(__s64)(__s32)(a & 0xffffffffUL);
344 return (b == a) ? 1 : 0;
346 #error "Sign extend check only works for NEFF==32"
350 static int generate_and_check_address(struct pt_regs *regs,
352 int displacement_not_indexed,
356 /* return -1 for fault, 0 for OK */
358 __u64 base_address, addr;
361 basereg = (opcode >> 20) & 0x3f;
362 base_address = regs->regs[basereg];
363 if (displacement_not_indexed) {
365 displacement = (opcode >> 10) & 0x3ff;
366 displacement = ((displacement << 54) >> 54); /* sign extend */
367 addr = (__u64)((__s64)base_address + (displacement << width_shift));
371 offsetreg = (opcode >> 10) & 0x3f;
372 offset = regs->regs[offsetreg];
373 addr = base_address + offset;
376 /* Check sign extended */
377 if (!address_is_sign_extended(addr)) {
381 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
382 /* Check accessible. For misaligned access in the kernel, assume the
383 address is always accessible (and if not, just fault when the
384 load/store gets done.) */
385 if (user_mode(regs)) {
386 if (addr >= TASK_SIZE) {
389 /* Do access_ok check later - it depends on whether it's a load or a store. */
397 /* Default value as for sh */
398 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
399 static int user_mode_unaligned_fixup_count = 10;
400 static int user_mode_unaligned_fixup_enable = 1;
403 static int kernel_mode_unaligned_fixup_count = 32;
405 static void misaligned_kernel_word_load(__u64 address, int do_sign_extend, __u64 *result)
408 unsigned char *p, *q;
409 p = (unsigned char *) (int) address;
410 q = (unsigned char *) &x;
414 if (do_sign_extend) {
415 *result = (__u64)(__s64) *(short *) &x;
421 static void misaligned_kernel_word_store(__u64 address, __u64 value)
424 unsigned char *p, *q;
425 p = (unsigned char *) (int) address;
426 q = (unsigned char *) &x;
433 static int misaligned_load(struct pt_regs *regs,
435 int displacement_not_indexed,
439 /* Return -1 for a fault, 0 for OK */
444 error = generate_and_check_address(regs, opcode,
445 displacement_not_indexed, width_shift, &address);
450 destreg = (opcode >> 4) & 0x3f;
451 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
452 if (user_mode(regs)) {
455 if (!access_ok(VERIFY_READ, (unsigned long) address, 1UL<<width_shift)) {
459 if (__copy_user(&buffer, (const void *)(int)address, (1 << width_shift)) > 0) {
460 return -1; /* fault */
462 switch (width_shift) {
464 if (do_sign_extend) {
465 regs->regs[destreg] = (__u64)(__s64) *(__s16 *) &buffer;
467 regs->regs[destreg] = (__u64) *(__u16 *) &buffer;
471 regs->regs[destreg] = (__u64)(__s64) *(__s32 *) &buffer;
474 regs->regs[destreg] = buffer;
477 printk("Unexpected width_shift %d in misaligned_load, PC=%08lx\n",
478 width_shift, (unsigned long) regs->pc);
484 /* kernel mode - we can take short cuts since if we fault, it's a genuine bug */
487 switch (width_shift) {
489 misaligned_kernel_word_load(address, do_sign_extend, ®s->regs[destreg]);
492 asm ("ldlo.l %1, 0, %0" : "=r" (lo) : "r" (address));
493 asm ("ldhi.l %1, 3, %0" : "=r" (hi) : "r" (address));
494 regs->regs[destreg] = lo | hi;
497 asm ("ldlo.q %1, 0, %0" : "=r" (lo) : "r" (address));
498 asm ("ldhi.q %1, 7, %0" : "=r" (hi) : "r" (address));
499 regs->regs[destreg] = lo | hi;
503 printk("Unexpected width_shift %d in misaligned_load, PC=%08lx\n",
504 width_shift, (unsigned long) regs->pc);
513 static int misaligned_store(struct pt_regs *regs,
515 int displacement_not_indexed,
518 /* Return -1 for a fault, 0 for OK */
523 error = generate_and_check_address(regs, opcode,
524 displacement_not_indexed, width_shift, &address);
529 srcreg = (opcode >> 4) & 0x3f;
530 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
531 if (user_mode(regs)) {
534 if (!access_ok(VERIFY_WRITE, (unsigned long) address, 1UL<<width_shift)) {
538 switch (width_shift) {
540 *(__u16 *) &buffer = (__u16) regs->regs[srcreg];
543 *(__u32 *) &buffer = (__u32) regs->regs[srcreg];
546 buffer = regs->regs[srcreg];
549 printk("Unexpected width_shift %d in misaligned_store, PC=%08lx\n",
550 width_shift, (unsigned long) regs->pc);
554 if (__copy_user((void *)(int)address, &buffer, (1 << width_shift)) > 0) {
555 return -1; /* fault */
560 /* kernel mode - we can take short cuts since if we fault, it's a genuine bug */
561 __u64 val = regs->regs[srcreg];
563 switch (width_shift) {
565 misaligned_kernel_word_store(address, val);
568 asm ("stlo.l %1, 0, %0" : : "r" (val), "r" (address));
569 asm ("sthi.l %1, 3, %0" : : "r" (val), "r" (address));
572 asm ("stlo.q %1, 0, %0" : : "r" (val), "r" (address));
573 asm ("sthi.q %1, 7, %0" : : "r" (val), "r" (address));
577 printk("Unexpected width_shift %d in misaligned_store, PC=%08lx\n",
578 width_shift, (unsigned long) regs->pc);
587 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
588 /* Never need to fix up misaligned FPU accesses within the kernel since that's a real
590 static int misaligned_fpu_load(struct pt_regs *regs,
592 int displacement_not_indexed,
596 /* Return -1 for a fault, 0 for OK */
601 error = generate_and_check_address(regs, opcode,
602 displacement_not_indexed, width_shift, &address);
607 destreg = (opcode >> 4) & 0x3f;
608 if (user_mode(regs)) {
612 if (!access_ok(VERIFY_READ, (unsigned long) address, 1UL<<width_shift)) {
616 if (__copy_user(&buffer, (const void *)(int)address, (1 << width_shift)) > 0) {
617 return -1; /* fault */
619 /* 'current' may be the current owner of the FPU state, so
620 context switch the registers into memory so they can be
621 indexed by register number. */
622 if (last_task_used_math == current) {
624 fpsave(¤t->thread.fpu.hard);
626 last_task_used_math = NULL;
630 buflo = *(__u32*) &buffer;
631 bufhi = *(1 + (__u32*) &buffer);
633 switch (width_shift) {
635 current->thread.fpu.hard.fp_regs[destreg] = buflo;
638 if (do_paired_load) {
639 current->thread.fpu.hard.fp_regs[destreg] = buflo;
640 current->thread.fpu.hard.fp_regs[destreg+1] = bufhi;
642 #if defined(CONFIG_LITTLE_ENDIAN)
643 current->thread.fpu.hard.fp_regs[destreg] = bufhi;
644 current->thread.fpu.hard.fp_regs[destreg+1] = buflo;
646 current->thread.fpu.hard.fp_regs[destreg] = buflo;
647 current->thread.fpu.hard.fp_regs[destreg+1] = bufhi;
652 printk("Unexpected width_shift %d in misaligned_fpu_load, PC=%08lx\n",
653 width_shift, (unsigned long) regs->pc);
658 die ("Misaligned FPU load inside kernel", regs, 0);
665 static int misaligned_fpu_store(struct pt_regs *regs,
667 int displacement_not_indexed,
671 /* Return -1 for a fault, 0 for OK */
676 error = generate_and_check_address(regs, opcode,
677 displacement_not_indexed, width_shift, &address);
682 srcreg = (opcode >> 4) & 0x3f;
683 if (user_mode(regs)) {
685 /* Initialise these to NaNs. */
686 __u32 buflo=0xffffffffUL, bufhi=0xffffffffUL;
688 if (!access_ok(VERIFY_WRITE, (unsigned long) address, 1UL<<width_shift)) {
692 /* 'current' may be the current owner of the FPU state, so
693 context switch the registers into memory so they can be
694 indexed by register number. */
695 if (last_task_used_math == current) {
697 fpsave(¤t->thread.fpu.hard);
699 last_task_used_math = NULL;
703 switch (width_shift) {
705 buflo = current->thread.fpu.hard.fp_regs[srcreg];
708 if (do_paired_load) {
709 buflo = current->thread.fpu.hard.fp_regs[srcreg];
710 bufhi = current->thread.fpu.hard.fp_regs[srcreg+1];
712 #if defined(CONFIG_LITTLE_ENDIAN)
713 bufhi = current->thread.fpu.hard.fp_regs[srcreg];
714 buflo = current->thread.fpu.hard.fp_regs[srcreg+1];
716 buflo = current->thread.fpu.hard.fp_regs[srcreg];
717 bufhi = current->thread.fpu.hard.fp_regs[srcreg+1];
722 printk("Unexpected width_shift %d in misaligned_fpu_store, PC=%08lx\n",
723 width_shift, (unsigned long) regs->pc);
727 *(__u32*) &buffer = buflo;
728 *(1 + (__u32*) &buffer) = bufhi;
729 if (__copy_user((void *)(int)address, &buffer, (1 << width_shift)) > 0) {
730 return -1; /* fault */
734 die ("Misaligned FPU load inside kernel", regs, 0);
740 static int misaligned_fixup(struct pt_regs *regs)
742 unsigned long opcode;
746 #if !defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
747 /* Never fixup user mode misaligned accesses without this option enabled. */
750 if (!user_mode_unaligned_fixup_enable) return -1;
753 error = read_opcode(regs->pc, &opcode, user_mode(regs));
757 major = (opcode >> 26) & 0x3f;
758 minor = (opcode >> 16) & 0xf;
760 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
761 if (user_mode(regs) && (user_mode_unaligned_fixup_count > 0)) {
762 --user_mode_unaligned_fixup_count;
763 /* Only do 'count' worth of these reports, to remove a potential DoS against syslog */
764 printk("Fixing up unaligned userspace access in \"%s\" pid=%d pc=0x%08x ins=0x%08lx\n",
765 current->comm, current->pid, (__u32)regs->pc, opcode);
768 if (!user_mode(regs) && (kernel_mode_unaligned_fixup_count > 0)) {
769 --kernel_mode_unaligned_fixup_count;
770 if (in_interrupt()) {
771 printk("Fixing up unaligned kernelspace access in interrupt pc=0x%08x ins=0x%08lx\n",
772 (__u32)regs->pc, opcode);
774 printk("Fixing up unaligned kernelspace access in \"%s\" pid=%d pc=0x%08x ins=0x%08lx\n",
775 current->comm, current->pid, (__u32)regs->pc, opcode);
781 case (0x84>>2): /* LD.W */
782 error = misaligned_load(regs, opcode, 1, 1, 1);
784 case (0xb0>>2): /* LD.UW */
785 error = misaligned_load(regs, opcode, 1, 1, 0);
787 case (0x88>>2): /* LD.L */
788 error = misaligned_load(regs, opcode, 1, 2, 1);
790 case (0x8c>>2): /* LD.Q */
791 error = misaligned_load(regs, opcode, 1, 3, 0);
794 case (0xa4>>2): /* ST.W */
795 error = misaligned_store(regs, opcode, 1, 1);
797 case (0xa8>>2): /* ST.L */
798 error = misaligned_store(regs, opcode, 1, 2);
800 case (0xac>>2): /* ST.Q */
801 error = misaligned_store(regs, opcode, 1, 3);
804 case (0x40>>2): /* indexed loads */
806 case 0x1: /* LDX.W */
807 error = misaligned_load(regs, opcode, 0, 1, 1);
809 case 0x5: /* LDX.UW */
810 error = misaligned_load(regs, opcode, 0, 1, 0);
812 case 0x2: /* LDX.L */
813 error = misaligned_load(regs, opcode, 0, 2, 1);
815 case 0x3: /* LDX.Q */
816 error = misaligned_load(regs, opcode, 0, 3, 0);
824 case (0x60>>2): /* indexed stores */
826 case 0x1: /* STX.W */
827 error = misaligned_store(regs, opcode, 0, 1);
829 case 0x2: /* STX.L */
830 error = misaligned_store(regs, opcode, 0, 2);
832 case 0x3: /* STX.Q */
833 error = misaligned_store(regs, opcode, 0, 3);
841 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
842 case (0x94>>2): /* FLD.S */
843 error = misaligned_fpu_load(regs, opcode, 1, 2, 0);
845 case (0x98>>2): /* FLD.P */
846 error = misaligned_fpu_load(regs, opcode, 1, 3, 1);
848 case (0x9c>>2): /* FLD.D */
849 error = misaligned_fpu_load(regs, opcode, 1, 3, 0);
851 case (0x1c>>2): /* floating indexed loads */
853 case 0x8: /* FLDX.S */
854 error = misaligned_fpu_load(regs, opcode, 0, 2, 0);
856 case 0xd: /* FLDX.P */
857 error = misaligned_fpu_load(regs, opcode, 0, 3, 1);
859 case 0x9: /* FLDX.D */
860 error = misaligned_fpu_load(regs, opcode, 0, 3, 0);
867 case (0xb4>>2): /* FLD.S */
868 error = misaligned_fpu_store(regs, opcode, 1, 2, 0);
870 case (0xb8>>2): /* FLD.P */
871 error = misaligned_fpu_store(regs, opcode, 1, 3, 1);
873 case (0xbc>>2): /* FLD.D */
874 error = misaligned_fpu_store(regs, opcode, 1, 3, 0);
876 case (0x3c>>2): /* floating indexed stores */
878 case 0x8: /* FSTX.S */
879 error = misaligned_fpu_store(regs, opcode, 0, 2, 0);
881 case 0xd: /* FSTX.P */
882 error = misaligned_fpu_store(regs, opcode, 0, 3, 1);
884 case 0x9: /* FSTX.D */
885 error = misaligned_fpu_store(regs, opcode, 0, 3, 0);
903 regs->pc += 4; /* Skip the instruction that's just been emulated */
909 static ctl_table unaligned_table[] = {
910 {1, "kernel_reports", &kernel_mode_unaligned_fixup_count,
911 sizeof(int), 0644, NULL, &proc_dointvec},
912 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
913 {2, "user_reports", &user_mode_unaligned_fixup_count,
914 sizeof(int), 0644, NULL, &proc_dointvec},
915 {3, "user_enable", &user_mode_unaligned_fixup_enable,
916 sizeof(int), 0644, NULL, &proc_dointvec},
921 static ctl_table unaligned_root[] = {
922 {1, "unaligned_fixup", NULL, 0, 0555, unaligned_table},
926 static ctl_table sh64_root[] = {
927 {1, "sh64", NULL, 0, 0555, unaligned_root},
930 static struct ctl_table_header *sysctl_header;
931 static int __init init_sysctl(void)
933 sysctl_header = register_sysctl_table(sh64_root, 0);
937 __initcall(init_sysctl);
940 asmlinkage void do_debug_interrupt(unsigned long code, struct pt_regs *regs)
942 u64 peek_real_address_q(u64 addr);
943 u64 poke_real_address_q(u64 addr, u64 val);
944 unsigned long long DM_EXP_CAUSE_PHY = 0x0c100010;
945 unsigned long long exp_cause;
946 /* It's not worth ioremapping the debug module registers for the amount
947 of access we make to them - just go direct to their physical
949 exp_cause = peek_real_address_q(DM_EXP_CAUSE_PHY);
950 if (exp_cause & ~4) {
951 printk("DM.EXP_CAUSE had unexpected bits set (=%08lx)\n",
952 (unsigned long)(exp_cause & 0xffffffff));
955 /* Clear all DEBUGINT causes */
956 poke_real_address_q(DM_EXP_CAUSE_PHY, 0x0);