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>
38 GET_THREAD_INFO(%_ASM_DX)
39 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
41 sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */
42 and %_ASM_DX, %_ASM_AX
44 1: movzbl (%_ASM_AX),%edx
53 GET_THREAD_INFO(%_ASM_DX)
54 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
56 sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */
57 and %_ASM_DX, %_ASM_AX
59 2: movzwl -1(%_ASM_AX),%edx
68 GET_THREAD_INFO(%_ASM_DX)
69 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
71 sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */
72 and %_ASM_DX, %_ASM_AX
74 3: movl -3(%_ASM_AX),%edx
84 GET_THREAD_INFO(%_ASM_DX)
85 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
87 sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */
88 and %_ASM_DX, %_ASM_AX
90 4: movq -7(%_ASM_AX),%rdx
97 GET_THREAD_INFO(%_ASM_DX)
98 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
100 sbb %_ASM_DX, %_ASM_DX /* array_index_mask_nospec() */
101 and %_ASM_DX, %_ASM_AX
103 4: movl -7(%_ASM_AX),%edx
104 5: movl -3(%_ASM_AX),%ecx
109 ENDPROC(__get_user_8)
114 mov $(-EFAULT),%_ASM_AX
123 mov $(-EFAULT),%_ASM_AX
129 _ASM_EXTABLE(1b,bad_get_user)
130 _ASM_EXTABLE(2b,bad_get_user)
131 _ASM_EXTABLE(3b,bad_get_user)
133 _ASM_EXTABLE(4b,bad_get_user)
135 _ASM_EXTABLE(4b,bad_get_user_8)
136 _ASM_EXTABLE(5b,bad_get_user_8)