Go to the documentation of this file. 1 #ifndef __ALPHA_UACCESS_H
2 #define __ALPHA_UACCESS_H
4 #include <linux/errno.h>
5 #include <linux/sched.h>
20 #define KERNEL_DS ((mm_segment_t) { 0UL })
21 #define USER_DS ((mm_segment_t) { -0x40000000000UL })
24 #define VERIFY_WRITE 1
26 #define get_fs() (current_thread_info()->addr_limit)
27 #define get_ds() (KERNEL_DS)
28 #define set_fs(x) (current_thread_info()->addr_limit = (x))
30 #define segment_eq(a,b) ((a).seg == (b).seg)
42 #define __access_ok(addr,size,segment) \
43 (((segment).seg & (addr | size | (addr+size))) == 0)
45 #define access_ok(type,addr,size) \
47 __chk_user_ptr(addr); \
48 __access_ok(((unsigned long)(addr)),(size),get_fs()); \
63 #define put_user(x,ptr) \
64 __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)),get_fs())
65 #define get_user(x,ptr) \
66 __get_user_check((x),(ptr),sizeof(*(ptr)),get_fs())
73 #define __put_user(x,ptr) \
74 __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
75 #define __get_user(x,ptr) \
76 __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
87 #define __get_user_nocheck(x,ptr,size) \
90 unsigned long __gu_val; \
91 __chk_user_ptr(ptr); \
93 case 1: __get_user_8(ptr); break; \
94 case 2: __get_user_16(ptr); break; \
95 case 4: __get_user_32(ptr); break; \
96 case 8: __get_user_64(ptr); break; \
97 default: __get_user_unknown(); break; \
99 (x) = (__typeof__(*(ptr))) __gu_val; \
103 #define __get_user_check(x,ptr,size,segment) \
105 long __gu_err = -EFAULT; \
106 unsigned long __gu_val = 0; \
107 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
108 if (__access_ok((unsigned long)__gu_addr,size,segment)) { \
111 case 1: __get_user_8(__gu_addr); break; \
112 case 2: __get_user_16(__gu_addr); break; \
113 case 4: __get_user_32(__gu_addr); break; \
114 case 8: __get_user_64(__gu_addr); break; \
115 default: __get_user_unknown(); break; \
118 (x) = (__typeof__(*(ptr))) __gu_val; \
123 #define __m(x) (*(struct __large_struct __user *)(x))
125 #define __get_user_64(addr) \
126 __asm__("1: ldq %0,%2\n" \
128 ".section __ex_table,\"a\"\n" \
130 " lda %0, 2b-1b(%1)\n" \
132 : "=r"(__gu_val), "=r"(__gu_err) \
133 : "m"(__m(addr)), "1"(__gu_err))
135 #define __get_user_32(addr) \
136 __asm__("1: ldl %0,%2\n" \
138 ".section __ex_table,\"a\"\n" \
140 " lda %0, 2b-1b(%1)\n" \
142 : "=r"(__gu_val), "=r"(__gu_err) \
143 : "m"(__m(addr)), "1"(__gu_err))
148 #define __get_user_16(addr) \
149 __asm__("1: ldwu %0,%2\n" \
151 ".section __ex_table,\"a\"\n" \
153 " lda %0, 2b-1b(%1)\n" \
155 : "=r"(__gu_val), "=r"(__gu_err) \
156 : "m"(__m(addr)), "1"(__gu_err))
158 #define __get_user_8(addr) \
159 __asm__("1: ldbu %0,%2\n" \
161 ".section __ex_table,\"a\"\n" \
163 " lda %0, 2b-1b(%1)\n" \
165 : "=r"(__gu_val), "=r"(__gu_err) \
166 : "m"(__m(addr)), "1"(__gu_err))
171 #define __get_user_16(addr) \
174 __asm__("1: ldq_u %0,0(%3)\n" \
175 "2: ldq_u %1,1(%3)\n" \
176 " extwl %0,%3,%0\n" \
177 " extwh %1,%3,%1\n" \
180 ".section __ex_table,\"a\"\n" \
182 " lda %0, 3b-1b(%2)\n" \
184 " lda %0, 3b-2b(%2)\n" \
186 : "=&r"(__gu_val), "=&r"(__gu_tmp), "=r"(__gu_err) \
187 : "r"(addr), "2"(__gu_err)); \
190 #define __get_user_8(addr) \
191 __asm__("1: ldq_u %0,0(%2)\n" \
192 " extbl %0,%2,%0\n" \
194 ".section __ex_table,\"a\"\n" \
196 " lda %0, 2b-1b(%1)\n" \
198 : "=&r"(__gu_val), "=r"(__gu_err) \
199 : "r"(addr), "1"(__gu_err))
204 #define __put_user_nocheck(x,ptr,size) \
207 __chk_user_ptr(ptr); \
209 case 1: __put_user_8(x,ptr); break; \
210 case 2: __put_user_16(x,ptr); break; \
211 case 4: __put_user_32(x,ptr); break; \
212 case 8: __put_user_64(x,ptr); break; \
213 default: __put_user_unknown(); break; \
218 #define __put_user_check(x,ptr,size,segment) \
220 long __pu_err = -EFAULT; \
221 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
222 if (__access_ok((unsigned long)__pu_addr,size,segment)) { \
225 case 1: __put_user_8(x,__pu_addr); break; \
226 case 2: __put_user_16(x,__pu_addr); break; \
227 case 4: __put_user_32(x,__pu_addr); break; \
228 case 8: __put_user_64(x,__pu_addr); break; \
229 default: __put_user_unknown(); break; \
240 #define __put_user_64(x,addr) \
241 __asm__ __volatile__("1: stq %r2,%1\n" \
243 ".section __ex_table,\"a\"\n" \
245 " lda $31,2b-1b(%0)\n" \
248 : "m" (__m(addr)), "rJ" (x), "0"(__pu_err))
250 #define __put_user_32(x,addr) \
251 __asm__ __volatile__("1: stl %r2,%1\n" \
253 ".section __ex_table,\"a\"\n" \
255 " lda $31,2b-1b(%0)\n" \
258 : "m"(__m(addr)), "rJ"(x), "0"(__pu_err))
263 #define __put_user_16(x,addr) \
264 __asm__ __volatile__("1: stw %r2,%1\n" \
266 ".section __ex_table,\"a\"\n" \
268 " lda $31,2b-1b(%0)\n" \
271 : "m"(__m(addr)), "rJ"(x), "0"(__pu_err))
273 #define __put_user_8(x,addr) \
274 __asm__ __volatile__("1: stb %r2,%1\n" \
276 ".section __ex_table,\"a\"\n" \
278 " lda $31,2b-1b(%0)\n" \
281 : "m"(__m(addr)), "rJ"(x), "0"(__pu_err))
286 #define __put_user_16(x,addr) \
288 long __pu_tmp1, __pu_tmp2, __pu_tmp3, __pu_tmp4; \
289 __asm__ __volatile__( \
290 "1: ldq_u %2,1(%5)\n" \
291 "2: ldq_u %1,0(%5)\n" \
292 " inswh %6,%5,%4\n" \
293 " inswl %6,%5,%3\n" \
294 " mskwh %2,%5,%2\n" \
295 " mskwl %1,%5,%1\n" \
298 "3: stq_u %2,1(%5)\n" \
299 "4: stq_u %1,0(%5)\n" \
301 ".section __ex_table,\"a\"\n" \
303 " lda $31, 5b-1b(%0)\n" \
305 " lda $31, 5b-2b(%0)\n" \
307 " lda $31, 5b-3b(%0)\n" \
309 " lda $31, 5b-4b(%0)\n" \
311 : "=r"(__pu_err), "=&r"(__pu_tmp1), \
312 "=&r"(__pu_tmp2), "=&r"(__pu_tmp3), \
314 : "r"(addr), "r"((unsigned long)(x)), "0"(__pu_err)); \
317 #define __put_user_8(x,addr) \
319 long __pu_tmp1, __pu_tmp2; \
320 __asm__ __volatile__( \
321 "1: ldq_u %1,0(%4)\n" \
322 " insbl %3,%4,%2\n" \
323 " mskbl %1,%4,%1\n" \
325 "2: stq_u %1,0(%4)\n" \
327 ".section __ex_table,\"a\"\n" \
329 " lda $31, 3b-1b(%0)\n" \
331 " lda $31, 3b-2b(%0)\n" \
334 "=&r"(__pu_tmp1), "=&r"(__pu_tmp2) \
335 : "r"((unsigned long)(x)), "r"(addr), "0"(__pu_err)); \
348 #define __module_address(sym) "r"(sym),
349 #define __module_call(ra, arg, sym) "jsr $" #ra ",(%" #arg ")," #sym
351 #define __module_address(sym)
352 #define __module_call(ra, arg, sym) "bsr $" #ra "," #sym " !samegp"
360 register void * __cu_to
__asm__(
"$6") = to;
361 register const void * __cu_from
__asm__(
"$7") =
from;
362 register long __cu_len
__asm__(
"$0") = len;
366 :
"=r" (__cu_len),
"=r" (__cu_from),
"=r" (__cu_to)
368 "0" (__cu_len),
"1" (__cu_from),
"2" (__cu_to)
369 :
"$1",
"$2",
"$3",
"$4",
"$5",
"$28",
"memory");
382 #define __copy_to_user(to,from,n) \
384 __chk_user_ptr(to); \
385 __copy_tofrom_user_nocheck((__force void *)(to),(from),(n)); \
387 #define __copy_from_user(to,from,n) \
389 __chk_user_ptr(from); \
390 __copy_tofrom_user_nocheck((to),(__force void *)(from),(n)); \
393 #define __copy_to_user_inatomic __copy_to_user
394 #define __copy_from_user_inatomic __copy_from_user
415 register long __cl_len
__asm__(
"$0") = len;
418 :
"=r"(__cl_len),
"=r"(__cl_to)
420 "0"(__cl_len),
"1"(__cl_to)
421 :
"$1",
"$2",
"$3",
"$4",
"$5",
"$28",
"memory");
433 #undef __module_address
436 #define user_addr_max() \
437 (segment_eq(get_fs(), USER_DS) ? TASK_SIZE : ~0UL)
477 #define fixup_exception(map_reg, _fixup, pc) \
479 if ((_fixup)->fixup.bits.valreg != 31) \
480 map_reg((_fixup)->fixup.bits.valreg) = 0; \
481 if ((_fixup)->fixup.bits.errreg != 31) \
482 map_reg((_fixup)->fixup.bits.errreg) = -EFAULT; \
483 (pc) + (_fixup)->fixup.bits.nextinsn; \
486 #define ARCH_HAS_SORT_EXTABLE
487 #define ARCH_HAS_SEARCH_EXTABLE