1
2 #ifndef __PARISC_UACCESS_H
3 #define __PARISC_UACCESS_H
4
5
6
7
8 #include <asm/page.h>
9 #include <asm/cache.h>
10
11 #include <linux/bug.h>
12 #include <linux/string.h>
13
14 #define KERNEL_DS ((mm_segment_t){0})
15 #define USER_DS ((mm_segment_t){1})
16
17 #define segment_eq(a, b) ((a).seg == (b).seg)
18
19 #define get_fs() (current_thread_info()->addr_limit)
20 #define set_fs(x) (current_thread_info()->addr_limit = (x))
21
22
23
24
25
26
27
28
29 #define access_ok(uaddr, size) \
30 ( (uaddr) == (uaddr) )
31
32 #define put_user __put_user
33 #define get_user __get_user
34
35 #if !defined(CONFIG_64BIT)
36 #define LDD_USER(val, ptr) __get_user_asm64(val, ptr)
37 #define STD_USER(x, ptr) __put_user_asm64(x, ptr)
38 #else
39 #define LDD_USER(val, ptr) __get_user_asm(val, "ldd", ptr)
40 #define STD_USER(x, ptr) __put_user_asm("std", x, ptr)
41 #endif
42
43
44
45
46
47
48
49
50 #define ARCH_HAS_RELATIVE_EXTABLE
51 struct exception_table_entry {
52 int insn;
53 int fixup;
54 };
55
56 #define ASM_EXCEPTIONTABLE_ENTRY( fault_addr, except_addr )\
57 ".section __ex_table,\"aw\"\n" \
58 ".word (" #fault_addr " - .), (" #except_addr " - .)\n\t" \
59 ".previous\n"
60
61
62
63
64
65
66
67 #define ASM_EXCEPTIONTABLE_ENTRY_EFAULT( fault_addr, except_addr )\
68 ASM_EXCEPTIONTABLE_ENTRY( fault_addr, except_addr + 1)
69
70
71
72
73
74
75
76
77 #define load_sr2() \
78 __asm__(" or,= %0,%%r0,%%r0\n\t" \
79 " mfsp %%sr3,%0\n\t" \
80 " mtsp %0,%%sr2\n\t" \
81 : : "r"(get_fs()) : )
82
83 #define __get_user_internal(val, ptr) \
84 ({ \
85 register long __gu_err __asm__ ("r8") = 0; \
86 \
87 switch (sizeof(*(ptr))) { \
88 case 1: __get_user_asm(val, "ldb", ptr); break; \
89 case 2: __get_user_asm(val, "ldh", ptr); break; \
90 case 4: __get_user_asm(val, "ldw", ptr); break; \
91 case 8: LDD_USER(val, ptr); break; \
92 default: BUILD_BUG(); \
93 } \
94 \
95 __gu_err; \
96 })
97
98 #define __get_user(val, ptr) \
99 ({ \
100 load_sr2(); \
101 __get_user_internal(val, ptr); \
102 })
103
104 #define __get_user_asm(val, ldx, ptr) \
105 { \
106 register long __gu_val; \
107 \
108 __asm__("1: " ldx " 0(%%sr2,%2),%0\n" \
109 "9:\n" \
110 ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
111 : "=r"(__gu_val), "=r"(__gu_err) \
112 : "r"(ptr), "1"(__gu_err)); \
113 \
114 (val) = (__force __typeof__(*(ptr))) __gu_val; \
115 }
116
117 #if !defined(CONFIG_64BIT)
118
119 #define __get_user_asm64(val, ptr) \
120 { \
121 union { \
122 unsigned long long l; \
123 __typeof__(*(ptr)) t; \
124 } __gu_tmp; \
125 \
126 __asm__(" copy %%r0,%R0\n" \
127 "1: ldw 0(%%sr2,%2),%0\n" \
128 "2: ldw 4(%%sr2,%2),%R0\n" \
129 "9:\n" \
130 ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
131 ASM_EXCEPTIONTABLE_ENTRY_EFAULT(2b, 9b) \
132 : "=&r"(__gu_tmp.l), "=r"(__gu_err) \
133 : "r"(ptr), "1"(__gu_err)); \
134 \
135 (val) = __gu_tmp.t; \
136 }
137
138 #endif
139
140
141 #define __put_user_internal(x, ptr) \
142 ({ \
143 register long __pu_err __asm__ ("r8") = 0; \
144 __typeof__(*(ptr)) __x = (__typeof__(*(ptr)))(x); \
145 \
146 switch (sizeof(*(ptr))) { \
147 case 1: __put_user_asm("stb", __x, ptr); break; \
148 case 2: __put_user_asm("sth", __x, ptr); break; \
149 case 4: __put_user_asm("stw", __x, ptr); break; \
150 case 8: STD_USER(__x, ptr); break; \
151 default: BUILD_BUG(); \
152 } \
153 \
154 __pu_err; \
155 })
156
157 #define __put_user(x, ptr) \
158 ({ \
159 load_sr2(); \
160 __put_user_internal(x, ptr); \
161 })
162
163
164
165
166
167
168
169
170
171
172
173 #define __put_user_asm(stx, x, ptr) \
174 __asm__ __volatile__ ( \
175 "1: " stx " %2,0(%%sr2,%1)\n" \
176 "9:\n" \
177 ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
178 : "=r"(__pu_err) \
179 : "r"(ptr), "r"(x), "0"(__pu_err))
180
181
182 #if !defined(CONFIG_64BIT)
183
184 #define __put_user_asm64(__val, ptr) do { \
185 __asm__ __volatile__ ( \
186 "1: stw %2,0(%%sr2,%1)\n" \
187 "2: stw %R2,4(%%sr2,%1)\n" \
188 "9:\n" \
189 ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 9b) \
190 ASM_EXCEPTIONTABLE_ENTRY_EFAULT(2b, 9b) \
191 : "=r"(__pu_err) \
192 : "r"(ptr), "r"(__val), "0"(__pu_err)); \
193 } while (0)
194
195 #endif
196
197
198
199
200
201
202 extern long strncpy_from_user(char *, const char __user *, long);
203 extern unsigned lclear_user(void __user *, unsigned long);
204 extern long lstrnlen_user(const char __user *, long);
205
206
207
208 #define user_addr_max() (~0UL)
209
210 #define strnlen_user lstrnlen_user
211 #define clear_user lclear_user
212 #define __clear_user lclear_user
213
214 unsigned long __must_check raw_copy_to_user(void __user *dst, const void *src,
215 unsigned long len);
216 unsigned long __must_check raw_copy_from_user(void *dst, const void __user *src,
217 unsigned long len);
218 unsigned long __must_check raw_copy_in_user(void __user *dst, const void __user *src,
219 unsigned long len);
220 #define INLINE_COPY_TO_USER
221 #define INLINE_COPY_FROM_USER
222
223 struct pt_regs;
224 int fixup_exception(struct pt_regs *regs);
225
226 #endif