xref: /openbmc/linux/arch/loongarch/lib/clear_user.S (revision da1d9caf)
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
4 */
5
6#include <asm/asm.h>
7#include <asm/asmmacro.h>
8#include <asm/export.h>
9#include <asm/regdef.h>
10
11.macro fixup_ex from, to, offset, fix
12.if \fix
13	.section .fixup, "ax"
14\to:	addi.d	a0, a1, \offset
15	jr	ra
16	.previous
17.endif
18	.section __ex_table, "a"
19	PTR	\from\()b, \to\()b
20	.previous
21.endm
22
23/*
24 * unsigned long __clear_user(void *addr, size_t size)
25 *
26 * a0: addr
27 * a1: size
28 */
29SYM_FUNC_START(__clear_user)
30	beqz	a1, 2f
31
321:	st.b	zero, a0, 0
33	addi.d	a0, a0, 1
34	addi.d	a1, a1, -1
35	bgt	a1, zero, 1b
36
372:	move	a0, a1
38	jr	ra
39
40	fixup_ex 1, 3, 0, 1
41SYM_FUNC_END(__clear_user)
42
43EXPORT_SYMBOL(__clear_user)
44