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\():
16 addi.d a0, a2, (\to) * (-8)
20 SYM_FUNC_START(__copy_user)
22 * Some CPUs support hardware unaligned access
24 ALTERNATIVE "b __copy_user_generic", \
25 "b __copy_user_fast", CPU_FEATURE_UAL
26 SYM_FUNC_END(__copy_user)
28 EXPORT_SYMBOL(__copy_user)
31 * unsigned long __copy_user_generic(void *to, const void *from, size_t n)
37 SYM_FUNC_START(__copy_user_generic)
50 _asm_extable 1b, .L_fixup_handle_0
51 _asm_extable 2b, .L_fixup_handle_0
52 SYM_FUNC_END(__copy_user_generic)
55 * unsigned long __copy_user_fast(void *to, const void *from, unsigned long n)
61 SYM_FUNC_START(__copy_user_fast)
67 /* copy 64 bytes at a time */
92 /* copy the remaining bytes */
104 /* fixup and ex_table */
105 _asm_extable 1b, .L_fixup_handle_0
106 _asm_extable 2b, .L_fixup_handle_1
107 _asm_extable 3b, .L_fixup_handle_2
108 _asm_extable 4b, .L_fixup_handle_3
109 _asm_extable 5b, .L_fixup_handle_4
110 _asm_extable 6b, .L_fixup_handle_5
111 _asm_extable 7b, .L_fixup_handle_6
112 _asm_extable 8b, .L_fixup_handle_7
113 _asm_extable 9b, .L_fixup_handle_0
114 _asm_extable 10b, .L_fixup_handle_1
115 _asm_extable 11b, .L_fixup_handle_2
116 _asm_extable 12b, .L_fixup_handle_3
117 _asm_extable 13b, .L_fixup_handle_4
118 _asm_extable 14b, .L_fixup_handle_5
119 _asm_extable 15b, .L_fixup_handle_6
120 _asm_extable 16b, .L_fixup_handle_7
121 _asm_extable 17b, .L_fixup_handle_0
122 _asm_extable 18b, .L_fixup_handle_0
123 SYM_FUNC_END(__copy_user_fast)