Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/lib/copy_to_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 Yongting | 279f487 | 2014-11-26 14:38:33 +0100 | [diff] [blame] | 15 | #include <asm/unwind.h> |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 16 | |
| 17 | /* |
| 18 | * Prototype: |
| 19 | * |
Russell King | 02fcb97 | 2006-06-21 14:44:52 +0100 | [diff] [blame] | 20 | * size_t __copy_to_user(void *to, const void *from, size_t n) |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 21 | * |
| 22 | * Purpose: |
| 23 | * |
| 24 | * copy a block to user memory from kernel memory |
| 25 | * |
| 26 | * Params: |
| 27 | * |
| 28 | * to = user memory |
| 29 | * from = kernel memory |
| 30 | * n = number of bytes to copy |
| 31 | * |
| 32 | * Return value: |
| 33 | * |
| 34 | * Number of bytes NOT copied. |
| 35 | */ |
| 36 | |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 37 | #define LDR1W_SHIFT 0 |
| 38 | #ifndef CONFIG_THUMB2_KERNEL |
| 39 | #define STR1W_SHIFT 0 |
| 40 | #else |
| 41 | #define STR1W_SHIFT 1 |
| 42 | #endif |
| 43 | |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 44 | .macro ldr1w ptr reg abort |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 45 | W(ldr) \reg, [\ptr], #4 |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 46 | .endm |
| 47 | |
| 48 | .macro ldr4w ptr reg1 reg2 reg3 reg4 abort |
| 49 | ldmia \ptr!, {\reg1, \reg2, \reg3, \reg4} |
| 50 | .endm |
| 51 | |
| 52 | .macro ldr8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort |
| 53 | ldmia \ptr!, {\reg1, \reg2, \reg3, \reg4, \reg5, \reg6, \reg7, \reg8} |
| 54 | .endm |
| 55 | |
| 56 | .macro ldr1b ptr reg cond=al abort |
| 57 | ldr\cond\()b \reg, [\ptr], #1 |
| 58 | .endm |
| 59 | |
| 60 | .macro str1w ptr reg abort |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 61 | strusr \reg, \ptr, 4, abort=\abort |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 62 | .endm |
| 63 | |
| 64 | .macro str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort |
| 65 | str1w \ptr, \reg1, \abort |
| 66 | str1w \ptr, \reg2, \abort |
| 67 | str1w \ptr, \reg3, \abort |
| 68 | str1w \ptr, \reg4, \abort |
| 69 | str1w \ptr, \reg5, \abort |
| 70 | str1w \ptr, \reg6, \abort |
| 71 | str1w \ptr, \reg7, \abort |
| 72 | str1w \ptr, \reg8, \abort |
| 73 | .endm |
| 74 | |
| 75 | .macro str1b ptr reg cond=al abort |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 76 | strusr \reg, \ptr, 1, \cond, abort=\abort |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 77 | .endm |
| 78 | |
| 79 | .macro enter reg1 reg2 |
| 80 | mov r3, #0 |
| 81 | stmdb sp!, {r0, r2, r3, \reg1, \reg2} |
| 82 | .endm |
| 83 | |
Lin Yongting | 279f487 | 2014-11-26 14:38:33 +0100 | [diff] [blame] | 84 | .macro usave reg1 reg2 |
| 85 | UNWIND( .save {r0, r2, r3, \reg1, \reg2} ) |
| 86 | .endm |
| 87 | |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 88 | .macro exit reg1 reg2 |
| 89 | add sp, sp, #8 |
| 90 | ldmfd sp!, {r0, \reg1, \reg2} |
| 91 | .endm |
| 92 | |
| 93 | .text |
| 94 | |
Nicolas Pitre | a1f9884 | 2009-03-08 22:34:45 -0400 | [diff] [blame] | 95 | ENTRY(__copy_to_user_std) |
| 96 | WEAK(__copy_to_user) |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 97 | |
| 98 | #include "copy_template.S" |
| 99 | |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 100 | ENDPROC(__copy_to_user) |
Catalin Marinas | e814d82 | 2010-05-07 10:52:32 +0100 | [diff] [blame] | 101 | ENDPROC(__copy_to_user_std) |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 102 | |
Ard Biesheuvel | c4a84ae | 2015-03-24 10:41:09 +0100 | [diff] [blame] | 103 | .pushsection .text.fixup,"ax" |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 104 | .align 0 |
| 105 | copy_abort_preamble |
| 106 | ldmfd sp!, {r1, r2, r3} |
| 107 | sub r0, r0, r1 |
| 108 | rsb r0, r0, r2 |
| 109 | copy_abort_end |
Russell King | 4260415 | 2010-04-19 10:15:03 +0100 | [diff] [blame] | 110 | .popsection |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 111 | |