2 * arch/sh/kernel/traps_64.c
4 * Copyright (C) 2000, 2001 Paolo Alberelli
5 * Copyright (C) 2003, 2004 Paul Mundt
6 * Copyright (C) 2003, 2004 Richard Curnow
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
12 #include <linux/sched.h>
13 #include <linux/kernel.h>
14 #include <linux/string.h>
15 #include <linux/errno.h>
16 #include <linux/ptrace.h>
17 #include <linux/timer.h>
19 #include <linux/smp.h>
20 #include <linux/init.h>
21 #include <linux/delay.h>
22 #include <linux/spinlock.h>
23 #include <linux/kallsyms.h>
24 #include <linux/interrupt.h>
25 #include <linux/sysctl.h>
26 #include <linux/module.h>
27 #include <asm/system.h>
28 #include <asm/uaccess.h>
30 #include <asm/atomic.h>
31 #include <asm/processor.h>
32 #include <asm/pgtable.h>
35 #undef DEBUG_EXCEPTION
36 #ifdef DEBUG_EXCEPTION
37 /* implemented in ../lib/dbg.c */
38 extern void show_excp_regs(char *fname, int trapnr, int signr,
39 struct pt_regs *regs);
41 #define show_excp_regs(a, b, c, d)
44 static void do_unhandled_exception(int trapnr, int signr, char *str, char *fn_name,
45 unsigned long error_code, struct pt_regs *regs, struct task_struct *tsk);
47 #define DO_ERROR(trapnr, signr, str, name, tsk) \
48 asmlinkage void do_##name(unsigned long error_code, struct pt_regs *regs) \
50 do_unhandled_exception(trapnr, signr, str, __stringify(name), error_code, regs, current); \
55 void die(const char * str, struct pt_regs * regs, long err)
58 spin_lock_irq(&die_lock);
59 printk("%s: %lx\n", str, (err & 0xffffff));
61 spin_unlock_irq(&die_lock);
65 static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err)
71 static void die_if_no_fixup(const char * str, struct pt_regs * regs, long err)
73 if (!user_mode(regs)) {
74 const struct exception_table_entry *fixup;
75 fixup = search_exception_tables(regs->pc);
77 regs->pc = fixup->fixup;
84 DO_ERROR(13, SIGILL, "illegal slot instruction", illegal_slot_inst, current)
85 DO_ERROR(87, SIGSEGV, "address error (exec)", address_error_exec, current)
88 /* Implement misaligned load/store handling for kernel (and optionally for user
89 mode too). Limitation : only SHmedia mode code is handled - there is no
90 handling at all for misaligned accesses occurring in SHcompact code yet. */
92 static int misaligned_fixup(struct pt_regs *regs);
94 asmlinkage void do_address_error_load(unsigned long error_code, struct pt_regs *regs)
96 if (misaligned_fixup(regs) < 0) {
97 do_unhandled_exception(7, SIGSEGV, "address error(load)",
98 "do_address_error_load",
99 error_code, regs, current);
104 asmlinkage void do_address_error_store(unsigned long error_code, struct pt_regs *regs)
106 if (misaligned_fixup(regs) < 0) {
107 do_unhandled_exception(8, SIGSEGV, "address error(store)",
108 "do_address_error_store",
109 error_code, regs, current);
114 #if defined(CONFIG_SH64_ID2815_WORKAROUND)
116 #define OPCODE_INVALID 0
117 #define OPCODE_USER_VALID 1
118 #define OPCODE_PRIV_VALID 2
120 /* getcon/putcon - requires checking which control register is referenced. */
121 #define OPCODE_CTRL_REG 3
123 /* Table of valid opcodes for SHmedia mode.
124 Form a 10-bit value by concatenating the major/minor opcodes i.e.
125 opcode[31:26,20:16]. The 6 MSBs of this value index into the following
126 array. The 4 LSBs select the bit-pair in the entry (bits 1:0 correspond to
127 LSBs==4'b0000 etc). */
128 static unsigned long shmedia_opcode_table[64] = {
129 0x55554044,0x54445055,0x15141514,0x14541414,0x00000000,0x10001000,0x01110055,0x04050015,
130 0x00000444,0xc0000000,0x44545515,0x40405555,0x55550015,0x10005555,0x55555505,0x04050000,
131 0x00000555,0x00000404,0x00040445,0x15151414,0x00000000,0x00000000,0x00000000,0x00000000,
132 0x00000055,0x40404444,0x00000404,0xc0009495,0x00000000,0x00000000,0x00000000,0x00000000,
133 0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
134 0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
135 0x80005050,0x04005055,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,0x55555555,
136 0x81055554,0x00000404,0x55555555,0x55555555,0x00000000,0x00000000,0x00000000,0x00000000
139 void do_reserved_inst(unsigned long error_code, struct pt_regs *regs)
141 /* Workaround SH5-101 cut2 silicon defect #2815 :
142 in some situations, inter-mode branches from SHcompact -> SHmedia
143 which should take ITLBMISS or EXECPROT exceptions at the target
144 falsely take RESINST at the target instead. */
146 unsigned long opcode = 0x6ff4fff0; /* guaranteed reserved opcode */
147 unsigned long pc, aligned_pc;
151 char *exception_name = "reserved_instruction";
155 /* SHmedia : check for defect. This requires executable vmas
156 to be readable too. */
157 aligned_pc = pc & ~3;
158 if (!access_ok(VERIFY_READ, aligned_pc, sizeof(unsigned long))) {
159 get_user_error = -EFAULT;
161 get_user_error = __get_user(opcode, (unsigned long *)aligned_pc);
163 if (get_user_error >= 0) {
164 unsigned long index, shift;
165 unsigned long major, minor, combined;
166 unsigned long reserved_field;
167 reserved_field = opcode & 0xf; /* These bits are currently reserved as zero in all valid opcodes */
168 major = (opcode >> 26) & 0x3f;
169 minor = (opcode >> 16) & 0xf;
170 combined = (major << 4) | minor;
173 if (reserved_field == 0) {
174 int opcode_state = (shmedia_opcode_table[index] >> shift) & 0x3;
175 switch (opcode_state) {
179 case OPCODE_USER_VALID:
180 /* Restart the instruction : the branch to the instruction will now be from an RTE
181 not from SHcompact so the silicon defect won't be triggered. */
183 case OPCODE_PRIV_VALID:
184 if (!user_mode(regs)) {
185 /* Should only ever get here if a module has
186 SHcompact code inside it. If so, the same fix up is needed. */
187 return; /* same reason */
189 /* Otherwise, user mode trying to execute a privileged instruction -
190 fall through to trap. */
192 case OPCODE_CTRL_REG:
193 /* If in privileged mode, return as above. */
194 if (!user_mode(regs)) return;
195 /* In user mode ... */
196 if (combined == 0x9f) { /* GETCON */
197 unsigned long regno = (opcode >> 20) & 0x3f;
201 /* Otherwise, reserved or privileged control register, => trap */
202 } else if (combined == 0x1bf) { /* PUTCON */
203 unsigned long regno = (opcode >> 4) & 0x3f;
207 /* Otherwise, reserved or privileged control register, => trap */
213 /* Fall through to trap. */
217 /* fall through to normal resinst processing */
219 /* Error trying to read opcode. This typically means a
220 real fault, not a RESINST any more. So change the
223 exception_name = "address error (exec)";
228 do_unhandled_exception(trapnr, signr, exception_name, "do_reserved_inst", error_code, regs, current);
231 #else /* CONFIG_SH64_ID2815_WORKAROUND */
233 /* If the workaround isn't needed, this is just a straightforward reserved
235 DO_ERROR(12, SIGILL, "reserved instruction", reserved_inst, current)
237 #endif /* CONFIG_SH64_ID2815_WORKAROUND */
239 /* Called with interrupts disabled */
240 asmlinkage void do_exception_error(unsigned long ex, struct pt_regs *regs)
242 show_excp_regs(__func__, -1, -1, regs);
243 die_if_kernel("exception", regs, ex);
246 int do_unknown_trapa(unsigned long scId, struct pt_regs *regs)
249 printk("System call ID error: [0x1#args:8 #syscall:16 0x%lx]\n", scId);
251 die_if_kernel("unknown trapa", regs, scId);
256 void show_stack(struct task_struct *tsk, unsigned long *sp)
258 #ifdef CONFIG_KALLSYMS
259 extern void sh64_unwind(struct pt_regs *regs);
260 struct pt_regs *regs;
262 regs = tsk ? tsk->thread.kregs : NULL;
266 printk(KERN_ERR "Can't backtrace on sh64 without CONFIG_KALLSYMS\n");
270 void show_task(unsigned long *sp)
272 show_stack(NULL, sp);
275 void dump_stack(void)
279 /* Needed by any user of WARN_ON in view of the defn in include/asm-sh/bug.h */
280 EXPORT_SYMBOL(dump_stack);
282 static void do_unhandled_exception(int trapnr, int signr, char *str, char *fn_name,
283 unsigned long error_code, struct pt_regs *regs, struct task_struct *tsk)
285 show_excp_regs(fn_name, trapnr, signr, regs);
286 tsk->thread.error_code = error_code;
287 tsk->thread.trap_no = trapnr;
290 force_sig(signr, tsk);
292 die_if_no_fixup(str, regs, error_code);
295 static int read_opcode(unsigned long long pc, unsigned long *result_opcode, int from_user_mode)
298 unsigned long aligned_pc;
299 unsigned long opcode;
303 aligned_pc = pc & ~3;
304 if (from_user_mode) {
305 if (!access_ok(VERIFY_READ, aligned_pc, sizeof(unsigned long))) {
306 get_user_error = -EFAULT;
308 get_user_error = __get_user(opcode, (unsigned long *)aligned_pc);
309 *result_opcode = opcode;
311 return get_user_error;
313 /* If the fault was in the kernel, we can either read
314 * this directly, or if not, we fault.
316 *result_opcode = *(unsigned long *) aligned_pc;
319 } else if ((pc & 1) == 0) {
321 /* TODO : provide handling for this. We don't really support
322 user-mode SHcompact yet, and for a kernel fault, this would
323 have to come from a module built for SHcompact. */
331 static int address_is_sign_extended(__u64 a)
335 b = (__u64)(__s64)(__s32)(a & 0xffffffffUL);
336 return (b == a) ? 1 : 0;
338 #error "Sign extend check only works for NEFF==32"
342 static int generate_and_check_address(struct pt_regs *regs,
344 int displacement_not_indexed,
348 /* return -1 for fault, 0 for OK */
350 __u64 base_address, addr;
353 basereg = (opcode >> 20) & 0x3f;
354 base_address = regs->regs[basereg];
355 if (displacement_not_indexed) {
357 displacement = (opcode >> 10) & 0x3ff;
358 displacement = ((displacement << 54) >> 54); /* sign extend */
359 addr = (__u64)((__s64)base_address + (displacement << width_shift));
363 offsetreg = (opcode >> 10) & 0x3f;
364 offset = regs->regs[offsetreg];
365 addr = base_address + offset;
368 /* Check sign extended */
369 if (!address_is_sign_extended(addr)) {
373 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
374 /* Check accessible. For misaligned access in the kernel, assume the
375 address is always accessible (and if not, just fault when the
376 load/store gets done.) */
377 if (user_mode(regs)) {
378 if (addr >= TASK_SIZE) {
381 /* Do access_ok check later - it depends on whether it's a load or a store. */
389 /* Default value as for sh */
390 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
391 static int user_mode_unaligned_fixup_count = 10;
392 static int user_mode_unaligned_fixup_enable = 1;
395 static int kernel_mode_unaligned_fixup_count = 32;
397 static void misaligned_kernel_word_load(__u64 address, int do_sign_extend, __u64 *result)
400 unsigned char *p, *q;
401 p = (unsigned char *) (int) address;
402 q = (unsigned char *) &x;
406 if (do_sign_extend) {
407 *result = (__u64)(__s64) *(short *) &x;
413 static void misaligned_kernel_word_store(__u64 address, __u64 value)
416 unsigned char *p, *q;
417 p = (unsigned char *) (int) address;
418 q = (unsigned char *) &x;
425 static int misaligned_load(struct pt_regs *regs,
427 int displacement_not_indexed,
431 /* Return -1 for a fault, 0 for OK */
436 error = generate_and_check_address(regs, opcode,
437 displacement_not_indexed, width_shift, &address);
442 destreg = (opcode >> 4) & 0x3f;
443 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
444 if (user_mode(regs)) {
447 if (!access_ok(VERIFY_READ, (unsigned long) address, 1UL<<width_shift)) {
451 if (__copy_user(&buffer, (const void *)(int)address, (1 << width_shift)) > 0) {
452 return -1; /* fault */
454 switch (width_shift) {
456 if (do_sign_extend) {
457 regs->regs[destreg] = (__u64)(__s64) *(__s16 *) &buffer;
459 regs->regs[destreg] = (__u64) *(__u16 *) &buffer;
463 regs->regs[destreg] = (__u64)(__s64) *(__s32 *) &buffer;
466 regs->regs[destreg] = buffer;
469 printk("Unexpected width_shift %d in misaligned_load, PC=%08lx\n",
470 width_shift, (unsigned long) regs->pc);
476 /* kernel mode - we can take short cuts since if we fault, it's a genuine bug */
479 switch (width_shift) {
481 misaligned_kernel_word_load(address, do_sign_extend, ®s->regs[destreg]);
484 asm ("ldlo.l %1, 0, %0" : "=r" (lo) : "r" (address));
485 asm ("ldhi.l %1, 3, %0" : "=r" (hi) : "r" (address));
486 regs->regs[destreg] = lo | hi;
489 asm ("ldlo.q %1, 0, %0" : "=r" (lo) : "r" (address));
490 asm ("ldhi.q %1, 7, %0" : "=r" (hi) : "r" (address));
491 regs->regs[destreg] = lo | hi;
495 printk("Unexpected width_shift %d in misaligned_load, PC=%08lx\n",
496 width_shift, (unsigned long) regs->pc);
505 static int misaligned_store(struct pt_regs *regs,
507 int displacement_not_indexed,
510 /* Return -1 for a fault, 0 for OK */
515 error = generate_and_check_address(regs, opcode,
516 displacement_not_indexed, width_shift, &address);
521 srcreg = (opcode >> 4) & 0x3f;
522 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
523 if (user_mode(regs)) {
526 if (!access_ok(VERIFY_WRITE, (unsigned long) address, 1UL<<width_shift)) {
530 switch (width_shift) {
532 *(__u16 *) &buffer = (__u16) regs->regs[srcreg];
535 *(__u32 *) &buffer = (__u32) regs->regs[srcreg];
538 buffer = regs->regs[srcreg];
541 printk("Unexpected width_shift %d in misaligned_store, PC=%08lx\n",
542 width_shift, (unsigned long) regs->pc);
546 if (__copy_user((void *)(int)address, &buffer, (1 << width_shift)) > 0) {
547 return -1; /* fault */
552 /* kernel mode - we can take short cuts since if we fault, it's a genuine bug */
553 __u64 val = regs->regs[srcreg];
555 switch (width_shift) {
557 misaligned_kernel_word_store(address, val);
560 asm ("stlo.l %1, 0, %0" : : "r" (val), "r" (address));
561 asm ("sthi.l %1, 3, %0" : : "r" (val), "r" (address));
564 asm ("stlo.q %1, 0, %0" : : "r" (val), "r" (address));
565 asm ("sthi.q %1, 7, %0" : : "r" (val), "r" (address));
569 printk("Unexpected width_shift %d in misaligned_store, PC=%08lx\n",
570 width_shift, (unsigned long) regs->pc);
579 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
580 /* Never need to fix up misaligned FPU accesses within the kernel since that's a real
582 static int misaligned_fpu_load(struct pt_regs *regs,
584 int displacement_not_indexed,
588 /* Return -1 for a fault, 0 for OK */
593 error = generate_and_check_address(regs, opcode,
594 displacement_not_indexed, width_shift, &address);
599 destreg = (opcode >> 4) & 0x3f;
600 if (user_mode(regs)) {
604 if (!access_ok(VERIFY_READ, (unsigned long) address, 1UL<<width_shift)) {
608 if (__copy_user(&buffer, (const void *)(int)address, (1 << width_shift)) > 0) {
609 return -1; /* fault */
611 /* 'current' may be the current owner of the FPU state, so
612 context switch the registers into memory so they can be
613 indexed by register number. */
614 if (last_task_used_math == current) {
616 save_fpu(current, regs);
618 last_task_used_math = NULL;
622 buflo = *(__u32*) &buffer;
623 bufhi = *(1 + (__u32*) &buffer);
625 switch (width_shift) {
627 current->thread.fpu.hard.fp_regs[destreg] = buflo;
630 if (do_paired_load) {
631 current->thread.fpu.hard.fp_regs[destreg] = buflo;
632 current->thread.fpu.hard.fp_regs[destreg+1] = bufhi;
634 #if defined(CONFIG_CPU_LITTLE_ENDIAN)
635 current->thread.fpu.hard.fp_regs[destreg] = bufhi;
636 current->thread.fpu.hard.fp_regs[destreg+1] = buflo;
638 current->thread.fpu.hard.fp_regs[destreg] = buflo;
639 current->thread.fpu.hard.fp_regs[destreg+1] = bufhi;
644 printk("Unexpected width_shift %d in misaligned_fpu_load, PC=%08lx\n",
645 width_shift, (unsigned long) regs->pc);
650 die ("Misaligned FPU load inside kernel", regs, 0);
657 static int misaligned_fpu_store(struct pt_regs *regs,
659 int displacement_not_indexed,
663 /* Return -1 for a fault, 0 for OK */
668 error = generate_and_check_address(regs, opcode,
669 displacement_not_indexed, width_shift, &address);
674 srcreg = (opcode >> 4) & 0x3f;
675 if (user_mode(regs)) {
677 /* Initialise these to NaNs. */
678 __u32 buflo=0xffffffffUL, bufhi=0xffffffffUL;
680 if (!access_ok(VERIFY_WRITE, (unsigned long) address, 1UL<<width_shift)) {
684 /* 'current' may be the current owner of the FPU state, so
685 context switch the registers into memory so they can be
686 indexed by register number. */
687 if (last_task_used_math == current) {
689 save_fpu(current, regs);
691 last_task_used_math = NULL;
695 switch (width_shift) {
697 buflo = current->thread.fpu.hard.fp_regs[srcreg];
700 if (do_paired_load) {
701 buflo = current->thread.fpu.hard.fp_regs[srcreg];
702 bufhi = current->thread.fpu.hard.fp_regs[srcreg+1];
704 #if defined(CONFIG_CPU_LITTLE_ENDIAN)
705 bufhi = current->thread.fpu.hard.fp_regs[srcreg];
706 buflo = current->thread.fpu.hard.fp_regs[srcreg+1];
708 buflo = current->thread.fpu.hard.fp_regs[srcreg];
709 bufhi = current->thread.fpu.hard.fp_regs[srcreg+1];
714 printk("Unexpected width_shift %d in misaligned_fpu_store, PC=%08lx\n",
715 width_shift, (unsigned long) regs->pc);
719 *(__u32*) &buffer = buflo;
720 *(1 + (__u32*) &buffer) = bufhi;
721 if (__copy_user((void *)(int)address, &buffer, (1 << width_shift)) > 0) {
722 return -1; /* fault */
726 die ("Misaligned FPU load inside kernel", regs, 0);
732 static int misaligned_fixup(struct pt_regs *regs)
734 unsigned long opcode;
738 #if !defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
739 /* Never fixup user mode misaligned accesses without this option enabled. */
742 if (!user_mode_unaligned_fixup_enable) return -1;
745 error = read_opcode(regs->pc, &opcode, user_mode(regs));
749 major = (opcode >> 26) & 0x3f;
750 minor = (opcode >> 16) & 0xf;
752 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
753 if (user_mode(regs) && (user_mode_unaligned_fixup_count > 0)) {
754 --user_mode_unaligned_fixup_count;
755 /* Only do 'count' worth of these reports, to remove a potential DoS against syslog */
756 printk("Fixing up unaligned userspace access in \"%s\" pid=%d pc=0x%08x ins=0x%08lx\n",
757 current->comm, task_pid_nr(current), (__u32)regs->pc, opcode);
760 if (!user_mode(regs) && (kernel_mode_unaligned_fixup_count > 0)) {
761 --kernel_mode_unaligned_fixup_count;
762 if (in_interrupt()) {
763 printk("Fixing up unaligned kernelspace access in interrupt pc=0x%08x ins=0x%08lx\n",
764 (__u32)regs->pc, opcode);
766 printk("Fixing up unaligned kernelspace access in \"%s\" pid=%d pc=0x%08x ins=0x%08lx\n",
767 current->comm, task_pid_nr(current), (__u32)regs->pc, opcode);
773 case (0x84>>2): /* LD.W */
774 error = misaligned_load(regs, opcode, 1, 1, 1);
776 case (0xb0>>2): /* LD.UW */
777 error = misaligned_load(regs, opcode, 1, 1, 0);
779 case (0x88>>2): /* LD.L */
780 error = misaligned_load(regs, opcode, 1, 2, 1);
782 case (0x8c>>2): /* LD.Q */
783 error = misaligned_load(regs, opcode, 1, 3, 0);
786 case (0xa4>>2): /* ST.W */
787 error = misaligned_store(regs, opcode, 1, 1);
789 case (0xa8>>2): /* ST.L */
790 error = misaligned_store(regs, opcode, 1, 2);
792 case (0xac>>2): /* ST.Q */
793 error = misaligned_store(regs, opcode, 1, 3);
796 case (0x40>>2): /* indexed loads */
798 case 0x1: /* LDX.W */
799 error = misaligned_load(regs, opcode, 0, 1, 1);
801 case 0x5: /* LDX.UW */
802 error = misaligned_load(regs, opcode, 0, 1, 0);
804 case 0x2: /* LDX.L */
805 error = misaligned_load(regs, opcode, 0, 2, 1);
807 case 0x3: /* LDX.Q */
808 error = misaligned_load(regs, opcode, 0, 3, 0);
816 case (0x60>>2): /* indexed stores */
818 case 0x1: /* STX.W */
819 error = misaligned_store(regs, opcode, 0, 1);
821 case 0x2: /* STX.L */
822 error = misaligned_store(regs, opcode, 0, 2);
824 case 0x3: /* STX.Q */
825 error = misaligned_store(regs, opcode, 0, 3);
833 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
834 case (0x94>>2): /* FLD.S */
835 error = misaligned_fpu_load(regs, opcode, 1, 2, 0);
837 case (0x98>>2): /* FLD.P */
838 error = misaligned_fpu_load(regs, opcode, 1, 3, 1);
840 case (0x9c>>2): /* FLD.D */
841 error = misaligned_fpu_load(regs, opcode, 1, 3, 0);
843 case (0x1c>>2): /* floating indexed loads */
845 case 0x8: /* FLDX.S */
846 error = misaligned_fpu_load(regs, opcode, 0, 2, 0);
848 case 0xd: /* FLDX.P */
849 error = misaligned_fpu_load(regs, opcode, 0, 3, 1);
851 case 0x9: /* FLDX.D */
852 error = misaligned_fpu_load(regs, opcode, 0, 3, 0);
859 case (0xb4>>2): /* FLD.S */
860 error = misaligned_fpu_store(regs, opcode, 1, 2, 0);
862 case (0xb8>>2): /* FLD.P */
863 error = misaligned_fpu_store(regs, opcode, 1, 3, 1);
865 case (0xbc>>2): /* FLD.D */
866 error = misaligned_fpu_store(regs, opcode, 1, 3, 0);
868 case (0x3c>>2): /* floating indexed stores */
870 case 0x8: /* FSTX.S */
871 error = misaligned_fpu_store(regs, opcode, 0, 2, 0);
873 case 0xd: /* FSTX.P */
874 error = misaligned_fpu_store(regs, opcode, 0, 3, 1);
876 case 0x9: /* FSTX.D */
877 error = misaligned_fpu_store(regs, opcode, 0, 3, 0);
895 regs->pc += 4; /* Skip the instruction that's just been emulated */
901 static ctl_table unaligned_table[] = {
903 .ctl_name = CTL_UNNUMBERED,
904 .procname = "kernel_reports",
905 .data = &kernel_mode_unaligned_fixup_count,
906 .maxlen = sizeof(int),
908 .proc_handler = &proc_dointvec
910 #if defined(CONFIG_SH64_USER_MISALIGNED_FIXUP)
912 .ctl_name = CTL_UNNUMBERED,
913 .procname = "user_reports",
914 .data = &user_mode_unaligned_fixup_count,
915 .maxlen = sizeof(int),
917 .proc_handler = &proc_dointvec
920 .ctl_name = CTL_UNNUMBERED,
921 .procname = "user_enable",
922 .data = &user_mode_unaligned_fixup_enable,
923 .maxlen = sizeof(int),
925 .proc_handler = &proc_dointvec},
930 static ctl_table unaligned_root[] = {
932 .ctl_name = CTL_UNNUMBERED,
933 .procname = "unaligned_fixup",
940 static ctl_table sh64_root[] = {
942 .ctl_name = CTL_UNNUMBERED,
945 .child = unaligned_root
949 static struct ctl_table_header *sysctl_header;
950 static int __init init_sysctl(void)
952 sysctl_header = register_sysctl_table(sh64_root);
956 __initcall(init_sysctl);
959 asmlinkage void do_debug_interrupt(unsigned long code, struct pt_regs *regs)
961 u64 peek_real_address_q(u64 addr);
962 u64 poke_real_address_q(u64 addr, u64 val);
963 unsigned long long DM_EXP_CAUSE_PHY = 0x0c100010;
964 unsigned long long exp_cause;
965 /* It's not worth ioremapping the debug module registers for the amount
966 of access we make to them - just go direct to their physical
968 exp_cause = peek_real_address_q(DM_EXP_CAUSE_PHY);
969 if (exp_cause & ~4) {
970 printk("DM.EXP_CAUSE had unexpected bits set (=%08lx)\n",
971 (unsigned long)(exp_cause & 0xffffffff));
974 /* Clear all DEBUGINT causes */
975 poke_real_address_q(DM_EXP_CAUSE_PHY, 0x0);