1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/arch/arm/lib/copy_from_user.S
5 * Author: Nicolas Pitre
6 * Created: Sep 29, 2005
7 * Copyright: MontaVista Software, Inc.
10 #include <linux/linkage.h>
11 #include <asm/assembler.h>
12 #include <asm/unwind.h>
17 * size_t arm_copy_from_user(void *to, const void *from, size_t n)
21 * copy a block to kernel memory from user memory
27 * n = number of bytes to copy
31 * Number of bytes NOT copied.
34 #ifdef CONFIG_CPU_USE_DOMAINS
36 #ifndef CONFIG_THUMB2_KERNEL
42 .macro ldr1w ptr reg abort
43 ldrusr \reg, \ptr, 4, abort=\abort
46 .macro ldr4w ptr reg1 reg2 reg3 reg4 abort
47 ldr1w \ptr, \reg1, \abort
48 ldr1w \ptr, \reg2, \abort
49 ldr1w \ptr, \reg3, \abort
50 ldr1w \ptr, \reg4, \abort
53 .macro ldr8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
54 ldr4w \ptr, \reg1, \reg2, \reg3, \reg4, \abort
55 ldr4w \ptr, \reg5, \reg6, \reg7, \reg8, \abort
62 .macro ldr1w ptr reg abort
63 USERL(\abort, W(ldr) \reg, [\ptr], #4)
66 .macro ldr4w ptr reg1 reg2 reg3 reg4 abort
67 USERL(\abort, ldmia \ptr!, {\reg1, \reg2, \reg3, \reg4})
70 .macro ldr8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
71 USERL(\abort, ldmia \ptr!, {\reg1, \reg2, \reg3, \reg4, \reg5, \reg6, \reg7, \reg8})
74 #endif /* CONFIG_CPU_USE_DOMAINS */
76 .macro ldr1b ptr reg cond=al abort
77 ldrusr \reg, \ptr, 1, \cond, abort=\abort
82 .macro str1w ptr reg abort
83 W(str) \reg, [\ptr], #4
86 .macro str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
87 stmia \ptr!, {\reg1, \reg2, \reg3, \reg4, \reg5, \reg6, \reg7, \reg8}
90 .macro str1b ptr reg cond=al abort
91 strb\cond \reg, [\ptr], #1
94 .macro enter reg1 reg2
96 stmdb sp!, {r0, r2, r3, \reg1, \reg2}
99 .macro usave reg1 reg2
100 UNWIND( .save {r0, r2, r3, \reg1, \reg2} )
103 .macro exit reg1 reg2
105 ldmfd sp!, {r0, \reg1, \reg2}
110 ENTRY(arm_copy_from_user)
111 #ifdef CONFIG_CPU_SPECTRE
113 ldr r3, [r3, #TI_ADDR_LIMIT]
114 uaccess_mask_range_ptr r1, r2, r3, ip
117 #include "copy_template.S"
119 ENDPROC(arm_copy_from_user)
121 .pushsection .text.fixup,"ax"
124 ldmfd sp!, {r1, r2, r3}