1 /* SPDX-License-Identifier: GPL-2.0 */
3 * __get_user functions.
5 * (C) Copyright 1998 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"
18 * Inputs: %[r|e]ax contains the address.
20 * Outputs: %[r|e]ax is error code (0 or -EFAULT)
21 * %[r|e]dx contains zero-extended value
22 * %ecx contains the high half for 32-bit __get_user_8
25 * These functions should not modify any other registers,
26 * as they get called from within inline assembly.
29 #include <linux/linkage.h>
30 #include <asm/page_types.h>
31 #include <asm/errno.h>
32 #include <asm/asm-offsets.h>
33 #include <asm/thread_info.h>
36 #include <asm/export.h>
40 mov PER_CPU_VAR(current_task), %_ASM_DX
41 cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX
44 1: movzbl (%_ASM_AX),%edx
49 EXPORT_SYMBOL(__get_user_1)
54 mov PER_CPU_VAR(current_task), %_ASM_DX
55 cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX
58 2: movzwl -1(%_ASM_AX),%edx
63 EXPORT_SYMBOL(__get_user_2)
68 mov PER_CPU_VAR(current_task), %_ASM_DX
69 cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX
72 3: movl -3(%_ASM_AX),%edx
77 EXPORT_SYMBOL(__get_user_4)
83 mov PER_CPU_VAR(current_task), %_ASM_DX
84 cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX
87 4: movq -7(%_ASM_AX),%rdx
94 mov PER_CPU_VAR(current_task), %_ASM_DX
95 cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX
98 4: movl -7(%_ASM_AX),%edx
99 5: movl -3(%_ASM_AX),%ecx
104 ENDPROC(__get_user_8)
105 EXPORT_SYMBOL(__get_user_8)
110 mov $(-EFAULT),%_ASM_AX
119 mov $(-EFAULT),%_ASM_AX
125 _ASM_EXTABLE(1b,bad_get_user)
126 _ASM_EXTABLE(2b,bad_get_user)
127 _ASM_EXTABLE(3b,bad_get_user)
129 _ASM_EXTABLE(4b,bad_get_user)
131 _ASM_EXTABLE(4b,bad_get_user_8)
132 _ASM_EXTABLE(5b,bad_get_user_8)