xref: /linux/arch/x86/include/asm/uaccess.h (revision bb29b957eaaa15be33243550d9ee576c2d601669)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_UACCESS_H
3 #define _ASM_X86_UACCESS_H
4 /*
5  * User space memory access functions
6  */
7 #include <linux/compiler.h>
8 #include <linux/instrumented.h>
9 #include <linux/kasan-checks.h>
10 #include <linux/mm_types.h>
11 #include <linux/string.h>
12 #include <linux/mmap_lock.h>
13 #include <asm/asm.h>
14 #include <asm/page.h>
15 #include <asm/smap.h>
16 #include <asm/extable.h>
17 #include <asm/tlbflush.h>
18 
19 #ifdef CONFIG_X86_32
20 # include <asm/uaccess_32.h>
21 #else
22 # include <asm/uaccess_64.h>
23 #endif
24 
25 #include <asm-generic/access_ok.h>
26 
27 extern int __get_user_1(void);
28 extern int __get_user_2(void);
29 extern int __get_user_4(void);
30 extern int __get_user_8(void);
31 extern int __get_user_bad(void);
32 
33 #define __uaccess_begin() stac()
34 #define __uaccess_end()   clac()
35 #define __uaccess_begin_nospec()	\
36 ({					\
37 	stac();				\
38 	barrier_nospec();		\
39 })
40 
41 /*
42  * This is the smallest unsigned integer type that can fit a value
43  * (up to 'long long')
44  */
45 #define __inttype(x) __typeof__(		\
46 	__typefits(x,char,			\
47 	  __typefits(x,short,			\
48 	    __typefits(x,int,			\
49 	      __typefits(x,long,0ULL)))))
50 
51 #define __typefits(x,type,not) \
52 	__builtin_choose_expr(sizeof(x)<=sizeof(type),(unsigned type)0,not)
53 
54 /*
55  * This is used by get_user() to expand to the proper special function
56  * call that has odd calling conventions due to returning both a value
57  * and an error, and that depends on the size of the pointer passed in.
58  *
59  * Careful: we have to cast the result to the type of the pointer
60  * for sign reasons.
61  *
62  * The use of _ASM_DX as the register specifier is a bit of a
63  * simplification, as gcc only cares about it as the starting point
64  * and not size: for a 64-bit value it will use %ecx:%edx on 32 bits
65  * (%ecx being the next register in gcc's x86 register sequence), and
66  * %rdx on 64 bits.
67  *
68  * Clang/LLVM cares about the size of the register, but still wants
69  * the base register for something that ends up being a pair.
70  */
71 #define do_get_user_call(fn,x,ptr)					\
72 ({									\
73 	int __ret_gu;							\
74 	register __inttype(*(ptr)) __val_gu asm("%"_ASM_DX);		\
75 	__chk_user_ptr(ptr);						\
76 	asm volatile("call __" #fn "_%c[size]"				\
77 		     : "=a" (__ret_gu), "=r" (__val_gu),		\
78 			ASM_CALL_CONSTRAINT				\
79 		     : "0" (ptr), [size] "i" (sizeof(*(ptr))));		\
80 	instrument_get_user(__val_gu);					\
81 	(x) = (__force __typeof__(*(ptr))) __val_gu;			\
82 	__builtin_expect(__ret_gu, 0);					\
83 })
84 
85 /**
86  * get_user - Get a simple variable from user space.
87  * @x:   Variable to store result.
88  * @ptr: Source address, in user space.
89  *
90  * Context: User context only. This function may sleep if pagefaults are
91  *          enabled.
92  *
93  * This macro copies a single simple variable from user space to kernel
94  * space.  It supports simple types like char and int, but not larger
95  * data types like structures or arrays.
96  *
97  * @ptr must have pointer-to-simple-variable type, and the result of
98  * dereferencing @ptr must be assignable to @x without a cast.
99  *
100  * Return: zero on success, or -EFAULT on error.
101  * On error, the variable @x is set to zero.
102  */
103 #define get_user(x,ptr) ({ might_fault(); do_get_user_call(get_user,x,ptr); })
104 
105 
106 #ifdef CONFIG_X86_32
107 #define __put_user_goto_u64(x, addr, label)			\
108 	asm goto("\n"					\
109 		     "1:	movl %%eax,0(%1)\n"		\
110 		     "2:	movl %%edx,4(%1)\n"		\
111 		     _ASM_EXTABLE_UA(1b, %l2)			\
112 		     _ASM_EXTABLE_UA(2b, %l2)			\
113 		     : : "A" (x), "r" (addr)			\
114 		     : : label)
115 
116 #else
117 #define __put_user_goto_u64(x, ptr, label) \
118 	__put_user_goto(x, ptr, "q", "er", label)
119 #endif
120 
121 extern void __put_user_bad(void);
122 
123 /*
124  * Strange magic calling convention: pointer in %ecx,
125  * value in %eax(:%edx), return value in %ecx. clobbers %rbx
126  */
127 extern void __put_user_1(void);
128 extern void __put_user_2(void);
129 extern void __put_user_4(void);
130 extern void __put_user_8(void);
131 
132 /*
133  * ptr must be evaluated and assigned to the temporary __ptr_pu before
134  * the assignment of x to __val_pu, to avoid any function calls
135  * involved in the ptr expression (possibly implicitly generated due
136  * to KASAN) from clobbering %ax.
137  */
138 #define do_put_user_call(fn,x,ptr)					\
139 ({									\
140 	int __ret_pu;							\
141 	void __user *__ptr_pu;						\
142 	register __typeof__(*(ptr)) __val_pu asm("%"_ASM_AX);		\
143 	__typeof__(*(ptr)) __x = (x); /* eval x once */			\
144 	__typeof__(ptr) __ptr = (ptr); /* eval ptr once */		\
145 	__chk_user_ptr(__ptr);						\
146 	__ptr_pu = __ptr;						\
147 	__val_pu = __x;							\
148 	asm volatile("call __" #fn "_%c[size]"				\
149 		     : "=c" (__ret_pu),					\
150 			ASM_CALL_CONSTRAINT				\
151 		     : "0" (__ptr_pu),					\
152 		       "r" (__val_pu),					\
153 		       [size] "i" (sizeof(*(ptr)))			\
154 		     :"ebx");						\
155 	instrument_put_user(__x, __ptr, sizeof(*(ptr)));		\
156 	__builtin_expect(__ret_pu, 0);					\
157 })
158 
159 /**
160  * put_user - Write a simple value into user space.
161  * @x:   Value to copy to user space.
162  * @ptr: Destination address, in user space.
163  *
164  * Context: User context only. This function may sleep if pagefaults are
165  *          enabled.
166  *
167  * This macro copies a single simple value from kernel space to user
168  * space.  It supports simple types like char and int, but not larger
169  * data types like structures or arrays.
170  *
171  * @ptr must have pointer-to-simple-variable type, and @x must be assignable
172  * to the result of dereferencing @ptr.
173  *
174  * Return: zero on success, or -EFAULT on error.
175  */
176 #define put_user(x, ptr) ({ might_fault(); do_put_user_call(put_user,x,ptr); })
177 
178 #define __put_user_size(x, ptr, size, label)				\
179 do {									\
180 	__typeof__(*(ptr)) __x = (x); /* eval x once */			\
181 	__typeof__(ptr) __ptr = (ptr); /* eval ptr once */		\
182 	__chk_user_ptr(__ptr);						\
183 	switch (size) {							\
184 	case 1:								\
185 		__put_user_goto(__x, __ptr, "b", "iq", label);		\
186 		break;							\
187 	case 2:								\
188 		__put_user_goto(__x, __ptr, "w", "ir", label);		\
189 		break;							\
190 	case 4:								\
191 		__put_user_goto(__x, __ptr, "l", "ir", label);		\
192 		break;							\
193 	case 8:								\
194 		__put_user_goto_u64(__x, __ptr, label);			\
195 		break;							\
196 	default:							\
197 		__put_user_bad();					\
198 	}								\
199 	instrument_put_user(__x, __ptr, size);				\
200 } while (0)
201 
202 #ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT
203 
204 #ifdef CONFIG_X86_32
205 #define __get_user_asm_u64(x, ptr, label) do {				\
206 	unsigned int __gu_low, __gu_high;				\
207 	const unsigned int __user *__gu_ptr;				\
208 	__gu_ptr = (const void __user *)(ptr);				\
209 	__get_user_asm(__gu_low, __gu_ptr, "l", "=r", label);		\
210 	__get_user_asm(__gu_high, __gu_ptr+1, "l", "=r", label);	\
211 	(x) = ((unsigned long long)__gu_high << 32) | __gu_low;		\
212 } while (0)
213 #else
214 #define __get_user_asm_u64(x, ptr, label)				\
215 	__get_user_asm(x, ptr, "q", "=r", label)
216 #endif
217 
218 #define __get_user_size(x, ptr, size, label)				\
219 do {									\
220 	__chk_user_ptr(ptr);						\
221 	switch (size) {							\
222 	case 1:	{							\
223 		unsigned char x_u8__;					\
224 		__get_user_asm(x_u8__, ptr, "b", "=q", label);		\
225 		(x) = x_u8__;						\
226 		break;							\
227 	}								\
228 	case 2:								\
229 		__get_user_asm(x, ptr, "w", "=r", label);		\
230 		break;							\
231 	case 4:								\
232 		__get_user_asm(x, ptr, "l", "=r", label);		\
233 		break;							\
234 	case 8:								\
235 		__get_user_asm_u64(x, ptr, label);			\
236 		break;							\
237 	default:							\
238 		(x) = __get_user_bad();					\
239 	}								\
240 	instrument_get_user(x);						\
241 } while (0)
242 
243 #define __get_user_asm(x, addr, itype, ltype, label)			\
244 	asm_goto_output("\n"						\
245 		     "1:	mov"itype" %[umem],%[output]\n"		\
246 		     _ASM_EXTABLE_UA(1b, %l2)				\
247 		     : [output] ltype(x)				\
248 		     : [umem] "m" (__m(addr))				\
249 		     : : label)
250 
251 #else // !CONFIG_CC_HAS_ASM_GOTO_OUTPUT
252 
253 #ifdef CONFIG_X86_32
254 #define __get_user_asm_u64(x, ptr, retval)				\
255 ({									\
256 	__typeof__(ptr) __ptr = (ptr);					\
257 	asm volatile("\n"						\
258 		     "1:	movl %[lowbits],%%eax\n"		\
259 		     "2:	movl %[highbits],%%edx\n"		\
260 		     "3:\n"						\
261 		     _ASM_EXTABLE_TYPE_REG(1b, 3b, EX_TYPE_EFAULT_REG |	\
262 					   EX_FLAG_CLEAR_AX_DX,		\
263 					   %[errout])			\
264 		     _ASM_EXTABLE_TYPE_REG(2b, 3b, EX_TYPE_EFAULT_REG |	\
265 					   EX_FLAG_CLEAR_AX_DX,		\
266 					   %[errout])			\
267 		     : [errout] "=r" (retval),				\
268 		       [output] "=&A"(x)				\
269 		     : [lowbits] "m" (__m(__ptr)),			\
270 		       [highbits] "m" __m(((u32 __user *)(__ptr)) + 1),	\
271 		       "0" (retval));					\
272 })
273 
274 #else
275 #define __get_user_asm_u64(x, ptr, retval) \
276 	 __get_user_asm(x, ptr, retval, "q")
277 #endif
278 
279 #define __get_user_size(x, ptr, size, retval)				\
280 do {									\
281 	unsigned char x_u8__;						\
282 									\
283 	retval = 0;							\
284 	__chk_user_ptr(ptr);						\
285 	switch (size) {							\
286 	case 1:								\
287 		__get_user_asm(x_u8__, ptr, retval, "b");		\
288 		(x) = x_u8__;						\
289 		break;							\
290 	case 2:								\
291 		__get_user_asm(x, ptr, retval, "w");			\
292 		break;							\
293 	case 4:								\
294 		__get_user_asm(x, ptr, retval, "l");			\
295 		break;							\
296 	case 8:								\
297 		__get_user_asm_u64(x, ptr, retval);			\
298 		break;							\
299 	default:							\
300 		(x) = __get_user_bad();					\
301 	}								\
302 } while (0)
303 
304 #define __get_user_asm(x, addr, err, itype)				\
305 	asm volatile("\n"						\
306 		     "1:	mov"itype" %[umem],%[output]\n"		\
307 		     "2:\n"						\
308 		     _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG | \
309 					   EX_FLAG_CLEAR_AX,		\
310 					   %[errout])			\
311 		     : [errout] "=r" (err),				\
312 		       [output] "=a" (x)				\
313 		     : [umem] "m" (__m(addr)),				\
314 		       "0" (err))
315 
316 #endif // CONFIG_CC_HAS_ASM_GOTO_OUTPUT
317 
318 #ifdef CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT
319 #define __try_cmpxchg_user_asm(itype, ltype, _ptr, _pold, _new, label)	({ \
320 	bool success;							\
321 	__typeof__(_ptr) _old = (__typeof__(_ptr))(_pold);		\
322 	__typeof__(*(_ptr)) __old = *_old;				\
323 	__typeof__(*(_ptr)) __new = (_new);				\
324 	asm_goto_output("\n"						\
325 		     "1: " LOCK_PREFIX "cmpxchg"itype" %[new], %[ptr]\n"\
326 		     _ASM_EXTABLE_UA(1b, %l[label])			\
327 		     : "=@ccz" (success),				\
328 		       [ptr] "+m" (*_ptr),				\
329 		       [old] "+a" (__old)				\
330 		     : [new] ltype (__new)				\
331 		     : "memory"						\
332 		     : label);						\
333 	if (unlikely(!success))						\
334 		*_old = __old;						\
335 	likely(success);					})
336 
337 #ifdef CONFIG_X86_32
338 #define __try_cmpxchg64_user_asm(_ptr, _pold, _new, label)	({	\
339 	bool success;							\
340 	__typeof__(_ptr) _old = (__typeof__(_ptr))(_pold);		\
341 	__typeof__(*(_ptr)) __old = *_old;				\
342 	__typeof__(*(_ptr)) __new = (_new);				\
343 	asm_goto_output("\n"						\
344 		     "1: " LOCK_PREFIX "cmpxchg8b %[ptr]\n"		\
345 		     _ASM_EXTABLE_UA(1b, %l[label])			\
346 		     : "=@ccz" (success),				\
347 		       "+A" (__old),					\
348 		       [ptr] "+m" (*_ptr)				\
349 		     : "b" ((u32)__new),				\
350 		       "c" ((u32)((u64)__new >> 32))			\
351 		     : "memory"						\
352 		     : label);						\
353 	if (unlikely(!success))						\
354 		*_old = __old;						\
355 	likely(success);					})
356 #endif // CONFIG_X86_32
357 #else  // !CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT
358 #define __try_cmpxchg_user_asm(itype, ltype, _ptr, _pold, _new, label)	({ \
359 	int __err = 0;							\
360 	bool success;							\
361 	__typeof__(_ptr) _old = (__typeof__(_ptr))(_pold);		\
362 	__typeof__(*(_ptr)) __old = *_old;				\
363 	__typeof__(*(_ptr)) __new = (_new);				\
364 	asm volatile("\n"						\
365 		     "1: " LOCK_PREFIX "cmpxchg"itype" %[new], %[ptr]\n"\
366 		     "2:\n"						\
367 		     _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG,	\
368 					   %[errout])			\
369 		     : "=@ccz" (success),				\
370 		       [errout] "+r" (__err),				\
371 		       [ptr] "+m" (*_ptr),				\
372 		       [old] "+a" (__old)				\
373 		     : [new] ltype (__new)				\
374 		     : "memory");					\
375 	if (unlikely(__err))						\
376 		goto label;						\
377 	if (unlikely(!success))						\
378 		*_old = __old;						\
379 	likely(success);					})
380 
381 #ifdef CONFIG_X86_32
382 /*
383  * Unlike the normal CMPXCHG, use output GPR for both success/fail and error.
384  * There are only six GPRs available and four (EAX, EBX, ECX, and EDX) are
385  * hardcoded by CMPXCHG8B, leaving only ESI and EDI.  If the compiler uses
386  * both ESI and EDI for the memory operand, compilation will fail if the error
387  * is an input+output as there will be no register available for input.
388  */
389 #define __try_cmpxchg64_user_asm(_ptr, _pold, _new, label)	({	\
390 	int __result;							\
391 	__typeof__(_ptr) _old = (__typeof__(_ptr))(_pold);		\
392 	__typeof__(*(_ptr)) __old = *_old;				\
393 	__typeof__(*(_ptr)) __new = (_new);				\
394 	asm volatile("\n"						\
395 		     "1: " LOCK_PREFIX "cmpxchg8b %[ptr]\n"		\
396 		     "mov $0, %[result]\n\t"				\
397 		     "setz %b[result]\n"				\
398 		     "2:\n"						\
399 		     _ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_EFAULT_REG,	\
400 					   %[result])			\
401 		     : [result] "=q" (__result),			\
402 		       "+A" (__old),					\
403 		       [ptr] "+m" (*_ptr)				\
404 		     : "b" ((u32)__new),				\
405 		       "c" ((u32)((u64)__new >> 32))			\
406 		     : "memory", "cc");					\
407 	if (unlikely(__result < 0))					\
408 		goto label;						\
409 	if (unlikely(!__result))					\
410 		*_old = __old;						\
411 	likely(__result);					})
412 #endif // CONFIG_X86_32
413 #endif // CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT
414 
415 /* FIXME: this hack is definitely wrong -AK */
416 struct __large_struct { unsigned long buf[100]; };
417 #define __m(x) (*(struct __large_struct __user *)(x))
418 
419 /*
420  * Tell gcc we read from memory instead of writing: this is because
421  * we do not write to any memory gcc knows about, so there are no
422  * aliasing issues.
423  */
424 #define __put_user_goto(x, addr, itype, ltype, label)			\
425 	asm goto("\n"							\
426 		"1:	mov"itype" %0,%1\n"				\
427 		_ASM_EXTABLE_UA(1b, %l2)				\
428 		: : ltype(x), "m" (__m(addr))				\
429 		: : label)
430 
431 extern unsigned long
432 copy_from_user_nmi(void *to, const void __user *from, unsigned long n);
433 extern __must_check long
434 strncpy_from_user(char *dst, const char __user *src, long count);
435 
436 extern __must_check long strnlen_user(const char __user *str, long n);
437 
438 #ifdef CONFIG_ARCH_HAS_COPY_MC
439 unsigned long __must_check
440 copy_mc_to_kernel(void *to, const void *from, unsigned len);
441 #define copy_mc_to_kernel copy_mc_to_kernel
442 
443 unsigned long __must_check
444 copy_mc_to_user(void __user *to, const void *from, unsigned len);
445 #endif
446 
447 /*
448  * movsl can be slow when source and dest are not both 8-byte aligned
449  */
450 #ifdef CONFIG_X86_INTEL_USERCOPY
451 extern struct movsl_mask {
452 	int mask;
453 } ____cacheline_aligned_in_smp movsl_mask;
454 #endif
455 
456 #define ARCH_HAS_NONTEMPORAL_UACCESS 1
457 
458 /*
459  * The "unsafe" user accesses aren't really "unsafe", but the naming
460  * is a big fat warning: you have to not only do the access_ok()
461  * checking before using them, but you have to surround them with the
462  * user_access_begin/end() pair.
463  */
464 static __must_check __always_inline bool user_access_begin(const void __user *ptr, size_t len)
465 {
466 	if (unlikely(!access_ok(ptr,len)))
467 		return 0;
468 	__uaccess_begin_nospec();
469 	return 1;
470 }
471 #define user_access_begin(a,b)	user_access_begin(a,b)
472 #define user_access_end()	__uaccess_end()
473 
474 #define user_access_save()	smap_save()
475 #define user_access_restore(x)	smap_restore(x)
476 
477 #define arch_unsafe_put_user(x, ptr, label)	\
478 	__put_user_size((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)), label)
479 
480 #ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT
481 #define arch_unsafe_get_user(x, ptr, err_label)					\
482 do {										\
483 	__inttype(*(ptr)) __gu_val;						\
484 	__get_user_size(__gu_val, (ptr), sizeof(*(ptr)), err_label);		\
485 	(x) = (__force __typeof__(*(ptr)))__gu_val;				\
486 } while (0)
487 #else // !CONFIG_CC_HAS_ASM_GOTO_OUTPUT
488 #define arch_unsafe_get_user(x, ptr, err_label)					\
489 do {										\
490 	int __gu_err;								\
491 	__inttype(*(ptr)) __gu_val;						\
492 	__get_user_size(__gu_val, (ptr), sizeof(*(ptr)), __gu_err);		\
493 	(x) = (__force __typeof__(*(ptr)))__gu_val;				\
494 	if (unlikely(__gu_err)) goto err_label;					\
495 } while (0)
496 #endif // CONFIG_CC_HAS_ASM_GOTO_OUTPUT
497 
498 extern void __try_cmpxchg_user_wrong_size(void);
499 
500 #ifndef CONFIG_X86_32
501 #define __try_cmpxchg64_user_asm(_ptr, _oldp, _nval, _label)		\
502 	__try_cmpxchg_user_asm("q", "r", (_ptr), (_oldp), (_nval), _label)
503 #endif
504 
505 /*
506  * Force the pointer to u<size> to match the size expected by the asm helper.
507  * clang/LLVM compiles all cases and only discards the unused paths after
508  * processing errors, which breaks i386 if the pointer is an 8-byte value.
509  */
510 #define unsafe_try_cmpxchg_user(_ptr, _oldp, _nval, _label) ({			\
511 	bool __ret;								\
512 	__chk_user_ptr(_ptr);							\
513 	switch (sizeof(*(_ptr))) {						\
514 	case 1:	__ret = __try_cmpxchg_user_asm("b", "q",			\
515 					       (__force u8 *)(_ptr), (_oldp),	\
516 					       (_nval), _label);		\
517 		break;								\
518 	case 2:	__ret = __try_cmpxchg_user_asm("w", "r",			\
519 					       (__force u16 *)(_ptr), (_oldp),	\
520 					       (_nval), _label);		\
521 		break;								\
522 	case 4:	__ret = __try_cmpxchg_user_asm("l", "r",			\
523 					       (__force u32 *)(_ptr), (_oldp),	\
524 					       (_nval), _label);		\
525 		break;								\
526 	case 8:	__ret = __try_cmpxchg64_user_asm((__force u64 *)(_ptr), (_oldp),\
527 						 (_nval), _label);		\
528 		break;								\
529 	default: __try_cmpxchg_user_wrong_size();				\
530 	}									\
531 	__ret;						})
532 
533 /* "Returns" 0 on success, 1 on failure, -EFAULT if the access faults. */
534 #define __try_cmpxchg_user(_ptr, _oldp, _nval, _label)	({		\
535 	int __ret = -EFAULT;						\
536 	__uaccess_begin_nospec();					\
537 	__ret = !unsafe_try_cmpxchg_user(_ptr, _oldp, _nval, _label);	\
538 _label:									\
539 	__uaccess_end();						\
540 	__ret;								\
541 							})
542 
543 /*
544  * We want the unsafe accessors to always be inlined and use
545  * the error labels - thus the macro games.
546  */
547 #define unsafe_copy_loop(dst, src, len, type, label)				\
548 	while (len >= sizeof(type)) {						\
549 		unsafe_put_user(*(type *)(src),(type __user *)(dst),label);	\
550 		dst += sizeof(type);						\
551 		src += sizeof(type);						\
552 		len -= sizeof(type);						\
553 	}
554 
555 #define unsafe_copy_to_user(_dst,_src,_len,label)			\
556 do {									\
557 	char __user *__ucu_dst = (_dst);				\
558 	const char *__ucu_src = (_src);					\
559 	size_t __ucu_len = (_len);					\
560 	unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u64, label);	\
561 	unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u32, label);	\
562 	unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u16, label);	\
563 	unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u8, label);	\
564 } while (0)
565 
566 #ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT
567 #define arch_get_kernel_nofault(dst, src, type, err_label)		\
568 	__get_user_size(*((type *)(dst)), (__force type __user *)(src),	\
569 			sizeof(type), err_label)
570 #else // !CONFIG_CC_HAS_ASM_GOTO_OUTPUT
571 #define arch_get_kernel_nofault(dst, src, type, err_label)			\
572 do {									\
573 	int __kr_err;							\
574 									\
575 	__get_user_size(*((type *)(dst)), (__force type __user *)(src),	\
576 			sizeof(type), __kr_err);			\
577 	if (unlikely(__kr_err))						\
578 		goto err_label;						\
579 } while (0)
580 #endif // CONFIG_CC_HAS_ASM_GOTO_OUTPUT
581 
582 #define arch_put_kernel_nofault(dst, src, type, err_label)		\
583 	__put_user_size(*((type *)(src)), (__force type __user *)(dst),	\
584 			sizeof(type), err_label)
585 
586 #endif /* _ASM_X86_UACCESS_H */
587 
588