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: %eax is error code (0 or -EFAULT)
30 * These functions should not modify any other registers,
31 * as they get called from within inline assembly.
34 #define ENTER mov PER_CPU_VAR(current_task), %_ASM_BX
35 #define EXIT ASM_CLAC ; \
41 cmp TASK_addr_limit(%_ASM_BX),%_ASM_CX
44 1: movb %al,(%_ASM_CX)
48 EXPORT_SYMBOL(__put_user_1)
52 mov TASK_addr_limit(%_ASM_BX),%_ASM_BX
57 2: movw %ax,(%_ASM_CX)
61 EXPORT_SYMBOL(__put_user_2)
65 mov TASK_addr_limit(%_ASM_BX),%_ASM_BX
70 3: movl %eax,(%_ASM_CX)
74 EXPORT_SYMBOL(__put_user_4)
78 mov TASK_addr_limit(%_ASM_BX),%_ASM_BX
83 4: mov %_ASM_AX,(%_ASM_CX)
85 5: movl %edx,4(%_ASM_CX)
90 EXPORT_SYMBOL(__put_user_8)
97 _ASM_EXTABLE(1b,bad_put_user)
98 _ASM_EXTABLE(2b,bad_put_user)
99 _ASM_EXTABLE(3b,bad_put_user)
100 _ASM_EXTABLE(4b,bad_put_user)
102 _ASM_EXTABLE(5b,bad_put_user)