blob: 800779eb3079dfafea890f272f64492e801c8986 [file] [log] [blame]
Catalin Marinas0aea86a2012-03-05 11:49:32 +00001/*
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>
James Morse338d4f42015-07-22 19:05:54 +010020
Feng Kan40426882015-09-23 11:55:39 -070021#include <asm/cache.h>
Catalin Marinas2962f1d2016-07-01 14:58:21 +010022#include <asm/uaccess.h>
Catalin Marinas0aea86a2012-03-05 11:49:32 +000023
24/*
25 * Copy from user space to user space (alignment handled by the hardware)
26 *
27 * Parameters:
28 * x0 - to
29 * x1 - from
30 * x2 - n
31 * Returns:
32 * x0 - bytes not copied
33 */
Feng Kan40426882015-09-23 11:55:39 -070034 .macro ldrb1 ptr, regB, val
James Morse57f49592016-02-05 14:58:48 +000035 uao_user_alternative 9998f, ldrb, ldtrb, \ptr, \regB, \val
Feng Kan40426882015-09-23 11:55:39 -070036 .endm
37
38 .macro strb1 ptr, regB, val
James Morse57f49592016-02-05 14:58:48 +000039 uao_user_alternative 9998f, strb, sttrb, \ptr, \regB, \val
Feng Kan40426882015-09-23 11:55:39 -070040 .endm
41
42 .macro ldrh1 ptr, regB, val
James Morse57f49592016-02-05 14:58:48 +000043 uao_user_alternative 9998f, ldrh, ldtrh, \ptr, \regB, \val
Feng Kan40426882015-09-23 11:55:39 -070044 .endm
45
46 .macro strh1 ptr, regB, val
James Morse57f49592016-02-05 14:58:48 +000047 uao_user_alternative 9998f, strh, sttrh, \ptr, \regB, \val
Feng Kan40426882015-09-23 11:55:39 -070048 .endm
49
50 .macro ldr1 ptr, regB, val
James Morse57f49592016-02-05 14:58:48 +000051 uao_user_alternative 9998f, ldr, ldtr, \ptr, \regB, \val
Feng Kan40426882015-09-23 11:55:39 -070052 .endm
53
54 .macro str1 ptr, regB, val
James Morse57f49592016-02-05 14:58:48 +000055 uao_user_alternative 9998f, str, sttr, \ptr, \regB, \val
Feng Kan40426882015-09-23 11:55:39 -070056 .endm
57
58 .macro ldp1 ptr, regB, regC, val
James Morse57f49592016-02-05 14:58:48 +000059 uao_ldp 9998f, \ptr, \regB, \regC, \val
Feng Kan40426882015-09-23 11:55:39 -070060 .endm
61
62 .macro stp1 ptr, regB, regC, val
James Morse57f49592016-02-05 14:58:48 +000063 uao_stp 9998f, \ptr, \regB, \regC, \val
Feng Kan40426882015-09-23 11:55:39 -070064 .endm
65
66end .req x5
Mark Rutland4504c5c2018-04-12 12:11:05 +010067ENTRY(__arch_copy_in_user)
Will Deacon599c71f2017-08-10 13:58:16 +010068 uaccess_enable_not_uao x3, x4, x5
Feng Kan40426882015-09-23 11:55:39 -070069 add end, x0, x2
70#include "copy_template.S"
Catalin Marinas87883132018-01-10 13:18:30 +000071 uaccess_disable_not_uao x3, x4
Feng Kan40426882015-09-23 11:55:39 -070072 mov x0, #0
Catalin Marinas0aea86a2012-03-05 11:49:32 +000073 ret
Mark Rutland4504c5c2018-04-12 12:11:05 +010074ENDPROC(__arch_copy_in_user)
Catalin Marinas0aea86a2012-03-05 11:49:32 +000075
76 .section .fixup,"ax"
77 .align 2
Feng Kan40426882015-09-23 11:55:39 -0700789998: sub x0, end, dst // bytes not copied
Catalin Marinas0aea86a2012-03-05 11:49:32 +000079 ret
80 .previous