Go to the documentation of this file.
18 #ifndef __ASM_UACCESS_H
19 #define __ASM_UACCESS_H
24 #include <linux/string.h>
27 #include <asm/ptrace.h>
28 #include <asm/errno.h>
29 #include <asm/memory.h>
30 #include <asm/compiler.h>
33 #define VERIFY_WRITE 1
55 #define KERNEL_DS (-1UL)
56 #define get_ds() (KERNEL_DS)
58 #define USER_DS TASK_SIZE_64
59 #define get_fs() (current_thread_info()->addr_limit)
66 #define segment_eq(a,b) ((a) == (b))
71 #define __addr_ok(addr) \
74 asm("cmp %1, %0; cset %0, lo" \
76 : "r" (addr), "0" (current_thread_info()->addr_limit) \
90 #define __range_ok(addr, size) \
92 unsigned long flag, roksum; \
93 __chk_user_ptr(addr); \
94 asm("adds %1, %1, %3; ccmp %1, %4, #2, cc; cset %0, cc" \
95 : "=&r" (flag), "=&r" (roksum) \
96 : "1" (addr), "Ir" (size), \
97 "r" (current_thread_info()->addr_limit) \
102 #define access_ok(type, addr, size) __range_ok(addr, size)
112 #define __get_user_asm(instr, reg, x, addr, err) \
114 "1: " instr " " reg "1, [%2]\n" \
116 " .section .fixup, \"ax\"\n" \
122 " .section __ex_table,\"a\"\n" \
126 : "+r" (err), "=&r" (x) \
127 : "r" (addr), "i" (-EFAULT))
129 #define __get_user_err(x, ptr, err) \
131 unsigned long __gu_val; \
132 __chk_user_ptr(ptr); \
133 switch (sizeof(*(ptr))) { \
135 __get_user_asm("ldrb", "%w", __gu_val, (ptr), (err)); \
138 __get_user_asm("ldrh", "%w", __gu_val, (ptr), (err)); \
141 __get_user_asm("ldr", "%w", __gu_val, (ptr), (err)); \
144 __get_user_asm("ldr", "%", __gu_val, (ptr), (err)); \
149 (x) = (__typeof__(*(ptr)))__gu_val; \
152 #define __get_user(x, ptr) \
155 __get_user_err((x), (ptr), __gu_err); \
159 #define __get_user_error(x, ptr, err) \
161 __get_user_err((x), (ptr), (err)); \
165 #define __get_user_unaligned __get_user
167 #define get_user(x, ptr) \
170 access_ok(VERIFY_READ, (ptr), sizeof(*(ptr))) ? \
171 __get_user((x), (ptr)) : \
172 ((x) = 0, -EFAULT); \
175 #define __put_user_asm(instr, reg, x, addr, err) \
177 "1: " instr " " reg "1, [%2]\n" \
179 " .section .fixup,\"ax\"\n" \
184 " .section __ex_table,\"a\"\n" \
189 : "r" (x), "r" (addr), "i" (-EFAULT))
191 #define __put_user_err(x, ptr, err) \
193 __typeof__(*(ptr)) __pu_val = (x); \
194 __chk_user_ptr(ptr); \
195 switch (sizeof(*(ptr))) { \
197 __put_user_asm("strb", "%w", __pu_val, (ptr), (err)); \
200 __put_user_asm("strh", "%w", __pu_val, (ptr), (err)); \
203 __put_user_asm("str", "%w", __pu_val, (ptr), (err)); \
206 __put_user_asm("str", "%", __pu_val, (ptr), (err)); \
213 #define __put_user(x, ptr) \
216 __put_user_err((x), (ptr), __pu_err); \
220 #define __put_user_error(x, ptr, err) \
222 __put_user_err((x), (ptr), (err)); \
226 #define __put_user_unaligned __put_user
228 #define put_user(x, ptr) \
231 access_ok(VERIFY_WRITE, (ptr), sizeof(*(ptr))) ? \
232 __put_user((x), (ptr)) : \
267 #define __copy_to_user_inatomic __copy_to_user
268 #define __copy_from_user_inatomic __copy_from_user
285 #define strlen_user(s) strnlen_user(s, ~0UL >> 1)
289 unsigned long res = 0;