Catalin Marinas | 0aea86a | 2012-03-05 11:49:32 +0000 | [diff] [blame^] | 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 | */ |
| 32 | ENTRY(__copy_in_user) |
| 33 | add x4, x0, x2 // upper user buffer boundary |
| 34 | subs x2, x2, #8 |
| 35 | b.mi 2f |
| 36 | 1: |
| 37 | USER(9f, ldr x3, [x1], #8 ) |
| 38 | subs x2, x2, #8 |
| 39 | USER(9f, str x3, [x0], #8 ) |
| 40 | b.pl 1b |
| 41 | 2: adds x2, x2, #4 |
| 42 | b.mi 3f |
| 43 | USER(9f, ldr w3, [x1], #4 ) |
| 44 | sub x2, x2, #4 |
| 45 | USER(9f, str w3, [x0], #4 ) |
| 46 | 3: adds x2, x2, #2 |
| 47 | b.mi 4f |
| 48 | USER(9f, ldrh w3, [x1], #2 ) |
| 49 | sub x2, x2, #2 |
| 50 | USER(9f, strh w3, [x0], #2 ) |
| 51 | 4: adds x2, x2, #1 |
| 52 | b.mi 5f |
| 53 | USER(9f, ldrb w3, [x1] ) |
| 54 | USER(9f, strb w3, [x0] ) |
| 55 | 5: mov x0, #0 |
| 56 | ret |
| 57 | ENDPROC(__copy_in_user) |
| 58 | |
| 59 | .section .fixup,"ax" |
| 60 | .align 2 |
| 61 | 9: sub x0, x4, x0 // bytes not copied |
| 62 | ret |
| 63 | .previous |