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 .macro check_range size:req
37 .if IS_ENABLED(CONFIG_X86_64)
42 cmp $TASK_SIZE_MAX-\size+1, %ecx
48 SYM_FUNC_START(__put_user_1)
51 1: movb %al,(%_ASM_CX)
55 SYM_FUNC_END(__put_user_1)
56 EXPORT_SYMBOL(__put_user_1)
58 SYM_FUNC_START(__put_user_nocheck_1)
60 2: movb %al,(%_ASM_CX)
64 SYM_FUNC_END(__put_user_nocheck_1)
65 EXPORT_SYMBOL(__put_user_nocheck_1)
67 SYM_FUNC_START(__put_user_2)
70 3: movw %ax,(%_ASM_CX)
74 SYM_FUNC_END(__put_user_2)
75 EXPORT_SYMBOL(__put_user_2)
77 SYM_FUNC_START(__put_user_nocheck_2)
79 4: movw %ax,(%_ASM_CX)
83 SYM_FUNC_END(__put_user_nocheck_2)
84 EXPORT_SYMBOL(__put_user_nocheck_2)
86 SYM_FUNC_START(__put_user_4)
89 5: movl %eax,(%_ASM_CX)
93 SYM_FUNC_END(__put_user_4)
94 EXPORT_SYMBOL(__put_user_4)
96 SYM_FUNC_START(__put_user_nocheck_4)
98 6: movl %eax,(%_ASM_CX)
102 SYM_FUNC_END(__put_user_nocheck_4)
103 EXPORT_SYMBOL(__put_user_nocheck_4)
105 SYM_FUNC_START(__put_user_8)
108 7: mov %_ASM_AX,(%_ASM_CX)
110 8: movl %edx,4(%_ASM_CX)
115 SYM_FUNC_END(__put_user_8)
116 EXPORT_SYMBOL(__put_user_8)
118 SYM_FUNC_START(__put_user_nocheck_8)
120 9: mov %_ASM_AX,(%_ASM_CX)
122 10: movl %edx,4(%_ASM_CX)
127 SYM_FUNC_END(__put_user_nocheck_8)
128 EXPORT_SYMBOL(__put_user_nocheck_8)
130 SYM_CODE_START_LOCAL(__put_user_handle_exception)
135 SYM_CODE_END(__put_user_handle_exception)
137 _ASM_EXTABLE(1b, __put_user_handle_exception)
138 _ASM_EXTABLE(2b, __put_user_handle_exception)
139 _ASM_EXTABLE(3b, __put_user_handle_exception)
140 _ASM_EXTABLE(4b, __put_user_handle_exception)
141 _ASM_EXTABLE(5b, __put_user_handle_exception)
142 _ASM_EXTABLE(6b, __put_user_handle_exception)
143 _ASM_EXTABLE(7b, __put_user_handle_exception)
144 _ASM_EXTABLE(9b, __put_user_handle_exception)
146 _ASM_EXTABLE(8b, __put_user_handle_exception)
147 _ASM_EXTABLE(10b, __put_user_handle_exception)