2 * __get_user functions.
4 * (C) Copyright 1998 Linus Torvalds
5 * (C) Copyright 2005 Andi Kleen
6 * (C) Copyright 2008 Glauber Costa
8 * These functions have a non-standard call interface
9 * to make them more efficient, especially as they
10 * return an error value in addition to the "real"
17 * Inputs: %[r|e]ax contains the address.
19 * Outputs: %[r|e]ax is error code (0 or -EFAULT)
20 * %[r|e]dx contains zero-extended value
21 * %ecx contains the high half for 32-bit __get_user_8
24 * These functions should not modify any other registers,
25 * as they get called from within inline assembly.
28 #include <linux/linkage.h>
29 #include <asm/page_types.h>
30 #include <asm/errno.h>
31 #include <asm/asm-offsets.h>
32 #include <asm/thread_info.h>
35 #include <asm/export.h>
39 mov PER_CPU_VAR(current_task), %_ASM_DX
40 cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX
42 sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */
43 and %_ASM_DX, %_ASM_AX
45 1: movzbl (%_ASM_AX),%edx
50 EXPORT_SYMBOL(__get_user_1)
55 mov PER_CPU_VAR(current_task), %_ASM_DX
56 cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX
58 sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */
59 and %_ASM_DX, %_ASM_AX
61 2: movzwl -1(%_ASM_AX),%edx
66 EXPORT_SYMBOL(__get_user_2)
71 mov PER_CPU_VAR(current_task), %_ASM_DX
72 cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX
74 sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */
75 and %_ASM_DX, %_ASM_AX
77 3: movl -3(%_ASM_AX),%edx
82 EXPORT_SYMBOL(__get_user_4)
88 mov PER_CPU_VAR(current_task), %_ASM_DX
89 cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX
91 sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */
92 and %_ASM_DX, %_ASM_AX
94 4: movq -7(%_ASM_AX),%rdx
101 mov PER_CPU_VAR(current_task), %_ASM_DX
102 cmp TASK_addr_limit(%_ASM_DX),%_ASM_AX
104 sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */
105 and %_ASM_DX, %_ASM_AX
107 4: movl -7(%_ASM_AX),%edx
108 5: movl -3(%_ASM_AX),%ecx
113 ENDPROC(__get_user_8)
114 EXPORT_SYMBOL(__get_user_8)
119 mov $(-EFAULT),%_ASM_AX
128 mov $(-EFAULT),%_ASM_AX
134 _ASM_EXTABLE(1b,bad_get_user)
135 _ASM_EXTABLE(2b,bad_get_user)
136 _ASM_EXTABLE(3b,bad_get_user)
138 _ASM_EXTABLE(4b,bad_get_user)
140 _ASM_EXTABLE(4b,bad_get_user_8)
141 _ASM_EXTABLE(5b,bad_get_user_8)