1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
6 #include <asm/alternative-asm.h>
8 #include <asm/asmmacro.h>
9 #include <asm/asm-extable.h>
11 #include <asm/export.h>
12 #include <asm/regdef.h>
14 .irp to, 0, 1, 2, 3, 4, 5, 6, 7
15 .L_fixup_handle_\to\():
17 addi.d a0, a0, (\to) * (-8)
22 .L_fixup_handle_s\to\():
27 SYM_FUNC_START(__clear_user)
29 * Some CPUs support hardware unaligned access
31 ALTERNATIVE "b __clear_user_generic", \
32 "b __clear_user_fast", CPU_FEATURE_UAL
33 SYM_FUNC_END(__clear_user)
35 EXPORT_SYMBOL(__clear_user)
38 * unsigned long __clear_user_generic(void *addr, size_t size)
43 SYM_FUNC_START(__clear_user_generic)
54 _asm_extable 1b, .L_fixup_handle_s0
55 SYM_FUNC_END(__clear_user_generic)
58 * unsigned long __clear_user_fast(void *addr, unsigned long size)
63 SYM_FUNC_START(__clear_user_fast)
70 /* align up address */
72 bstrins.d a0, zero, 2, 0
77 /* set 64 bytes at a time */
90 /* set the remaining bytes */
113 16: st.d zero, a2, -8
174 /* fixup and ex_table */
175 _asm_extable 0b, .L_fixup_handle_0
176 _asm_extable 1b, .L_fixup_handle_0
177 _asm_extable 2b, .L_fixup_handle_1
178 _asm_extable 3b, .L_fixup_handle_2
179 _asm_extable 4b, .L_fixup_handle_3
180 _asm_extable 5b, .L_fixup_handle_4
181 _asm_extable 6b, .L_fixup_handle_5
182 _asm_extable 7b, .L_fixup_handle_6
183 _asm_extable 8b, .L_fixup_handle_7
184 _asm_extable 9b, .L_fixup_handle_0
185 _asm_extable 10b, .L_fixup_handle_1
186 _asm_extable 11b, .L_fixup_handle_2
187 _asm_extable 12b, .L_fixup_handle_3
188 _asm_extable 13b, .L_fixup_handle_0
189 _asm_extable 14b, .L_fixup_handle_1
190 _asm_extable 15b, .L_fixup_handle_0
191 _asm_extable 16b, .L_fixup_handle_1
192 _asm_extable 17b, .L_fixup_handle_s0
193 _asm_extable 18b, .L_fixup_handle_s0
194 _asm_extable 19b, .L_fixup_handle_s0
195 _asm_extable 20b, .L_fixup_handle_s2
196 _asm_extable 21b, .L_fixup_handle_s0
197 _asm_extable 22b, .L_fixup_handle_s0
198 _asm_extable 23b, .L_fixup_handle_s4
199 _asm_extable 24b, .L_fixup_handle_s0
200 _asm_extable 25b, .L_fixup_handle_s4
201 _asm_extable 26b, .L_fixup_handle_s0
202 _asm_extable 27b, .L_fixup_handle_s4
203 _asm_extable 28b, .L_fixup_handle_s0
204 SYM_FUNC_END(__clear_user_fast)