• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copy from user space to user space
3 *
4 * Copyright (C) 2012 ARM Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <linux/linkage.h>
20#include <asm/assembler.h>
21
22/*
23 * Copy from user space to user space (alignment handled by the hardware)
24 *
25 * Parameters:
26 *	x0 - to
27 *	x1 - from
28 *	x2 - n
29 * Returns:
30 *	x0 - bytes not copied
31 */
32ENTRY(__copy_in_user)
33	add	x4, x0, x2			// upper user buffer boundary
34	subs	x2, x2, #8
35	b.mi	2f
361:
37USER(9f, ldr	x3, [x1], #8	)
38	subs	x2, x2, #8
39USER(9f, str	x3, [x0], #8	)
40	b.pl	1b
412:	adds	x2, x2, #4
42	b.mi	3f
43USER(9f, ldr	w3, [x1], #4	)
44	sub	x2, x2, #4
45USER(9f, str	w3, [x0], #4	)
463:	adds	x2, x2, #2
47	b.mi	4f
48USER(9f, ldrh	w3, [x1], #2	)
49	sub	x2, x2, #2
50USER(9f, strh	w3, [x0], #2	)
514:	adds	x2, x2, #1
52	b.mi	5f
53USER(9f, ldrb	w3, [x1]	)
54USER(9f, strb	w3, [x0]	)
555:	mov	x0, #0
56	ret
57ENDPROC(__copy_in_user)
58
59	.section .fixup,"ax"
60	.align	2
619:	sub	x0, x4, x0			// bytes not copied
62	ret
63	.previous
64