Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 ARM Ltd. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ |
| 16 | |
| 17 | #include <linux/linkage.h> |
James Morse | 338d4f4 | 2015-07-22 19:05:54 +0100 | [diff] [blame] | 18 | |
Feng Kan | 4042688 | 2015-09-23 11:55:39 -0700 | [diff] [blame] | 19 | #include <asm/cache.h> |
Al Viro | b4b8664 | 2016-12-26 04:10:19 -0500 | [diff] [blame] | 20 | #include <asm/asm-uaccess.h> |
Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 21 | |
| 22 | /* |
| 23 | * Copy to user space from a kernel buffer (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 | */ |
Feng Kan | 4042688 | 2015-09-23 11:55:39 -0700 | [diff] [blame] | 32 | .macro ldrb1 ptr, regB, val |
| 33 | ldrb \ptr, [\regB], \val |
| 34 | .endm |
| 35 | |
| 36 | .macro strb1 ptr, regB, val |
James Morse | 57f4959 | 2016-02-05 14:58:48 +0000 | [diff] [blame] | 37 | uao_user_alternative 9998f, strb, sttrb, \ptr, \regB, \val |
Feng Kan | 4042688 | 2015-09-23 11:55:39 -0700 | [diff] [blame] | 38 | .endm |
| 39 | |
| 40 | .macro ldrh1 ptr, regB, val |
| 41 | ldrh \ptr, [\regB], \val |
| 42 | .endm |
| 43 | |
| 44 | .macro strh1 ptr, regB, val |
James Morse | 57f4959 | 2016-02-05 14:58:48 +0000 | [diff] [blame] | 45 | uao_user_alternative 9998f, strh, sttrh, \ptr, \regB, \val |
Feng Kan | 4042688 | 2015-09-23 11:55:39 -0700 | [diff] [blame] | 46 | .endm |
| 47 | |
| 48 | .macro ldr1 ptr, regB, val |
| 49 | ldr \ptr, [\regB], \val |
| 50 | .endm |
| 51 | |
| 52 | .macro str1 ptr, regB, val |
James Morse | 57f4959 | 2016-02-05 14:58:48 +0000 | [diff] [blame] | 53 | uao_user_alternative 9998f, str, sttr, \ptr, \regB, \val |
Feng Kan | 4042688 | 2015-09-23 11:55:39 -0700 | [diff] [blame] | 54 | .endm |
| 55 | |
| 56 | .macro ldp1 ptr, regB, regC, val |
| 57 | ldp \ptr, \regB, [\regC], \val |
| 58 | .endm |
| 59 | |
| 60 | .macro stp1 ptr, regB, regC, val |
James Morse | 57f4959 | 2016-02-05 14:58:48 +0000 | [diff] [blame] | 61 | uao_stp 9998f, \ptr, \regB, \regC, \val |
Feng Kan | 4042688 | 2015-09-23 11:55:39 -0700 | [diff] [blame] | 62 | .endm |
| 63 | |
| 64 | end .req x5 |
Yang Shi | bffe1ba | 2016-06-08 14:40:56 -0700 | [diff] [blame] | 65 | ENTRY(__arch_copy_to_user) |
Will Deacon | 27a921e | 2017-08-10 13:58:16 +0100 | [diff] [blame] | 66 | uaccess_enable_not_uao x3, x4, x5 |
Feng Kan | 4042688 | 2015-09-23 11:55:39 -0700 | [diff] [blame] | 67 | add end, x0, x2 |
| 68 | #include "copy_template.S" |
Catalin Marinas | 6b88a32 | 2018-01-10 13:18:30 +0000 | [diff] [blame] | 69 | uaccess_disable_not_uao x3, x4 |
Feng Kan | 4042688 | 2015-09-23 11:55:39 -0700 | [diff] [blame] | 70 | mov x0, #0 |
Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 71 | ret |
Yang Shi | bffe1ba | 2016-06-08 14:40:56 -0700 | [diff] [blame] | 72 | ENDPROC(__arch_copy_to_user) |
Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 73 | |
| 74 | .section .fixup,"ax" |
| 75 | .align 2 |
Feng Kan | 4042688 | 2015-09-23 11:55:39 -0700 | [diff] [blame] | 76 | 9998: sub x0, end, dst // bytes not copied |
Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame] | 77 | ret |
| 78 | .previous |