1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/arch/arm/lib/getuser.S
5 * Copyright (C) 2001 Russell King
7 * Idea from x86 version, (C) Copyright 1998 Linus Torvalds
9 * These functions have a non-standard call interface to make them more
10 * efficient, especially as they return an error value in addition to
11 * the "real" return value.
15 * Inputs: r0 contains the address
16 * r1 contains the address limit, which must be preserved
17 * Outputs: r0 is the error code
18 * r2, r3 contains the zero-extended value
21 * No other registers must be altered. (see <asm/uaccess.h>
22 * for specific ASM register usage).
24 * Note that ADDR_LIMIT is either 0 or 0xc0000000.
25 * Note also that it is intended that __get_user_bad is not global.
27 #include <linux/linkage.h>
28 #include <asm/assembler.h>
29 #include <asm/errno.h>
30 #include <asm/domain.h>
33 check_uaccess r0, 1, r1, r2, __get_user_bad
34 1: TUSER(ldrb) r2, [r0]
38 _ASM_NOKPROBE(__get_user_1)
41 check_uaccess r0, 2, r1, r2, __get_user_bad
42 #if __LINUX_ARM_ARCH__ >= 6
44 2: TUSER(ldrh) r2, [r0]
48 #ifdef CONFIG_CPU_USE_DOMAINS
58 orr r2, r2, rb, lsl #8
60 orr r2, rb, r2, lsl #8
63 #endif /* __LINUX_ARM_ARCH__ >= 6 */
68 _ASM_NOKPROBE(__get_user_2)
71 check_uaccess r0, 4, r1, r2, __get_user_bad
72 4: TUSER(ldr) r2, [r0]
76 _ASM_NOKPROBE(__get_user_4)
79 check_uaccess r0, 8, r1, r2, __get_user_bad8
80 #ifdef CONFIG_THUMB2_KERNEL
81 5: TUSER(ldr) r2, [r0]
82 6: TUSER(ldr) r3, [r0, #4]
84 5: TUSER(ldr) r2, [r0], #4
85 6: TUSER(ldr) r3, [r0]
90 _ASM_NOKPROBE(__get_user_8)
93 ENTRY(__get_user_32t_8)
94 check_uaccess r0, 8, r1, r2, __get_user_bad
95 #ifdef CONFIG_CPU_USE_DOMAINS
103 ENDPROC(__get_user_32t_8)
104 _ASM_NOKPROBE(__get_user_32t_8)
106 ENTRY(__get_user_64t_1)
107 check_uaccess r0, 1, r1, r2, __get_user_bad8
108 8: TUSER(ldrb) r3, [r0]
111 ENDPROC(__get_user_64t_1)
112 _ASM_NOKPROBE(__get_user_64t_1)
114 ENTRY(__get_user_64t_2)
115 check_uaccess r0, 2, r1, r2, __get_user_bad8
116 #ifdef CONFIG_CPU_USE_DOMAINS
118 9: ldrbt r3, [r0], #1
119 10: ldrbt rb, [r0], #0
123 10: ldrb rb, [r0, #1]
125 orr r3, rb, r3, lsl #8
128 ENDPROC(__get_user_64t_2)
129 _ASM_NOKPROBE(__get_user_64t_2)
131 ENTRY(__get_user_64t_4)
132 check_uaccess r0, 4, r1, r2, __get_user_bad8
133 11: TUSER(ldr) r3, [r0]
136 ENDPROC(__get_user_64t_4)
137 _ASM_NOKPROBE(__get_user_64t_4)
146 ENDPROC(__get_user_bad)
147 ENDPROC(__get_user_bad8)
148 _ASM_NOKPROBE(__get_user_bad)
149 _ASM_NOKPROBE(__get_user_bad8)
151 .pushsection __ex_table, "a"
152 .long 1b, __get_user_bad
153 .long 2b, __get_user_bad
154 #if __LINUX_ARM_ARCH__ < 6
155 .long 3b, __get_user_bad
157 .long 4b, __get_user_bad
158 .long 5b, __get_user_bad8
159 .long 6b, __get_user_bad8
161 .long 7b, __get_user_bad
162 .long 8b, __get_user_bad8
163 .long 9b, __get_user_bad8
164 .long 10b, __get_user_bad8
165 .long 11b, __get_user_bad8