1 /* SPDX-License-Identifier: GPL-2.0 */
3 * __put_user functions.
5 * (C) Copyright 2005 Linus Torvalds
6 * (C) Copyright 2005 Andi Kleen
7 * (C) Copyright 2008 Glauber Costa
9 * These functions have a non-standard call interface
10 * to make them more efficient, especially as they
11 * return an error value in addition to the "real"
14 #include <linux/linkage.h>
15 #include <asm/thread_info.h>
16 #include <asm/errno.h>
19 #include <asm/export.h>
25 * Inputs: %eax[:%edx] contains the data
26 * %ecx contains the address
28 * Outputs: %ecx is error code (0 or -EFAULT)
30 * Clobbers: %ebx needed for task pointer
32 * These functions should not modify any other registers,
33 * as they get called from within inline assembly.
36 #define ENTER mov PER_CPU_VAR(current_task), %_ASM_BX
39 SYM_FUNC_START(__put_user_1)
41 cmp TASK_addr_limit(%_ASM_BX),%_ASM_CX
43 SYM_INNER_LABEL(__put_user_nocheck_1, SYM_L_GLOBAL)
45 1: movb %al,(%_ASM_CX)
49 SYM_FUNC_END(__put_user_1)
50 EXPORT_SYMBOL(__put_user_1)
51 EXPORT_SYMBOL(__put_user_nocheck_1)
53 SYM_FUNC_START(__put_user_2)
55 mov TASK_addr_limit(%_ASM_BX),%_ASM_BX
59 SYM_INNER_LABEL(__put_user_nocheck_2, SYM_L_GLOBAL)
61 2: movw %ax,(%_ASM_CX)
65 SYM_FUNC_END(__put_user_2)
66 EXPORT_SYMBOL(__put_user_2)
67 EXPORT_SYMBOL(__put_user_nocheck_2)
69 SYM_FUNC_START(__put_user_4)
71 mov TASK_addr_limit(%_ASM_BX),%_ASM_BX
75 SYM_INNER_LABEL(__put_user_nocheck_4, SYM_L_GLOBAL)
77 3: movl %eax,(%_ASM_CX)
81 SYM_FUNC_END(__put_user_4)
82 EXPORT_SYMBOL(__put_user_4)
83 EXPORT_SYMBOL(__put_user_nocheck_4)
85 SYM_FUNC_START(__put_user_8)
87 mov TASK_addr_limit(%_ASM_BX),%_ASM_BX
91 SYM_INNER_LABEL(__put_user_nocheck_8, SYM_L_GLOBAL)
93 4: mov %_ASM_AX,(%_ASM_CX)
95 5: movl %edx,4(%_ASM_CX)
100 SYM_FUNC_END(__put_user_8)
101 EXPORT_SYMBOL(__put_user_8)
102 EXPORT_SYMBOL(__put_user_nocheck_8)
104 SYM_CODE_START_LOCAL(.Lbad_put_user_clac)
109 SYM_CODE_END(.Lbad_put_user_clac)
111 _ASM_EXTABLE_UA(1b, .Lbad_put_user_clac)
112 _ASM_EXTABLE_UA(2b, .Lbad_put_user_clac)
113 _ASM_EXTABLE_UA(3b, .Lbad_put_user_clac)
114 _ASM_EXTABLE_UA(4b, .Lbad_put_user_clac)
116 _ASM_EXTABLE_UA(5b, .Lbad_put_user_clac)