|
7 | 7 | * it under the terms of the GNU General Public License version 2 as |
8 | 8 | * published by the Free Software Foundation. |
9 | 9 | * |
| 10 | + * vineetg: May 2011 |
| 11 | + * -user-space unaligned access emulation |
| 12 | + * |
10 | 13 | * Rahul Trivedi: Codito Technologies 2004 |
11 | 14 | */ |
12 | 15 |
|
|
16 | 19 | #include <asm/ptrace.h> |
17 | 20 | #include <asm/setup.h> |
18 | 21 | #include <asm/kprobes.h> |
| 22 | +#include <asm/unaligned.h> |
19 | 23 |
|
20 | 24 | void __init trap_init(void) |
21 | 25 | { |
@@ -79,7 +83,29 @@ DO_ERROR_INFO(SIGILL, "Illegal Insn (or Seq)", insterror_is_error, ILL_ILLOPC) |
79 | 83 | DO_ERROR_INFO(SIGBUS, "Invalid Mem Access", do_memory_error, BUS_ADRERR) |
80 | 84 | DO_ERROR_INFO(SIGTRAP, "Breakpoint Set", trap_is_brkpt, TRAP_BRKPT) |
81 | 85 |
|
| 86 | +#ifdef CONFIG_ARC_MISALIGN_ACCESS |
| 87 | +/* |
| 88 | + * Entry Point for Misaligned Data access Exception, for emulating in software |
| 89 | + */ |
| 90 | +int do_misaligned_access(unsigned long cause, unsigned long address, |
| 91 | + struct pt_regs *regs, struct callee_regs *cregs) |
| 92 | +{ |
| 93 | + if (misaligned_fixup(address, regs, cause, cregs) != 0) { |
| 94 | + siginfo_t info; |
| 95 | + |
| 96 | + info.si_signo = SIGBUS; |
| 97 | + info.si_errno = 0; |
| 98 | + info.si_code = BUS_ADRALN; |
| 99 | + info.si_addr = (void __user *)address; |
| 100 | + return handle_exception(cause, "Misaligned Access", regs, |
| 101 | + &info); |
| 102 | + } |
| 103 | + return 0; |
| 104 | +} |
| 105 | + |
| 106 | +#else |
82 | 107 | DO_ERROR_INFO(SIGSEGV, "Misaligned Access", do_misaligned_access, SEGV_ACCERR) |
| 108 | +#endif |
83 | 109 |
|
84 | 110 | /* |
85 | 111 | * Entry point for miscll errors such as Nested Exceptions |
|
0 commit comments