diff options
author | Noam Camus <noamc@ezchip.com> | 2012-09-10 08:13:19 -0400 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2013-09-05 01:01:11 -0400 |
commit | 7d669a193bc0f44c20054687a3bf9ff82ad001a7 (patch) | |
tree | 889e700ab5e07aa52f4a439f31a707bb28c74232 /arch | |
parent | 947bf103fcd2defa3bc4b7ebc6b05d0427bcde2d (diff) |
ARC: Handle un-aligned user space access in BE.
Adding endian awarness to un-aligned access exception handling.
Signed-off-by: Noam Camus <noamc@ezchip.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arc/kernel/unaligned.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/arch/arc/kernel/unaligned.c b/arch/arc/kernel/unaligned.c index c0f832f595d3..28d170060747 100644 --- a/arch/arc/kernel/unaligned.c +++ b/arch/arc/kernel/unaligned.c | |||
@@ -16,6 +16,16 @@ | |||
16 | #include <linux/uaccess.h> | 16 | #include <linux/uaccess.h> |
17 | #include <asm/disasm.h> | 17 | #include <asm/disasm.h> |
18 | 18 | ||
19 | #ifdef CONFIG_CPU_BIG_ENDIAN | ||
20 | #define BE 1 | ||
21 | #define FIRST_BYTE_16 "swap %1, %1\n swape %1, %1\n" | ||
22 | #define FIRST_BYTE_32 "swape %1, %1\n" | ||
23 | #else | ||
24 | #define BE 0 | ||
25 | #define FIRST_BYTE_16 | ||
26 | #define FIRST_BYTE_32 | ||
27 | #endif | ||
28 | |||
19 | #define __get8_unaligned_check(val, addr, err) \ | 29 | #define __get8_unaligned_check(val, addr, err) \ |
20 | __asm__( \ | 30 | __asm__( \ |
21 | "1: ldb.ab %1, [%2, 1]\n" \ | 31 | "1: ldb.ab %1, [%2, 1]\n" \ |
@@ -36,9 +46,9 @@ | |||
36 | do { \ | 46 | do { \ |
37 | unsigned int err = 0, v, a = addr; \ | 47 | unsigned int err = 0, v, a = addr; \ |
38 | __get8_unaligned_check(v, a, err); \ | 48 | __get8_unaligned_check(v, a, err); \ |
39 | val = v ; \ | 49 | val = v << ((BE) ? 8 : 0); \ |
40 | __get8_unaligned_check(v, a, err); \ | 50 | __get8_unaligned_check(v, a, err); \ |
41 | val |= v << 8; \ | 51 | val |= v << ((BE) ? 0 : 8); \ |
42 | if (err) \ | 52 | if (err) \ |
43 | goto fault; \ | 53 | goto fault; \ |
44 | } while (0) | 54 | } while (0) |
@@ -47,13 +57,13 @@ | |||
47 | do { \ | 57 | do { \ |
48 | unsigned int err = 0, v, a = addr; \ | 58 | unsigned int err = 0, v, a = addr; \ |
49 | __get8_unaligned_check(v, a, err); \ | 59 | __get8_unaligned_check(v, a, err); \ |
50 | val = v << 0; \ | 60 | val = v << ((BE) ? 24 : 0); \ |
51 | __get8_unaligned_check(v, a, err); \ | 61 | __get8_unaligned_check(v, a, err); \ |
52 | val |= v << 8; \ | 62 | val |= v << ((BE) ? 16 : 8); \ |
53 | __get8_unaligned_check(v, a, err); \ | 63 | __get8_unaligned_check(v, a, err); \ |
54 | val |= v << 16; \ | 64 | val |= v << ((BE) ? 8 : 16); \ |
55 | __get8_unaligned_check(v, a, err); \ | 65 | __get8_unaligned_check(v, a, err); \ |
56 | val |= v << 24; \ | 66 | val |= v << ((BE) ? 0 : 24); \ |
57 | if (err) \ | 67 | if (err) \ |
58 | goto fault; \ | 68 | goto fault; \ |
59 | } while (0) | 69 | } while (0) |
@@ -63,6 +73,7 @@ | |||
63 | unsigned int err = 0, v = val, a = addr;\ | 73 | unsigned int err = 0, v = val, a = addr;\ |
64 | \ | 74 | \ |
65 | __asm__( \ | 75 | __asm__( \ |
76 | FIRST_BYTE_16 \ | ||
66 | "1: stb.ab %1, [%2, 1]\n" \ | 77 | "1: stb.ab %1, [%2, 1]\n" \ |
67 | " lsr %1, %1, 8\n" \ | 78 | " lsr %1, %1, 8\n" \ |
68 | "2: stb %1, [%2]\n" \ | 79 | "2: stb %1, [%2]\n" \ |
@@ -87,8 +98,9 @@ | |||
87 | #define put32_unaligned_check(val, addr) \ | 98 | #define put32_unaligned_check(val, addr) \ |
88 | do { \ | 99 | do { \ |
89 | unsigned int err = 0, v = val, a = addr;\ | 100 | unsigned int err = 0, v = val, a = addr;\ |
90 | __asm__( \ | ||
91 | \ | 101 | \ |
102 | __asm__( \ | ||
103 | FIRST_BYTE_32 \ | ||
92 | "1: stb.ab %1, [%2, 1]\n" \ | 104 | "1: stb.ab %1, [%2, 1]\n" \ |
93 | " lsr %1, %1, 8\n" \ | 105 | " lsr %1, %1, 8\n" \ |
94 | "2: stb.ab %1, [%2, 1]\n" \ | 106 | "2: stb.ab %1, [%2, 1]\n" \ |