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>
39 SYM_FUNC_START(__get_user_1)
40 mov PER_CPU_VAR(current_task), %_ASM_DX
41 cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX
43 sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */
44 and %_ASM_DX, %_ASM_AX
46 1: movzbl (%_ASM_AX),%edx
50 SYM_FUNC_END(__get_user_1)
51 EXPORT_SYMBOL(__get_user_1)
53 SYM_FUNC_START(__get_user_2)
56 mov PER_CPU_VAR(current_task), %_ASM_DX
57 cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX
59 sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */
60 and %_ASM_DX, %_ASM_AX
62 2: movzwl -1(%_ASM_AX),%edx
66 SYM_FUNC_END(__get_user_2)
67 EXPORT_SYMBOL(__get_user_2)
69 SYM_FUNC_START(__get_user_4)
72 mov PER_CPU_VAR(current_task), %_ASM_DX
73 cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX
75 sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */
76 and %_ASM_DX, %_ASM_AX
78 3: movl -3(%_ASM_AX),%edx
82 SYM_FUNC_END(__get_user_4)
83 EXPORT_SYMBOL(__get_user_4)
85 SYM_FUNC_START(__get_user_8)
89 mov PER_CPU_VAR(current_task), %_ASM_DX
90 cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX
92 sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */
93 and %_ASM_DX, %_ASM_AX
95 4: movq -7(%_ASM_AX),%rdx
102 mov PER_CPU_VAR(current_task), %_ASM_DX
103 cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX
105 sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */
106 and %_ASM_DX, %_ASM_AX
108 4: movl -7(%_ASM_AX),%edx
109 5: movl -3(%_ASM_AX),%ecx
114 SYM_FUNC_END(__get_user_8)
115 EXPORT_SYMBOL(__get_user_8)
118 SYM_CODE_START_LOCAL(.Lbad_get_user_clac)
122 mov $(-EFAULT),%_ASM_AX
124 SYM_CODE_END(.Lbad_get_user_clac)
127 SYM_CODE_START_LOCAL(.Lbad_get_user_8_clac)
132 mov $(-EFAULT),%_ASM_AX
134 SYM_CODE_END(.Lbad_get_user_8_clac)
137 _ASM_EXTABLE_UA(1b, .Lbad_get_user_clac)
138 _ASM_EXTABLE_UA(2b, .Lbad_get_user_clac)
139 _ASM_EXTABLE_UA(3b, .Lbad_get_user_clac)
141 _ASM_EXTABLE_UA(4b, .Lbad_get_user_clac)
143 _ASM_EXTABLE_UA(4b, .Lbad_get_user_8_clac)
144 _ASM_EXTABLE_UA(5b, .Lbad_get_user_8_clac)