Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/lib/uaccess.S |
| 3 | * |
| 4 | * Copyright (C) 1995, 1996,1997,1998 Russell King |
| 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 | * Routines to block copy data to/from user memory |
| 11 | * These are highly optimised both for the 4k page size |
| 12 | * and for various alignments. |
| 13 | */ |
| 14 | #include <linux/linkage.h> |
| 15 | #include <asm/assembler.h> |
| 16 | #include <asm/errno.h> |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 17 | #include <asm/domain.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
| 19 | .text |
| 20 | |
| 21 | #define PAGE_SHIFT 12 |
| 22 | |
Russell King | 02fcb97 | 2006-06-21 14:44:52 +0100 | [diff] [blame] | 23 | /* Prototype: int __copy_to_user(void *to, const char *from, size_t n) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | * Purpose : copy a block to user memory from kernel memory |
| 25 | * Params : to - user memory |
| 26 | * : from - kernel memory |
| 27 | * : n - number of bytes to copy |
| 28 | * Returns : Number of bytes NOT copied. |
| 29 | */ |
| 30 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 31 | .Lc2u_dest_not_aligned: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | rsb ip, ip, #4 |
| 33 | cmp ip, #2 |
| 34 | ldrb r3, [r1], #1 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 35 | USER( T(strb) r3, [r0], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | ldrgeb r3, [r1], #1 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 37 | USER( T(strgeb) r3, [r0], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | ldrgtb r3, [r1], #1 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 39 | USER( T(strgtb) r3, [r0], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | sub r2, r2, ip |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 41 | b .Lc2u_dest_aligned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
Russell King | 02fcb97 | 2006-06-21 14:44:52 +0100 | [diff] [blame] | 43 | ENTRY(__copy_to_user) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | stmfd sp!, {r2, r4 - r7, lr} |
| 45 | cmp r2, #4 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 46 | blt .Lc2u_not_enough |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | ands ip, r0, #3 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 48 | bne .Lc2u_dest_not_aligned |
| 49 | .Lc2u_dest_aligned: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
| 51 | ands ip, r1, #3 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 52 | bne .Lc2u_src_not_aligned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | /* |
| 54 | * Seeing as there has to be at least 8 bytes to copy, we can |
| 55 | * copy one word, and force a user-mode page fault... |
| 56 | */ |
| 57 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 58 | .Lc2u_0fupi: subs r2, r2, #4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | addmi ip, r2, #4 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 60 | bmi .Lc2u_0nowords |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | ldr r3, [r1], #4 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 62 | USER( T(str) r3, [r0], #4) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | mov ip, r0, lsl #32 - PAGE_SHIFT @ On each page, use a ld/st??t instruction |
| 64 | rsb ip, ip, #0 |
| 65 | movs ip, ip, lsr #32 - PAGE_SHIFT |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 66 | beq .Lc2u_0fupi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | /* |
| 68 | * ip = max no. of bytes to copy before needing another "strt" insn |
| 69 | */ |
| 70 | cmp r2, ip |
| 71 | movlt ip, r2 |
| 72 | sub r2, r2, ip |
| 73 | subs ip, ip, #32 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 74 | blt .Lc2u_0rem8lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 76 | .Lc2u_0cpy8lp: ldmia r1!, {r3 - r6} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | stmia r0!, {r3 - r6} @ Shouldnt fault |
| 78 | ldmia r1!, {r3 - r6} |
| 79 | subs ip, ip, #32 |
| 80 | stmia r0!, {r3 - r6} @ Shouldnt fault |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 81 | bpl .Lc2u_0cpy8lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 83 | .Lc2u_0rem8lp: cmn ip, #16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | ldmgeia r1!, {r3 - r6} |
| 85 | stmgeia r0!, {r3 - r6} @ Shouldnt fault |
| 86 | tst ip, #8 |
| 87 | ldmneia r1!, {r3 - r4} |
| 88 | stmneia r0!, {r3 - r4} @ Shouldnt fault |
| 89 | tst ip, #4 |
| 90 | ldrne r3, [r1], #4 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 91 | T(strne) r3, [r0], #4 @ Shouldnt fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | ands ip, ip, #3 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 93 | beq .Lc2u_0fupi |
| 94 | .Lc2u_0nowords: teq ip, #0 |
| 95 | beq .Lc2u_finished |
| 96 | .Lc2u_nowords: cmp ip, #2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | ldrb r3, [r1], #1 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 98 | USER( T(strb) r3, [r0], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | ldrgeb r3, [r1], #1 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 100 | USER( T(strgeb) r3, [r0], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | ldrgtb r3, [r1], #1 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 102 | USER( T(strgtb) r3, [r0], #1) @ May fault |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 103 | b .Lc2u_finished |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 105 | .Lc2u_not_enough: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | movs ip, r2 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 107 | bne .Lc2u_nowords |
| 108 | .Lc2u_finished: mov r0, #0 |
Russell King | 1b93a71 | 2006-06-25 11:23:45 +0100 | [diff] [blame] | 109 | ldmfd sp!, {r2, r4 - r7, pc} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 111 | .Lc2u_src_not_aligned: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | bic r1, r1, #3 |
| 113 | ldr r7, [r1], #4 |
| 114 | cmp ip, #2 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 115 | bgt .Lc2u_3fupi |
| 116 | beq .Lc2u_2fupi |
| 117 | .Lc2u_1fupi: subs r2, r2, #4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | addmi ip, r2, #4 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 119 | bmi .Lc2u_1nowords |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | mov r3, r7, pull #8 |
| 121 | ldr r7, [r1], #4 |
| 122 | orr r3, r3, r7, push #24 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 123 | USER( T(str) r3, [r0], #4) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | mov ip, r0, lsl #32 - PAGE_SHIFT |
| 125 | rsb ip, ip, #0 |
| 126 | movs ip, ip, lsr #32 - PAGE_SHIFT |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 127 | beq .Lc2u_1fupi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | cmp r2, ip |
| 129 | movlt ip, r2 |
| 130 | sub r2, r2, ip |
| 131 | subs ip, ip, #16 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 132 | blt .Lc2u_1rem8lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 134 | .Lc2u_1cpy8lp: mov r3, r7, pull #8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | ldmia r1!, {r4 - r7} |
| 136 | subs ip, ip, #16 |
| 137 | orr r3, r3, r4, push #24 |
| 138 | mov r4, r4, pull #8 |
| 139 | orr r4, r4, r5, push #24 |
| 140 | mov r5, r5, pull #8 |
| 141 | orr r5, r5, r6, push #24 |
| 142 | mov r6, r6, pull #8 |
| 143 | orr r6, r6, r7, push #24 |
| 144 | stmia r0!, {r3 - r6} @ Shouldnt fault |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 145 | bpl .Lc2u_1cpy8lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 147 | .Lc2u_1rem8lp: tst ip, #8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | movne r3, r7, pull #8 |
| 149 | ldmneia r1!, {r4, r7} |
| 150 | orrne r3, r3, r4, push #24 |
| 151 | movne r4, r4, pull #8 |
| 152 | orrne r4, r4, r7, push #24 |
| 153 | stmneia r0!, {r3 - r4} @ Shouldnt fault |
| 154 | tst ip, #4 |
| 155 | movne r3, r7, pull #8 |
| 156 | ldrne r7, [r1], #4 |
| 157 | orrne r3, r3, r7, push #24 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 158 | T(strne) r3, [r0], #4 @ Shouldnt fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | ands ip, ip, #3 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 160 | beq .Lc2u_1fupi |
| 161 | .Lc2u_1nowords: mov r3, r7, get_byte_1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | teq ip, #0 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 163 | beq .Lc2u_finished |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | cmp ip, #2 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 165 | USER( T(strb) r3, [r0], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | movge r3, r7, get_byte_2 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 167 | USER( T(strgeb) r3, [r0], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | movgt r3, r7, get_byte_3 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 169 | USER( T(strgtb) r3, [r0], #1) @ May fault |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 170 | b .Lc2u_finished |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 172 | .Lc2u_2fupi: subs r2, r2, #4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | addmi ip, r2, #4 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 174 | bmi .Lc2u_2nowords |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | mov r3, r7, pull #16 |
| 176 | ldr r7, [r1], #4 |
| 177 | orr r3, r3, r7, push #16 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 178 | USER( T(str) r3, [r0], #4) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | mov ip, r0, lsl #32 - PAGE_SHIFT |
| 180 | rsb ip, ip, #0 |
| 181 | movs ip, ip, lsr #32 - PAGE_SHIFT |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 182 | beq .Lc2u_2fupi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | cmp r2, ip |
| 184 | movlt ip, r2 |
| 185 | sub r2, r2, ip |
| 186 | subs ip, ip, #16 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 187 | blt .Lc2u_2rem8lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 189 | .Lc2u_2cpy8lp: mov r3, r7, pull #16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | ldmia r1!, {r4 - r7} |
| 191 | subs ip, ip, #16 |
| 192 | orr r3, r3, r4, push #16 |
| 193 | mov r4, r4, pull #16 |
| 194 | orr r4, r4, r5, push #16 |
| 195 | mov r5, r5, pull #16 |
| 196 | orr r5, r5, r6, push #16 |
| 197 | mov r6, r6, pull #16 |
| 198 | orr r6, r6, r7, push #16 |
| 199 | stmia r0!, {r3 - r6} @ Shouldnt fault |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 200 | bpl .Lc2u_2cpy8lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 202 | .Lc2u_2rem8lp: tst ip, #8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | movne r3, r7, pull #16 |
| 204 | ldmneia r1!, {r4, r7} |
| 205 | orrne r3, r3, r4, push #16 |
| 206 | movne r4, r4, pull #16 |
| 207 | orrne r4, r4, r7, push #16 |
| 208 | stmneia r0!, {r3 - r4} @ Shouldnt fault |
| 209 | tst ip, #4 |
| 210 | movne r3, r7, pull #16 |
| 211 | ldrne r7, [r1], #4 |
| 212 | orrne r3, r3, r7, push #16 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 213 | T(strne) r3, [r0], #4 @ Shouldnt fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | ands ip, ip, #3 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 215 | beq .Lc2u_2fupi |
| 216 | .Lc2u_2nowords: mov r3, r7, get_byte_2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | teq ip, #0 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 218 | beq .Lc2u_finished |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | cmp ip, #2 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 220 | USER( T(strb) r3, [r0], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | movge r3, r7, get_byte_3 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 222 | USER( T(strgeb) r3, [r0], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | ldrgtb r3, [r1], #0 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 224 | USER( T(strgtb) r3, [r0], #1) @ May fault |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 225 | b .Lc2u_finished |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 227 | .Lc2u_3fupi: subs r2, r2, #4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | addmi ip, r2, #4 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 229 | bmi .Lc2u_3nowords |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | mov r3, r7, pull #24 |
| 231 | ldr r7, [r1], #4 |
| 232 | orr r3, r3, r7, push #8 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 233 | USER( T(str) r3, [r0], #4) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | mov ip, r0, lsl #32 - PAGE_SHIFT |
| 235 | rsb ip, ip, #0 |
| 236 | movs ip, ip, lsr #32 - PAGE_SHIFT |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 237 | beq .Lc2u_3fupi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | cmp r2, ip |
| 239 | movlt ip, r2 |
| 240 | sub r2, r2, ip |
| 241 | subs ip, ip, #16 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 242 | blt .Lc2u_3rem8lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 244 | .Lc2u_3cpy8lp: mov r3, r7, pull #24 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | ldmia r1!, {r4 - r7} |
| 246 | subs ip, ip, #16 |
| 247 | orr r3, r3, r4, push #8 |
| 248 | mov r4, r4, pull #24 |
| 249 | orr r4, r4, r5, push #8 |
| 250 | mov r5, r5, pull #24 |
| 251 | orr r5, r5, r6, push #8 |
| 252 | mov r6, r6, pull #24 |
| 253 | orr r6, r6, r7, push #8 |
| 254 | stmia r0!, {r3 - r6} @ Shouldnt fault |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 255 | bpl .Lc2u_3cpy8lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 257 | .Lc2u_3rem8lp: tst ip, #8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | movne r3, r7, pull #24 |
| 259 | ldmneia r1!, {r4, r7} |
| 260 | orrne r3, r3, r4, push #8 |
| 261 | movne r4, r4, pull #24 |
| 262 | orrne r4, r4, r7, push #8 |
| 263 | stmneia r0!, {r3 - r4} @ Shouldnt fault |
| 264 | tst ip, #4 |
| 265 | movne r3, r7, pull #24 |
| 266 | ldrne r7, [r1], #4 |
| 267 | orrne r3, r3, r7, push #8 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 268 | T(strne) r3, [r0], #4 @ Shouldnt fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | ands ip, ip, #3 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 270 | beq .Lc2u_3fupi |
| 271 | .Lc2u_3nowords: mov r3, r7, get_byte_3 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | teq ip, #0 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 273 | beq .Lc2u_finished |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | cmp ip, #2 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 275 | USER( T(strb) r3, [r0], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | ldrgeb r3, [r1], #1 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 277 | USER( T(strgeb) r3, [r0], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | ldrgtb r3, [r1], #0 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 279 | USER( T(strgtb) r3, [r0], #1) @ May fault |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 280 | b .Lc2u_finished |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 281 | ENDPROC(__copy_to_user) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | |
Russell King | 4260415 | 2010-04-19 10:15:03 +0100 | [diff] [blame] | 283 | .pushsection .fixup,"ax" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | .align 0 |
Russell King | 1b93a71 | 2006-06-25 11:23:45 +0100 | [diff] [blame] | 285 | 9001: ldmfd sp!, {r0, r4 - r7, pc} |
Russell King | 4260415 | 2010-04-19 10:15:03 +0100 | [diff] [blame] | 286 | .popsection |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | |
Russell King | 02fcb97 | 2006-06-21 14:44:52 +0100 | [diff] [blame] | 288 | /* Prototype: unsigned long __copy_from_user(void *to,const void *from,unsigned long n); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | * Purpose : copy a block from user memory to kernel memory |
| 290 | * Params : to - kernel memory |
| 291 | * : from - user memory |
| 292 | * : n - number of bytes to copy |
| 293 | * Returns : Number of bytes NOT copied. |
| 294 | */ |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 295 | .Lcfu_dest_not_aligned: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | rsb ip, ip, #4 |
| 297 | cmp ip, #2 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 298 | USER( T(ldrb) r3, [r1], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | strb r3, [r0], #1 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 300 | USER( T(ldrgeb) r3, [r1], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | strgeb r3, [r0], #1 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 302 | USER( T(ldrgtb) r3, [r1], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | strgtb r3, [r0], #1 |
| 304 | sub r2, r2, ip |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 305 | b .Lcfu_dest_aligned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | |
Russell King | 02fcb97 | 2006-06-21 14:44:52 +0100 | [diff] [blame] | 307 | ENTRY(__copy_from_user) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | stmfd sp!, {r0, r2, r4 - r7, lr} |
| 309 | cmp r2, #4 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 310 | blt .Lcfu_not_enough |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | ands ip, r0, #3 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 312 | bne .Lcfu_dest_not_aligned |
| 313 | .Lcfu_dest_aligned: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | ands ip, r1, #3 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 315 | bne .Lcfu_src_not_aligned |
| 316 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | /* |
| 318 | * Seeing as there has to be at least 8 bytes to copy, we can |
| 319 | * copy one word, and force a user-mode page fault... |
| 320 | */ |
| 321 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 322 | .Lcfu_0fupi: subs r2, r2, #4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | addmi ip, r2, #4 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 324 | bmi .Lcfu_0nowords |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 325 | USER( T(ldr) r3, [r1], #4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | str r3, [r0], #4 |
| 327 | mov ip, r1, lsl #32 - PAGE_SHIFT @ On each page, use a ld/st??t instruction |
| 328 | rsb ip, ip, #0 |
| 329 | movs ip, ip, lsr #32 - PAGE_SHIFT |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 330 | beq .Lcfu_0fupi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | /* |
| 332 | * ip = max no. of bytes to copy before needing another "strt" insn |
| 333 | */ |
| 334 | cmp r2, ip |
| 335 | movlt ip, r2 |
| 336 | sub r2, r2, ip |
| 337 | subs ip, ip, #32 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 338 | blt .Lcfu_0rem8lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 340 | .Lcfu_0cpy8lp: ldmia r1!, {r3 - r6} @ Shouldnt fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | stmia r0!, {r3 - r6} |
| 342 | ldmia r1!, {r3 - r6} @ Shouldnt fault |
| 343 | subs ip, ip, #32 |
| 344 | stmia r0!, {r3 - r6} |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 345 | bpl .Lcfu_0cpy8lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 347 | .Lcfu_0rem8lp: cmn ip, #16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | ldmgeia r1!, {r3 - r6} @ Shouldnt fault |
| 349 | stmgeia r0!, {r3 - r6} |
| 350 | tst ip, #8 |
| 351 | ldmneia r1!, {r3 - r4} @ Shouldnt fault |
| 352 | stmneia r0!, {r3 - r4} |
| 353 | tst ip, #4 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 354 | T(ldrne) r3, [r1], #4 @ Shouldnt fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | strne r3, [r0], #4 |
| 356 | ands ip, ip, #3 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 357 | beq .Lcfu_0fupi |
| 358 | .Lcfu_0nowords: teq ip, #0 |
| 359 | beq .Lcfu_finished |
| 360 | .Lcfu_nowords: cmp ip, #2 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 361 | USER( T(ldrb) r3, [r1], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | strb r3, [r0], #1 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 363 | USER( T(ldrgeb) r3, [r1], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | strgeb r3, [r0], #1 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 365 | USER( T(ldrgtb) r3, [r1], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | strgtb r3, [r0], #1 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 367 | b .Lcfu_finished |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 369 | .Lcfu_not_enough: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | movs ip, r2 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 371 | bne .Lcfu_nowords |
| 372 | .Lcfu_finished: mov r0, #0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | add sp, sp, #8 |
Russell King | 1b93a71 | 2006-06-25 11:23:45 +0100 | [diff] [blame] | 374 | ldmfd sp!, {r4 - r7, pc} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 376 | .Lcfu_src_not_aligned: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | bic r1, r1, #3 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 378 | USER( T(ldr) r7, [r1], #4) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | cmp ip, #2 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 380 | bgt .Lcfu_3fupi |
| 381 | beq .Lcfu_2fupi |
| 382 | .Lcfu_1fupi: subs r2, r2, #4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | addmi ip, r2, #4 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 384 | bmi .Lcfu_1nowords |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | mov r3, r7, pull #8 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 386 | USER( T(ldr) r7, [r1], #4) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | orr r3, r3, r7, push #24 |
| 388 | str r3, [r0], #4 |
| 389 | mov ip, r1, lsl #32 - PAGE_SHIFT |
| 390 | rsb ip, ip, #0 |
| 391 | movs ip, ip, lsr #32 - PAGE_SHIFT |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 392 | beq .Lcfu_1fupi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | cmp r2, ip |
| 394 | movlt ip, r2 |
| 395 | sub r2, r2, ip |
| 396 | subs ip, ip, #16 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 397 | blt .Lcfu_1rem8lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 399 | .Lcfu_1cpy8lp: mov r3, r7, pull #8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | ldmia r1!, {r4 - r7} @ Shouldnt fault |
| 401 | subs ip, ip, #16 |
| 402 | orr r3, r3, r4, push #24 |
| 403 | mov r4, r4, pull #8 |
| 404 | orr r4, r4, r5, push #24 |
| 405 | mov r5, r5, pull #8 |
| 406 | orr r5, r5, r6, push #24 |
| 407 | mov r6, r6, pull #8 |
| 408 | orr r6, r6, r7, push #24 |
| 409 | stmia r0!, {r3 - r6} |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 410 | bpl .Lcfu_1cpy8lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 412 | .Lcfu_1rem8lp: tst ip, #8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | movne r3, r7, pull #8 |
| 414 | ldmneia r1!, {r4, r7} @ Shouldnt fault |
| 415 | orrne r3, r3, r4, push #24 |
| 416 | movne r4, r4, pull #8 |
| 417 | orrne r4, r4, r7, push #24 |
| 418 | stmneia r0!, {r3 - r4} |
| 419 | tst ip, #4 |
| 420 | movne r3, r7, pull #8 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 421 | USER( T(ldrne) r7, [r1], #4) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | orrne r3, r3, r7, push #24 |
| 423 | strne r3, [r0], #4 |
| 424 | ands ip, ip, #3 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 425 | beq .Lcfu_1fupi |
| 426 | .Lcfu_1nowords: mov r3, r7, get_byte_1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | teq ip, #0 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 428 | beq .Lcfu_finished |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | cmp ip, #2 |
| 430 | strb r3, [r0], #1 |
| 431 | movge r3, r7, get_byte_2 |
| 432 | strgeb r3, [r0], #1 |
| 433 | movgt r3, r7, get_byte_3 |
| 434 | strgtb r3, [r0], #1 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 435 | b .Lcfu_finished |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 437 | .Lcfu_2fupi: subs r2, r2, #4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | addmi ip, r2, #4 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 439 | bmi .Lcfu_2nowords |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | mov r3, r7, pull #16 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 441 | USER( T(ldr) r7, [r1], #4) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | orr r3, r3, r7, push #16 |
| 443 | str r3, [r0], #4 |
| 444 | mov ip, r1, lsl #32 - PAGE_SHIFT |
| 445 | rsb ip, ip, #0 |
| 446 | movs ip, ip, lsr #32 - PAGE_SHIFT |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 447 | beq .Lcfu_2fupi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | cmp r2, ip |
| 449 | movlt ip, r2 |
| 450 | sub r2, r2, ip |
| 451 | subs ip, ip, #16 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 452 | blt .Lcfu_2rem8lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 454 | |
| 455 | .Lcfu_2cpy8lp: mov r3, r7, pull #16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | ldmia r1!, {r4 - r7} @ Shouldnt fault |
| 457 | subs ip, ip, #16 |
| 458 | orr r3, r3, r4, push #16 |
| 459 | mov r4, r4, pull #16 |
| 460 | orr r4, r4, r5, push #16 |
| 461 | mov r5, r5, pull #16 |
| 462 | orr r5, r5, r6, push #16 |
| 463 | mov r6, r6, pull #16 |
| 464 | orr r6, r6, r7, push #16 |
| 465 | stmia r0!, {r3 - r6} |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 466 | bpl .Lcfu_2cpy8lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 468 | .Lcfu_2rem8lp: tst ip, #8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | movne r3, r7, pull #16 |
| 470 | ldmneia r1!, {r4, r7} @ Shouldnt fault |
| 471 | orrne r3, r3, r4, push #16 |
| 472 | movne r4, r4, pull #16 |
| 473 | orrne r4, r4, r7, push #16 |
| 474 | stmneia r0!, {r3 - r4} |
| 475 | tst ip, #4 |
| 476 | movne r3, r7, pull #16 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 477 | USER( T(ldrne) r7, [r1], #4) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | orrne r3, r3, r7, push #16 |
| 479 | strne r3, [r0], #4 |
| 480 | ands ip, ip, #3 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 481 | beq .Lcfu_2fupi |
| 482 | .Lcfu_2nowords: mov r3, r7, get_byte_2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | teq ip, #0 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 484 | beq .Lcfu_finished |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | cmp ip, #2 |
| 486 | strb r3, [r0], #1 |
| 487 | movge r3, r7, get_byte_3 |
| 488 | strgeb r3, [r0], #1 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 489 | USER( T(ldrgtb) r3, [r1], #0) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | strgtb r3, [r0], #1 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 491 | b .Lcfu_finished |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 493 | .Lcfu_3fupi: subs r2, r2, #4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | addmi ip, r2, #4 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 495 | bmi .Lcfu_3nowords |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | mov r3, r7, pull #24 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 497 | USER( T(ldr) r7, [r1], #4) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | orr r3, r3, r7, push #8 |
| 499 | str r3, [r0], #4 |
| 500 | mov ip, r1, lsl #32 - PAGE_SHIFT |
| 501 | rsb ip, ip, #0 |
| 502 | movs ip, ip, lsr #32 - PAGE_SHIFT |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 503 | beq .Lcfu_3fupi |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | cmp r2, ip |
| 505 | movlt ip, r2 |
| 506 | sub r2, r2, ip |
| 507 | subs ip, ip, #16 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 508 | blt .Lcfu_3rem8lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 510 | .Lcfu_3cpy8lp: mov r3, r7, pull #24 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | ldmia r1!, {r4 - r7} @ Shouldnt fault |
| 512 | orr r3, r3, r4, push #8 |
| 513 | mov r4, r4, pull #24 |
| 514 | orr r4, r4, r5, push #8 |
| 515 | mov r5, r5, pull #24 |
| 516 | orr r5, r5, r6, push #8 |
| 517 | mov r6, r6, pull #24 |
| 518 | orr r6, r6, r7, push #8 |
| 519 | stmia r0!, {r3 - r6} |
| 520 | subs ip, ip, #16 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 521 | bpl .Lcfu_3cpy8lp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 523 | .Lcfu_3rem8lp: tst ip, #8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | movne r3, r7, pull #24 |
| 525 | ldmneia r1!, {r4, r7} @ Shouldnt fault |
| 526 | orrne r3, r3, r4, push #8 |
| 527 | movne r4, r4, pull #24 |
| 528 | orrne r4, r4, r7, push #8 |
| 529 | stmneia r0!, {r3 - r4} |
| 530 | tst ip, #4 |
| 531 | movne r3, r7, pull #24 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 532 | USER( T(ldrne) r7, [r1], #4) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | orrne r3, r3, r7, push #8 |
| 534 | strne r3, [r0], #4 |
| 535 | ands ip, ip, #3 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 536 | beq .Lcfu_3fupi |
| 537 | .Lcfu_3nowords: mov r3, r7, get_byte_3 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | teq ip, #0 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 539 | beq .Lcfu_finished |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | cmp ip, #2 |
| 541 | strb r3, [r0], #1 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 542 | USER( T(ldrgeb) r3, [r1], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | strgeb r3, [r0], #1 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 544 | USER( T(ldrgtb) r3, [r1], #1) @ May fault |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | strgtb r3, [r0], #1 |
Nicolas Pitre | 7ba11a9 | 2005-11-11 21:51:47 +0000 | [diff] [blame] | 546 | b .Lcfu_finished |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 547 | ENDPROC(__copy_from_user) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | |
Russell King | 4260415 | 2010-04-19 10:15:03 +0100 | [diff] [blame] | 549 | .pushsection .fixup,"ax" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | .align 0 |
| 551 | /* |
| 552 | * We took an exception. r0 contains a pointer to |
| 553 | * the byte not copied. |
| 554 | */ |
| 555 | 9001: ldr r2, [sp], #4 @ void *to |
| 556 | sub r2, r0, r2 @ bytes copied |
| 557 | ldr r1, [sp], #4 @ unsigned long count |
| 558 | subs r4, r1, r2 @ bytes left to copy |
| 559 | movne r1, r4 |
| 560 | blne __memzero |
| 561 | mov r0, r4 |
Russell King | 1b93a71 | 2006-06-25 11:23:45 +0100 | [diff] [blame] | 562 | ldmfd sp!, {r4 - r7, pc} |
Russell King | 4260415 | 2010-04-19 10:15:03 +0100 | [diff] [blame] | 563 | .popsection |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | |