xref: /linux/arch/arm64/lib/copy_from_user.S (revision cbd32a1c56e36fedaa93a727699188bd3e6e6f67)
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2012 ARM Ltd.
4 */
5
6#include <linux/linkage.h>
7
8#include <asm/asm-uaccess.h>
9#include <asm/assembler.h>
10#include <asm/cache.h>
11
12/*
13 * Copy from user space to a kernel buffer (alignment handled by the hardware)
14 *
15 * Parameters:
16 *	x0 - to
17 *	x1 - from
18 *	x2 - n
19 * Returns:
20 *	x0 - bytes not copied
21 */
22
23	.macro ldrb1 ptr, regB, val
24	uao_user_alternative 9998f, ldrb, ldtrb, \ptr, \regB, \val
25	.endm
26
27	.macro strb1 ptr, regB, val
28	strb \ptr, [\regB], \val
29	.endm
30
31	.macro ldrh1 ptr, regB, val
32	uao_user_alternative 9998f, ldrh, ldtrh, \ptr, \regB, \val
33	.endm
34
35	.macro strh1 ptr, regB, val
36	strh \ptr, [\regB], \val
37	.endm
38
39	.macro ldr1 ptr, regB, val
40	uao_user_alternative 9998f, ldr, ldtr, \ptr, \regB, \val
41	.endm
42
43	.macro str1 ptr, regB, val
44	str \ptr, [\regB], \val
45	.endm
46
47	.macro ldp1 ptr, regB, regC, val
48	uao_ldp 9998f, \ptr, \regB, \regC, \val
49	.endm
50
51	.macro stp1 ptr, regB, regC, val
52	stp \ptr, \regB, [\regC], \val
53	.endm
54
55end	.req	x5
56ENTRY(__arch_copy_from_user)
57	uaccess_enable_not_uao x3, x4, x5
58	add	end, x0, x2
59#include "copy_template.S"
60	uaccess_disable_not_uao x3, x4
61	mov	x0, #0				// Nothing to copy
62	ret
63ENDPROC(__arch_copy_from_user)
64EXPORT_SYMBOL(__arch_copy_from_user)
65
66	.section .fixup,"ax"
67	.align	2
689998:	sub	x0, end, dst			// bytes not copied
69	ret
70	.previous
71