1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
6 #include <linux/export.h>
7 #include <asm/alternative-asm.h>
9 #include <asm/asmmacro.h>
10 #include <asm/asm-extable.h>
12 #include <asm/regdef.h>
13 #include <asm/unwind_hints.h>
15 SYM_FUNC_START(__clear_user)
17 * Some CPUs support hardware unaligned access
19 ALTERNATIVE "b __clear_user_generic", \
20 "b __clear_user_fast", CPU_FEATURE_UAL
21 SYM_FUNC_END(__clear_user)
23 EXPORT_SYMBOL(__clear_user)
26 * unsigned long __clear_user_generic(void *addr, size_t size)
31 SYM_FUNC_START(__clear_user_generic)
43 SYM_FUNC_END(__clear_user_generic)
46 * unsigned long __clear_user_fast(void *addr, unsigned long size)
51 SYM_FUNC_START(__clear_user_fast)
58 /* align up address */
60 bstrins.d a0, zero, 2, 0
65 /* set 64 bytes at a time */
78 /* set the remaining bytes */
102 16: st.d zero, a2, -8
163 /* fixup and ex_table */
177 _asm_extable 0b, .Lsmall_fixup
178 _asm_extable 1b, .Llarge_fixup
179 _asm_extable 2b, .Llarge_fixup
180 _asm_extable 3b, .Llarge_fixup
181 _asm_extable 4b, .Llarge_fixup
182 _asm_extable 5b, .Llarge_fixup
183 _asm_extable 6b, .Llarge_fixup
184 _asm_extable 7b, .Llarge_fixup
185 _asm_extable 8b, .Llarge_fixup
186 _asm_extable 9b, .Llarge_fixup
187 _asm_extable 10b, .Llarge_fixup
188 _asm_extable 11b, .Llarge_fixup
189 _asm_extable 12b, .Llarge_fixup
190 _asm_extable 13b, .Llarge_fixup
191 _asm_extable 14b, .Llarge_fixup
192 _asm_extable 15b, .Llarge_fixup
193 _asm_extable 16b, .Llarge_fixup
194 _asm_extable 17b, .Lexit
195 _asm_extable 18b, .Lsmall_fixup
196 _asm_extable 19b, .Lsmall_fixup
197 _asm_extable 20b, .Lsmall_fixup
198 _asm_extable 21b, .Lsmall_fixup
199 _asm_extable 22b, .Lsmall_fixup
200 _asm_extable 23b, .Lsmall_fixup
201 _asm_extable 24b, .Lsmall_fixup
202 _asm_extable 25b, .Lsmall_fixup
203 _asm_extable 26b, .Lsmall_fixup
204 _asm_extable 27b, .Lsmall_fixup
205 _asm_extable 28b, .Lsmall_fixup
206 _asm_extable 29b, .Lexit
207 SYM_FUNC_END(__clear_user_fast)
209 STACK_FRAME_NON_STANDARD __clear_user_fast