summaryrefslogtreecommitdiffstats
path: root/arch/loongarch/lib/copy_user.S
blob: 61933d964da03dbfdcf44430d23094b5e4202cca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
 */

#include <asm/asm.h>
#include <asm/asmmacro.h>
#include <asm/asm-extable.h>
#include <asm/export.h>
#include <asm/regdef.h>

.irp to, 0
.L_fixup_handle_\to\():
	addi.d	a0, a2, (\to) * (-8)
	jr	ra
.endr

/*
 * unsigned long __copy_user(void *to, const void *from, size_t n)
 *
 * a0: to
 * a1: from
 * a2: n
 */
SYM_FUNC_START(__copy_user)
	beqz	a2, 3f

1:	ld.b	t0, a1, 0
2:	st.b	t0, a0, 0
	addi.d	a0, a0, 1
	addi.d	a1, a1, 1
	addi.d	a2, a2, -1
	bgtz	a2, 1b

3:	move	a0, a2
	jr	ra

	_asm_extable 1b, .L_fixup_handle_0
	_asm_extable 2b, .L_fixup_handle_0
SYM_FUNC_END(__copy_user)

EXPORT_SYMBOL(__copy_user)