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)
61 2: movb %al,(%_ASM_CX)
65 SYM_FUNC_END(__put_user_nocheck_1)
66 EXPORT_SYMBOL(__put_user_nocheck_1)
68 SYM_FUNC_START(__put_user_2)
71 3: movw %ax,(%_ASM_CX)
75 SYM_FUNC_END(__put_user_2)
76 EXPORT_SYMBOL(__put_user_2)
78 SYM_FUNC_START(__put_user_nocheck_2)
81 4: movw %ax,(%_ASM_CX)
85 SYM_FUNC_END(__put_user_nocheck_2)
86 EXPORT_SYMBOL(__put_user_nocheck_2)
88 SYM_FUNC_START(__put_user_4)
91 5: movl %eax,(%_ASM_CX)
95 SYM_FUNC_END(__put_user_4)
96 EXPORT_SYMBOL(__put_user_4)
98 SYM_FUNC_START(__put_user_nocheck_4)
101 6: movl %eax,(%_ASM_CX)
105 SYM_FUNC_END(__put_user_nocheck_4)
106 EXPORT_SYMBOL(__put_user_nocheck_4)
108 SYM_FUNC_START(__put_user_8)
111 7: mov %_ASM_AX,(%_ASM_CX)
113 8: movl %edx,4(%_ASM_CX)
118 SYM_FUNC_END(__put_user_8)
119 EXPORT_SYMBOL(__put_user_8)
121 SYM_FUNC_START(__put_user_nocheck_8)
124 9: mov %_ASM_AX,(%_ASM_CX)
126 10: movl %edx,4(%_ASM_CX)
131 SYM_FUNC_END(__put_user_nocheck_8)
132 EXPORT_SYMBOL(__put_user_nocheck_8)
134 SYM_CODE_START_LOCAL(__put_user_handle_exception)
139 SYM_CODE_END(__put_user_handle_exception)
141 _ASM_EXTABLE(1b, __put_user_handle_exception)
142 _ASM_EXTABLE(2b, __put_user_handle_exception)
143 _ASM_EXTABLE(3b, __put_user_handle_exception)
144 _ASM_EXTABLE(4b, __put_user_handle_exception)
145 _ASM_EXTABLE(5b, __put_user_handle_exception)
146 _ASM_EXTABLE(6b, __put_user_handle_exception)
147 _ASM_EXTABLE(7b, __put_user_handle_exception)
148 _ASM_EXTABLE(9b, __put_user_handle_exception)
150 _ASM_EXTABLE(8b, __put_user_handle_exception)
151 _ASM_EXTABLE(10b, __put_user_handle_exception)