blob: 7a4b060490012dd29f8a6d9fb8e24dfa58896bd1 [file] [log] [blame]
Nicolas Pitrefadab092005-11-01 19:52:24 +00001/*
2 * linux/arch/arm/lib/copy_from_user.S
3 *
4 * Author: Nicolas Pitre
5 * Created: Sep 29, 2005
6 * Copyright: MontaVista Software, Inc.
7 *
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.
11 */
12
13#include <linux/linkage.h>
14#include <asm/assembler.h>
Lin Yongting279f4872014-11-26 14:38:33 +010015#include <asm/unwind.h>
Nicolas Pitrefadab092005-11-01 19:52:24 +000016
17/*
18 * Prototype:
19 *
Russell King3fba7e22015-08-19 11:02:28 +010020 * size_t arm_copy_from_user(void *to, const void *from, size_t n)
Nicolas Pitrefadab092005-11-01 19:52:24 +000021 *
22 * Purpose:
23 *
24 * copy a block to kernel memory from user memory
25 *
26 * Params:
27 *
28 * to = kernel memory
29 * from = user memory
30 * n = number of bytes to copy
31 *
32 * Return value:
33 *
34 * Number of bytes NOT copied.
35 */
36
Catalin Marinas8b592782009-07-24 12:32:57 +010037#ifndef CONFIG_THUMB2_KERNEL
38#define LDR1W_SHIFT 0
39#else
40#define LDR1W_SHIFT 1
41#endif
42#define STR1W_SHIFT 0
43
Nicolas Pitrefadab092005-11-01 19:52:24 +000044 .macro ldr1w ptr reg abort
Catalin Marinas8b592782009-07-24 12:32:57 +010045 ldrusr \reg, \ptr, 4, abort=\abort
Nicolas Pitrefadab092005-11-01 19:52:24 +000046 .endm
47
48 .macro ldr4w ptr reg1 reg2 reg3 reg4 abort
49 ldr1w \ptr, \reg1, \abort
50 ldr1w \ptr, \reg2, \abort
51 ldr1w \ptr, \reg3, \abort
52 ldr1w \ptr, \reg4, \abort
53 .endm
54
55 .macro ldr8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
56 ldr4w \ptr, \reg1, \reg2, \reg3, \reg4, \abort
57 ldr4w \ptr, \reg5, \reg6, \reg7, \reg8, \abort
58 .endm
59
60 .macro ldr1b ptr reg cond=al abort
Catalin Marinas8b592782009-07-24 12:32:57 +010061 ldrusr \reg, \ptr, 1, \cond, abort=\abort
Nicolas Pitrefadab092005-11-01 19:52:24 +000062 .endm
63
64 .macro str1w ptr reg abort
Catalin Marinas8b592782009-07-24 12:32:57 +010065 W(str) \reg, [\ptr], #4
Nicolas Pitrefadab092005-11-01 19:52:24 +000066 .endm
67
68 .macro str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
69 stmia \ptr!, {\reg1, \reg2, \reg3, \reg4, \reg5, \reg6, \reg7, \reg8}
70 .endm
71
72 .macro str1b ptr reg cond=al abort
73 str\cond\()b \reg, [\ptr], #1
74 .endm
75
76 .macro enter reg1 reg2
77 mov r3, #0
78 stmdb sp!, {r0, r2, r3, \reg1, \reg2}
79 .endm
80
Lin Yongting279f4872014-11-26 14:38:33 +010081 .macro usave reg1 reg2
82 UNWIND( .save {r0, r2, r3, \reg1, \reg2} )
83 .endm
84
Nicolas Pitrefadab092005-11-01 19:52:24 +000085 .macro exit reg1 reg2
86 add sp, sp, #8
87 ldmfd sp!, {r0, \reg1, \reg2}
88 .endm
89
90 .text
91
Russell King3fba7e22015-08-19 11:02:28 +010092ENTRY(arm_copy_from_user)
Nicolas Pitrefadab092005-11-01 19:52:24 +000093
94#include "copy_template.S"
95
Russell King3fba7e22015-08-19 11:02:28 +010096ENDPROC(arm_copy_from_user)
Catalin Marinas93ed3972008-08-28 11:22:32 +010097
Russell King42604152010-04-19 10:15:03 +010098 .pushsection .fixup,"ax"
Nicolas Pitrefadab092005-11-01 19:52:24 +000099 .align 0
100 copy_abort_preamble
Al Viro91344492016-09-10 16:44:03 -0400101 ldmfd sp!, {r1, r2, r3}
102 sub r0, r0, r1
103 rsb r0, r0, r2
Nicolas Pitrefadab092005-11-01 19:52:24 +0000104 copy_abort_end
Russell King42604152010-04-19 10:15:03 +0100105 .popsection
Nicolas Pitrefadab092005-11-01 19:52:24 +0000106