Lines Matching +full:x +full:- +full:size
1 /* SPDX-License-Identifier: GPL-2.0 */
9 #include <asm/asm-compat.h>
16 #include <asm-generic/access_ok.h>
19 * These are the main single-value transfer routines. They automatically
20 * use the right size if we just have the right pointer type.
37 #define __put_user(x, ptr) \ argument
41 __typeof__(*(ptr)) __pu_val = (__typeof__(*(ptr)))(x); \
56 __pu_err = -EFAULT; \
62 #define put_user(x, ptr) \ argument
67 __put_user(x, _pu_addr) : -EFAULT; \
75 /* -mprefixed can generate offsets beyond range, fall back hack */
77 #define __put_user_asm_goto(x, addr, label, op) \ argument
82 : "r" (x), "b" (addr) \
86 #define __put_user_asm_goto(x, addr, label, op) \ argument
91 : "r" (x), "m<>" (*addr) \
98 #define __put_user_asm2_goto(x, ptr, label) \ argument
99 __put_user_asm_goto(x, ptr, label, "std")
101 #define __put_user_asm2_goto(x, addr, label) \ argument
105 : "r" (x), DS_FORM_CONSTRAINT (*addr) \
110 #define __put_user_asm2_goto(x, addr, label) \ argument
117 : "r" (x), "m" (*addr) \
122 #define __put_user_size_goto(x, ptr, size, label) \ argument
126 switch (size) { \
127 case 1: __put_user_asm_goto(x, __pus_addr, label, "stb"); break; \
128 case 2: __put_user_asm_goto(x, __pus_addr, label, "sth"); break; \
129 case 4: __put_user_asm_goto(x, __pus_addr, label, "stw"); break; \
130 case 8: __put_user_asm2_goto(x, __pus_addr, label); break; \
153 : "b" (uaddr), "b" (kaddr), "i" (-EFAULT), "0" (err))
157 /* -mprefixed can generate offsets beyond range, fall back hack */
159 #define __get_user_asm_goto(x, addr, label, op) \ argument
163 : "=r" (x) \
168 #define __get_user_asm_goto(x, addr, label, op) \ argument
172 : "=r" (x) \
180 #define __get_user_asm2_goto(x, addr, label) \ argument
181 __get_user_asm_goto(x, addr, label, "ld")
183 #define __get_user_asm2_goto(x, addr, label) \ argument
187 : "=r" (x) \
193 #define __get_user_asm2_goto(x, addr, label) \ argument
199 : "=&r" (x) \
205 #define __get_user_size_goto(x, ptr, size, label) \ argument
207 BUILD_BUG_ON(size > sizeof(x)); \
208 switch (size) { \
209 case 1: __get_user_asm_goto(x, (u8 __user *)ptr, label, "lbz"); break; \
210 case 2: __get_user_asm_goto(x, (u16 __user *)ptr, label, "lhz"); break; \
211 case 4: __get_user_asm_goto(x, (u32 __user *)ptr, label, "lwz"); break; \
212 case 8: __get_user_asm2_goto(x, (u64 __user *)ptr, label); break; \
213 default: x = 0; BUILD_BUG(); \
217 #define __get_user_size_allowed(x, ptr, size, retval) \ argument
221 __get_user_size_goto(x, ptr, size, __gus_failed); \
225 x = 0; \
226 retval = -EFAULT; \
231 #define __get_user_asm(x, addr, err, op) \ argument
241 : "=r" (err), "=r" (x) \
242 : "m<>" (*addr), "i" (-EFAULT), "0" (err))
245 #define __get_user_asm2(x, addr, err) \ argument
246 __get_user_asm(x, addr, err, "ld")
248 #define __get_user_asm2(x, addr, err) \ argument
261 : "=r" (err), "=&r" (x) \
262 : "m" (*addr), "i" (-EFAULT), "0" (err))
265 #define __get_user_size_allowed(x, ptr, size, retval) \ argument
268 BUILD_BUG_ON(size > sizeof(x)); \
269 switch (size) { \
270 case 1: __get_user_asm(x, (u8 __user *)ptr, retval, "lbz"); break; \
271 case 2: __get_user_asm(x, (u16 __user *)ptr, retval, "lhz"); break; \
272 case 4: __get_user_asm(x, (u32 __user *)ptr, retval, "lwz"); break; \
273 case 8: __get_user_asm2(x, (u64 __user *)ptr, retval); break; \
274 default: x = 0; BUILD_BUG(); \
278 #define __get_user_size_goto(x, ptr, size, label) \ argument
282 __get_user_size_allowed(x, ptr, size, __gus_retval); \
293 #define __long_type(x) \ argument
294 __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
296 #define __get_user(x, ptr) \ argument
307 (x) = (__typeof__(*(ptr)))__gu_val; \
312 #define get_user(x, ptr) \ argument
317 __get_user(x, _gu_addr) : \
318 ((x) = (__force __typeof__(*(ptr)))0, -EFAULT); \
324 const void __user *from, unsigned long size);
361 unsigned long __arch_clear_user(void __user *addr, unsigned long size);
363 static inline unsigned long __clear_user(void __user *addr, unsigned long size) in __clear_user() argument
368 allow_write_to_user(addr, size); in __clear_user()
369 ret = __arch_clear_user(addr, size); in __clear_user()
370 prevent_write_to_user(addr, size); in __clear_user()
374 static inline unsigned long clear_user(void __user *addr, unsigned long size) in clear_user() argument
376 return likely(access_ok(addr, size)) ? __clear_user(addr, size) : size; in clear_user()
384 copy_mc_generic(void *to, const void *from, unsigned long size);
387 copy_mc_to_kernel(void *to, const void *from, unsigned long size) in copy_mc_to_kernel() argument
389 return copy_mc_generic(to, from, size); in copy_mc_to_kernel()
409 unsigned size);
454 #define unsafe_get_user(x, p, e) do { \ argument
459 (x) = (__typeof__(*(p)))__gu_val; \
462 #define unsafe_put_user(x, p, e) \ argument
463 __put_user_size_goto((__typeof__(*(p)))(x), (p), sizeof(*(p)), e)
472 for (_i = 0; _i < (_len & ~(sizeof(u64) - 1)); _i += sizeof(u64)) \
493 for (_i = 0; _i < (_len & ~(sizeof(u64) - 1)); _i += sizeof(u64)) \