2 * linux/arch/arm/lib/copy_to_user.S
4 * Author: Nicolas Pitre
5 * Created: Sep 29, 2005
6 * Copyright: MontaVista Software, Inc.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/linkage.h>
14 #include <asm/assembler.h>
15 #include <asm/unwind.h>
20 * size_t arm_copy_to_user(void *to, const void *from, size_t n)
24 * copy a block to user memory from kernel memory
29 * from = kernel memory
30 * n = number of bytes to copy
34 * Number of bytes NOT copied.
38 #ifndef CONFIG_THUMB2_KERNEL
44 .macro ldr1w ptr reg abort
45 W(ldr) \reg, [\ptr], #4
48 .macro ldr4w ptr reg1 reg2 reg3 reg4 abort
49 ldmia \ptr!, {\reg1, \reg2, \reg3, \reg4}
52 .macro ldr8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
53 ldmia \ptr!, {\reg1, \reg2, \reg3, \reg4, \reg5, \reg6, \reg7, \reg8}
56 .macro ldr1b ptr reg cond=al abort
57 ldr\cond\()b \reg, [\ptr], #1
60 .macro str1w ptr reg abort
61 strusr \reg, \ptr, 4, abort=\abort
64 .macro str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
65 str1w \ptr, \reg1, \abort
66 str1w \ptr, \reg2, \abort
67 str1w \ptr, \reg3, \abort
68 str1w \ptr, \reg4, \abort
69 str1w \ptr, \reg5, \abort
70 str1w \ptr, \reg6, \abort
71 str1w \ptr, \reg7, \abort
72 str1w \ptr, \reg8, \abort
75 .macro str1b ptr reg cond=al abort
76 strusr \reg, \ptr, 1, \cond, abort=\abort
79 .macro enter reg1 reg2
81 stmdb sp!, {r0, r2, r3, \reg1, \reg2}
84 .macro usave reg1 reg2
85 UNWIND( .save {r0, r2, r3, \reg1, \reg2} )
90 ldmfd sp!, {r0, \reg1, \reg2}
95 ENTRY(__copy_to_user_std)
96 WEAK(arm_copy_to_user)
97 #ifdef CONFIG_CPU_SPECTRE
99 ldr r3, [r3, #TI_ADDR_LIMIT]
100 uaccess_mask_range_ptr r0, r2, r3, ip
103 #include "copy_template.S"
105 ENDPROC(arm_copy_to_user)
106 ENDPROC(__copy_to_user_std)
108 .pushsection .text.fixup,"ax"
111 ldmfd sp!, {r1, r2, r3}