uaccess.S 13.5 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 *  linux/arch/arm/lib/uaccess.S
 *
 *  Copyright (C) 1995, 1996,1997,1998 Russell King
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 *  Routines to block copy data to/from user memory
 *   These are highly optimised both for the 4k page size
 *   and for various alignments.
 */
#include <linux/linkage.h>
#include <asm/assembler.h>
#include <asm/errno.h>
17
#include <asm/domain.h>
L
Linus Torvalds 已提交
18 19 20 21 22

		.text

#define PAGE_SHIFT 12

23
/* Prototype: int __copy_to_user(void *to, const char *from, size_t n)
L
Linus Torvalds 已提交
24 25 26 27 28 29 30
 * Purpose  : copy a block to user memory from kernel memory
 * Params   : to   - user memory
 *          : from - kernel memory
 *          : n    - number of bytes to copy
 * Returns  : Number of bytes NOT copied.
 */

31
.Lc2u_dest_not_aligned:
L
Linus Torvalds 已提交
32 33 34
		rsb	ip, ip, #4
		cmp	ip, #2
		ldrb	r3, [r1], #1
35
USER(	TUSER(	strb)	r3, [r0], #1)			@ May fault
L
Linus Torvalds 已提交
36
		ldrgeb	r3, [r1], #1
37
USER(	TUSER(	strgeb) r3, [r0], #1)			@ May fault
L
Linus Torvalds 已提交
38
		ldrgtb	r3, [r1], #1
39
USER(	TUSER(	strgtb) r3, [r0], #1)			@ May fault
L
Linus Torvalds 已提交
40
		sub	r2, r2, ip
41
		b	.Lc2u_dest_aligned
L
Linus Torvalds 已提交
42

43
ENTRY(__copy_to_user)
L
Linus Torvalds 已提交
44 45
		stmfd	sp!, {r2, r4 - r7, lr}
		cmp	r2, #4
46
		blt	.Lc2u_not_enough
L
Linus Torvalds 已提交
47
		ands	ip, r0, #3
48 49
		bne	.Lc2u_dest_not_aligned
.Lc2u_dest_aligned:
L
Linus Torvalds 已提交
50 51

		ands	ip, r1, #3
52
		bne	.Lc2u_src_not_aligned
L
Linus Torvalds 已提交
53 54 55 56 57
/*
 * Seeing as there has to be at least 8 bytes to copy, we can
 * copy one word, and force a user-mode page fault...
 */

58
.Lc2u_0fupi:	subs	r2, r2, #4
L
Linus Torvalds 已提交
59
		addmi	ip, r2, #4
60
		bmi	.Lc2u_0nowords
L
Linus Torvalds 已提交
61
		ldr	r3, [r1], #4
62
USER(	TUSER(	str)	r3, [r0], #4)			@ May fault
L
Linus Torvalds 已提交
63 64 65
		mov	ip, r0, lsl #32 - PAGE_SHIFT	@ On each page, use a ld/st??t instruction
		rsb	ip, ip, #0
		movs	ip, ip, lsr #32 - PAGE_SHIFT
66
		beq	.Lc2u_0fupi
L
Linus Torvalds 已提交
67 68 69 70 71 72 73
/*
 * ip = max no. of bytes to copy before needing another "strt" insn
 */
		cmp	r2, ip
		movlt	ip, r2
		sub	r2, r2, ip
		subs	ip, ip, #32
74
		blt	.Lc2u_0rem8lp
75

76
.Lc2u_0cpy8lp:	ldmia	r1!, {r3 - r6}
L
Linus Torvalds 已提交
77 78 79 80
		stmia	r0!, {r3 - r6}			@ Shouldnt fault
		ldmia	r1!, {r3 - r6}
		subs	ip, ip, #32
		stmia	r0!, {r3 - r6}			@ Shouldnt fault
81
		bpl	.Lc2u_0cpy8lp
L
Linus Torvalds 已提交
82

83
.Lc2u_0rem8lp:	cmn	ip, #16
L
Linus Torvalds 已提交
84 85 86 87 88 89 90
		ldmgeia	r1!, {r3 - r6}
		stmgeia	r0!, {r3 - r6}			@ Shouldnt fault
		tst	ip, #8
		ldmneia	r1!, {r3 - r4}
		stmneia	r0!, {r3 - r4}			@ Shouldnt fault
		tst	ip, #4
		ldrne	r3, [r1], #4
91
	TUSER(	strne) r3, [r0], #4			@ Shouldnt fault
L
Linus Torvalds 已提交
92
		ands	ip, ip, #3
93 94 95 96
		beq	.Lc2u_0fupi
.Lc2u_0nowords:	teq	ip, #0
		beq	.Lc2u_finished
.Lc2u_nowords:	cmp	ip, #2
L
Linus Torvalds 已提交
97
		ldrb	r3, [r1], #1
98
USER(	TUSER(	strb)	r3, [r0], #1)			@ May fault
L
Linus Torvalds 已提交
99
		ldrgeb	r3, [r1], #1
100
USER(	TUSER(	strgeb) r3, [r0], #1)			@ May fault
L
Linus Torvalds 已提交
101
		ldrgtb	r3, [r1], #1
102
USER(	TUSER(	strgtb) r3, [r0], #1)			@ May fault
103
		b	.Lc2u_finished
L
Linus Torvalds 已提交
104

105
.Lc2u_not_enough:
L
Linus Torvalds 已提交
106
		movs	ip, r2
107 108
		bne	.Lc2u_nowords
.Lc2u_finished:	mov	r0, #0
R
Russell King 已提交
109
		ldmfd	sp!, {r2, r4 - r7, pc}
L
Linus Torvalds 已提交
110

111
.Lc2u_src_not_aligned:
L
Linus Torvalds 已提交
112 113 114
		bic	r1, r1, #3
		ldr	r7, [r1], #4
		cmp	ip, #2
115 116 117
		bgt	.Lc2u_3fupi
		beq	.Lc2u_2fupi
.Lc2u_1fupi:	subs	r2, r2, #4
L
Linus Torvalds 已提交
118
		addmi	ip, r2, #4
119
		bmi	.Lc2u_1nowords
L
Linus Torvalds 已提交
120 121 122
		mov	r3, r7, pull #8
		ldr	r7, [r1], #4
		orr	r3, r3, r7, push #24
123
USER(	TUSER(	str)	r3, [r0], #4)			@ May fault
L
Linus Torvalds 已提交
124 125 126
		mov	ip, r0, lsl #32 - PAGE_SHIFT
		rsb	ip, ip, #0
		movs	ip, ip, lsr #32 - PAGE_SHIFT
127
		beq	.Lc2u_1fupi
L
Linus Torvalds 已提交
128 129 130 131
		cmp	r2, ip
		movlt	ip, r2
		sub	r2, r2, ip
		subs	ip, ip, #16
132
		blt	.Lc2u_1rem8lp
133

134
.Lc2u_1cpy8lp:	mov	r3, r7, pull #8
L
Linus Torvalds 已提交
135 136 137 138 139 140 141 142 143 144
		ldmia	r1!, {r4 - r7}
		subs	ip, ip, #16
		orr	r3, r3, r4, push #24
		mov	r4, r4, pull #8
		orr	r4, r4, r5, push #24
		mov	r5, r5, pull #8
		orr	r5, r5, r6, push #24
		mov	r6, r6, pull #8
		orr	r6, r6, r7, push #24
		stmia	r0!, {r3 - r6}			@ Shouldnt fault
145
		bpl	.Lc2u_1cpy8lp
L
Linus Torvalds 已提交
146

147
.Lc2u_1rem8lp:	tst	ip, #8
L
Linus Torvalds 已提交
148 149 150 151 152 153 154 155 156 157
		movne	r3, r7, pull #8
		ldmneia	r1!, {r4, r7}
		orrne	r3, r3, r4, push #24
		movne	r4, r4, pull #8
		orrne	r4, r4, r7, push #24
		stmneia	r0!, {r3 - r4}			@ Shouldnt fault
		tst	ip, #4
		movne	r3, r7, pull #8
		ldrne	r7, [r1], #4
		orrne	r3, r3, r7, push #24
158
	TUSER(	strne) r3, [r0], #4			@ Shouldnt fault
L
Linus Torvalds 已提交
159
		ands	ip, ip, #3
160 161
		beq	.Lc2u_1fupi
.Lc2u_1nowords:	mov	r3, r7, get_byte_1
L
Linus Torvalds 已提交
162
		teq	ip, #0
163
		beq	.Lc2u_finished
L
Linus Torvalds 已提交
164
		cmp	ip, #2
165
USER(	TUSER(	strb)	r3, [r0], #1)			@ May fault
L
Linus Torvalds 已提交
166
		movge	r3, r7, get_byte_2
167
USER(	TUSER(	strgeb) r3, [r0], #1)			@ May fault
L
Linus Torvalds 已提交
168
		movgt	r3, r7, get_byte_3
169
USER(	TUSER(	strgtb) r3, [r0], #1)			@ May fault
170
		b	.Lc2u_finished
L
Linus Torvalds 已提交
171

172
.Lc2u_2fupi:	subs	r2, r2, #4
L
Linus Torvalds 已提交
173
		addmi	ip, r2, #4
174
		bmi	.Lc2u_2nowords
L
Linus Torvalds 已提交
175 176 177
		mov	r3, r7, pull #16
		ldr	r7, [r1], #4
		orr	r3, r3, r7, push #16
178
USER(	TUSER(	str)	r3, [r0], #4)			@ May fault
L
Linus Torvalds 已提交
179 180 181
		mov	ip, r0, lsl #32 - PAGE_SHIFT
		rsb	ip, ip, #0
		movs	ip, ip, lsr #32 - PAGE_SHIFT
182
		beq	.Lc2u_2fupi
L
Linus Torvalds 已提交
183 184 185 186
		cmp	r2, ip
		movlt	ip, r2
		sub	r2, r2, ip
		subs	ip, ip, #16
187
		blt	.Lc2u_2rem8lp
188

189
.Lc2u_2cpy8lp:	mov	r3, r7, pull #16
L
Linus Torvalds 已提交
190 191 192 193 194 195 196 197 198 199
		ldmia	r1!, {r4 - r7}
		subs	ip, ip, #16
		orr	r3, r3, r4, push #16
		mov	r4, r4, pull #16
		orr	r4, r4, r5, push #16
		mov	r5, r5, pull #16
		orr	r5, r5, r6, push #16
		mov	r6, r6, pull #16
		orr	r6, r6, r7, push #16
		stmia	r0!, {r3 - r6}			@ Shouldnt fault
200
		bpl	.Lc2u_2cpy8lp
L
Linus Torvalds 已提交
201

202
.Lc2u_2rem8lp:	tst	ip, #8
L
Linus Torvalds 已提交
203 204 205 206 207 208 209 210 211 212
		movne	r3, r7, pull #16
		ldmneia	r1!, {r4, r7}
		orrne	r3, r3, r4, push #16
		movne	r4, r4, pull #16
		orrne	r4, r4, r7, push #16
		stmneia	r0!, {r3 - r4}			@ Shouldnt fault
		tst	ip, #4
		movne	r3, r7, pull #16
		ldrne	r7, [r1], #4
		orrne	r3, r3, r7, push #16
213
	TUSER(	strne) r3, [r0], #4			@ Shouldnt fault
L
Linus Torvalds 已提交
214
		ands	ip, ip, #3
215 216
		beq	.Lc2u_2fupi
.Lc2u_2nowords:	mov	r3, r7, get_byte_2
L
Linus Torvalds 已提交
217
		teq	ip, #0
218
		beq	.Lc2u_finished
L
Linus Torvalds 已提交
219
		cmp	ip, #2
220
USER(	TUSER(	strb)	r3, [r0], #1)			@ May fault
L
Linus Torvalds 已提交
221
		movge	r3, r7, get_byte_3
222
USER(	TUSER(	strgeb) r3, [r0], #1)			@ May fault
L
Linus Torvalds 已提交
223
		ldrgtb	r3, [r1], #0
224
USER(	TUSER(	strgtb) r3, [r0], #1)			@ May fault
225
		b	.Lc2u_finished
L
Linus Torvalds 已提交
226

227
.Lc2u_3fupi:	subs	r2, r2, #4
L
Linus Torvalds 已提交
228
		addmi	ip, r2, #4
229
		bmi	.Lc2u_3nowords
L
Linus Torvalds 已提交
230 231 232
		mov	r3, r7, pull #24
		ldr	r7, [r1], #4
		orr	r3, r3, r7, push #8
233
USER(	TUSER(	str)	r3, [r0], #4)			@ May fault
L
Linus Torvalds 已提交
234 235 236
		mov	ip, r0, lsl #32 - PAGE_SHIFT
		rsb	ip, ip, #0
		movs	ip, ip, lsr #32 - PAGE_SHIFT
237
		beq	.Lc2u_3fupi
L
Linus Torvalds 已提交
238 239 240 241
		cmp	r2, ip
		movlt	ip, r2
		sub	r2, r2, ip
		subs	ip, ip, #16
242
		blt	.Lc2u_3rem8lp
243

244
.Lc2u_3cpy8lp:	mov	r3, r7, pull #24
L
Linus Torvalds 已提交
245 246 247 248 249 250 251 252 253 254
		ldmia	r1!, {r4 - r7}
		subs	ip, ip, #16
		orr	r3, r3, r4, push #8
		mov	r4, r4, pull #24
		orr	r4, r4, r5, push #8
		mov	r5, r5, pull #24
		orr	r5, r5, r6, push #8
		mov	r6, r6, pull #24
		orr	r6, r6, r7, push #8
		stmia	r0!, {r3 - r6}			@ Shouldnt fault
255
		bpl	.Lc2u_3cpy8lp
L
Linus Torvalds 已提交
256

257
.Lc2u_3rem8lp:	tst	ip, #8
L
Linus Torvalds 已提交
258 259 260 261 262 263 264 265 266 267
		movne	r3, r7, pull #24
		ldmneia	r1!, {r4, r7}
		orrne	r3, r3, r4, push #8
		movne	r4, r4, pull #24
		orrne	r4, r4, r7, push #8
		stmneia	r0!, {r3 - r4}			@ Shouldnt fault
		tst	ip, #4
		movne	r3, r7, pull #24
		ldrne	r7, [r1], #4
		orrne	r3, r3, r7, push #8
268
	TUSER(	strne) r3, [r0], #4			@ Shouldnt fault
L
Linus Torvalds 已提交
269
		ands	ip, ip, #3
270 271
		beq	.Lc2u_3fupi
.Lc2u_3nowords:	mov	r3, r7, get_byte_3
L
Linus Torvalds 已提交
272
		teq	ip, #0
273
		beq	.Lc2u_finished
L
Linus Torvalds 已提交
274
		cmp	ip, #2
275
USER(	TUSER(	strb)	r3, [r0], #1)			@ May fault
L
Linus Torvalds 已提交
276
		ldrgeb	r3, [r1], #1
277
USER(	TUSER(	strgeb) r3, [r0], #1)			@ May fault
L
Linus Torvalds 已提交
278
		ldrgtb	r3, [r1], #0
279
USER(	TUSER(	strgtb) r3, [r0], #1)			@ May fault
280
		b	.Lc2u_finished
281
ENDPROC(__copy_to_user)
L
Linus Torvalds 已提交
282

283
		.pushsection .fixup,"ax"
L
Linus Torvalds 已提交
284
		.align	0
R
Russell King 已提交
285
9001:		ldmfd	sp!, {r0, r4 - r7, pc}
286
		.popsection
L
Linus Torvalds 已提交
287

288
/* Prototype: unsigned long __copy_from_user(void *to,const void *from,unsigned long n);
L
Linus Torvalds 已提交
289 290 291 292 293 294
 * Purpose  : copy a block from user memory to kernel memory
 * Params   : to   - kernel memory
 *          : from - user memory
 *          : n    - number of bytes to copy
 * Returns  : Number of bytes NOT copied.
 */
295
.Lcfu_dest_not_aligned:
L
Linus Torvalds 已提交
296 297
		rsb	ip, ip, #4
		cmp	ip, #2
298
USER(	TUSER(	ldrb)	r3, [r1], #1)			@ May fault
L
Linus Torvalds 已提交
299
		strb	r3, [r0], #1
300
USER(	TUSER(	ldrgeb) r3, [r1], #1)			@ May fault
L
Linus Torvalds 已提交
301
		strgeb	r3, [r0], #1
302
USER(	TUSER(	ldrgtb) r3, [r1], #1)			@ May fault
L
Linus Torvalds 已提交
303 304
		strgtb	r3, [r0], #1
		sub	r2, r2, ip
305
		b	.Lcfu_dest_aligned
L
Linus Torvalds 已提交
306

307
ENTRY(__copy_from_user)
L
Linus Torvalds 已提交
308 309
		stmfd	sp!, {r0, r2, r4 - r7, lr}
		cmp	r2, #4
310
		blt	.Lcfu_not_enough
L
Linus Torvalds 已提交
311
		ands	ip, r0, #3
312 313
		bne	.Lcfu_dest_not_aligned
.Lcfu_dest_aligned:
L
Linus Torvalds 已提交
314
		ands	ip, r1, #3
315 316
		bne	.Lcfu_src_not_aligned

L
Linus Torvalds 已提交
317 318 319 320 321
/*
 * Seeing as there has to be at least 8 bytes to copy, we can
 * copy one word, and force a user-mode page fault...
 */

322
.Lcfu_0fupi:	subs	r2, r2, #4
L
Linus Torvalds 已提交
323
		addmi	ip, r2, #4
324
		bmi	.Lcfu_0nowords
325
USER(	TUSER(	ldr)	r3, [r1], #4)
L
Linus Torvalds 已提交
326 327 328 329
		str	r3, [r0], #4
		mov	ip, r1, lsl #32 - PAGE_SHIFT	@ On each page, use a ld/st??t instruction
		rsb	ip, ip, #0
		movs	ip, ip, lsr #32 - PAGE_SHIFT
330
		beq	.Lcfu_0fupi
L
Linus Torvalds 已提交
331 332 333 334 335 336 337
/*
 * ip = max no. of bytes to copy before needing another "strt" insn
 */
		cmp	r2, ip
		movlt	ip, r2
		sub	r2, r2, ip
		subs	ip, ip, #32
338
		blt	.Lcfu_0rem8lp
339

340
.Lcfu_0cpy8lp:	ldmia	r1!, {r3 - r6}			@ Shouldnt fault
L
Linus Torvalds 已提交
341 342 343 344
		stmia	r0!, {r3 - r6}
		ldmia	r1!, {r3 - r6}			@ Shouldnt fault
		subs	ip, ip, #32
		stmia	r0!, {r3 - r6}
345
		bpl	.Lcfu_0cpy8lp
L
Linus Torvalds 已提交
346

347
.Lcfu_0rem8lp:	cmn	ip, #16
L
Linus Torvalds 已提交
348 349 350 351 352 353
		ldmgeia	r1!, {r3 - r6}			@ Shouldnt fault
		stmgeia	r0!, {r3 - r6}
		tst	ip, #8
		ldmneia	r1!, {r3 - r4}			@ Shouldnt fault
		stmneia	r0!, {r3 - r4}
		tst	ip, #4
354
	TUSER(	ldrne) r3, [r1], #4			@ Shouldnt fault
L
Linus Torvalds 已提交
355 356
		strne	r3, [r0], #4
		ands	ip, ip, #3
357 358 359 360
		beq	.Lcfu_0fupi
.Lcfu_0nowords:	teq	ip, #0
		beq	.Lcfu_finished
.Lcfu_nowords:	cmp	ip, #2
361
USER(	TUSER(	ldrb)	r3, [r1], #1)			@ May fault
L
Linus Torvalds 已提交
362
		strb	r3, [r0], #1
363
USER(	TUSER(	ldrgeb) r3, [r1], #1)			@ May fault
L
Linus Torvalds 已提交
364
		strgeb	r3, [r0], #1
365
USER(	TUSER(	ldrgtb) r3, [r1], #1)			@ May fault
L
Linus Torvalds 已提交
366
		strgtb	r3, [r0], #1
367
		b	.Lcfu_finished
L
Linus Torvalds 已提交
368

369
.Lcfu_not_enough:
L
Linus Torvalds 已提交
370
		movs	ip, r2
371 372
		bne	.Lcfu_nowords
.Lcfu_finished:	mov	r0, #0
L
Linus Torvalds 已提交
373
		add	sp, sp, #8
R
Russell King 已提交
374
		ldmfd	sp!, {r4 - r7, pc}
L
Linus Torvalds 已提交
375

376
.Lcfu_src_not_aligned:
L
Linus Torvalds 已提交
377
		bic	r1, r1, #3
378
USER(	TUSER(	ldr)	r7, [r1], #4)			@ May fault
L
Linus Torvalds 已提交
379
		cmp	ip, #2
380 381 382
		bgt	.Lcfu_3fupi
		beq	.Lcfu_2fupi
.Lcfu_1fupi:	subs	r2, r2, #4
L
Linus Torvalds 已提交
383
		addmi	ip, r2, #4
384
		bmi	.Lcfu_1nowords
L
Linus Torvalds 已提交
385
		mov	r3, r7, pull #8
386
USER(	TUSER(	ldr)	r7, [r1], #4)			@ May fault
L
Linus Torvalds 已提交
387 388 389 390 391
		orr	r3, r3, r7, push #24
		str	r3, [r0], #4
		mov	ip, r1, lsl #32 - PAGE_SHIFT
		rsb	ip, ip, #0
		movs	ip, ip, lsr #32 - PAGE_SHIFT
392
		beq	.Lcfu_1fupi
L
Linus Torvalds 已提交
393 394 395 396
		cmp	r2, ip
		movlt	ip, r2
		sub	r2, r2, ip
		subs	ip, ip, #16
397
		blt	.Lcfu_1rem8lp
398

399
.Lcfu_1cpy8lp:	mov	r3, r7, pull #8
L
Linus Torvalds 已提交
400 401 402 403 404 405 406 407 408 409
		ldmia	r1!, {r4 - r7}			@ Shouldnt fault
		subs	ip, ip, #16
		orr	r3, r3, r4, push #24
		mov	r4, r4, pull #8
		orr	r4, r4, r5, push #24
		mov	r5, r5, pull #8
		orr	r5, r5, r6, push #24
		mov	r6, r6, pull #8
		orr	r6, r6, r7, push #24
		stmia	r0!, {r3 - r6}
410
		bpl	.Lcfu_1cpy8lp
L
Linus Torvalds 已提交
411

412
.Lcfu_1rem8lp:	tst	ip, #8
L
Linus Torvalds 已提交
413 414 415 416 417 418 419 420
		movne	r3, r7, pull #8
		ldmneia	r1!, {r4, r7}			@ Shouldnt fault
		orrne	r3, r3, r4, push #24
		movne	r4, r4, pull #8
		orrne	r4, r4, r7, push #24
		stmneia	r0!, {r3 - r4}
		tst	ip, #4
		movne	r3, r7, pull #8
421
USER(	TUSER(	ldrne) r7, [r1], #4)			@ May fault
L
Linus Torvalds 已提交
422 423 424
		orrne	r3, r3, r7, push #24
		strne	r3, [r0], #4
		ands	ip, ip, #3
425 426
		beq	.Lcfu_1fupi
.Lcfu_1nowords:	mov	r3, r7, get_byte_1
L
Linus Torvalds 已提交
427
		teq	ip, #0
428
		beq	.Lcfu_finished
L
Linus Torvalds 已提交
429 430 431 432 433 434
		cmp	ip, #2
		strb	r3, [r0], #1
		movge	r3, r7, get_byte_2
		strgeb	r3, [r0], #1
		movgt	r3, r7, get_byte_3
		strgtb	r3, [r0], #1
435
		b	.Lcfu_finished
L
Linus Torvalds 已提交
436

437
.Lcfu_2fupi:	subs	r2, r2, #4
L
Linus Torvalds 已提交
438
		addmi	ip, r2, #4
439
		bmi	.Lcfu_2nowords
L
Linus Torvalds 已提交
440
		mov	r3, r7, pull #16
441
USER(	TUSER(	ldr)	r7, [r1], #4)			@ May fault
L
Linus Torvalds 已提交
442 443 444 445 446
		orr	r3, r3, r7, push #16
		str	r3, [r0], #4
		mov	ip, r1, lsl #32 - PAGE_SHIFT
		rsb	ip, ip, #0
		movs	ip, ip, lsr #32 - PAGE_SHIFT
447
		beq	.Lcfu_2fupi
L
Linus Torvalds 已提交
448 449 450 451
		cmp	r2, ip
		movlt	ip, r2
		sub	r2, r2, ip
		subs	ip, ip, #16
452 453
		blt	.Lcfu_2rem8lp

454

455
.Lcfu_2cpy8lp:	mov	r3, r7, pull #16
L
Linus Torvalds 已提交
456 457 458 459 460 461 462 463 464 465
		ldmia	r1!, {r4 - r7}			@ Shouldnt fault
		subs	ip, ip, #16
		orr	r3, r3, r4, push #16
		mov	r4, r4, pull #16
		orr	r4, r4, r5, push #16
		mov	r5, r5, pull #16
		orr	r5, r5, r6, push #16
		mov	r6, r6, pull #16
		orr	r6, r6, r7, push #16
		stmia	r0!, {r3 - r6}
466
		bpl	.Lcfu_2cpy8lp
L
Linus Torvalds 已提交
467

468
.Lcfu_2rem8lp:	tst	ip, #8
L
Linus Torvalds 已提交
469 470 471 472 473 474 475 476
		movne	r3, r7, pull #16
		ldmneia	r1!, {r4, r7}			@ Shouldnt fault
		orrne	r3, r3, r4, push #16
		movne	r4, r4, pull #16
		orrne	r4, r4, r7, push #16
		stmneia	r0!, {r3 - r4}
		tst	ip, #4
		movne	r3, r7, pull #16
477
USER(	TUSER(	ldrne) r7, [r1], #4)			@ May fault
L
Linus Torvalds 已提交
478 479 480
		orrne	r3, r3, r7, push #16
		strne	r3, [r0], #4
		ands	ip, ip, #3
481 482
		beq	.Lcfu_2fupi
.Lcfu_2nowords:	mov	r3, r7, get_byte_2
L
Linus Torvalds 已提交
483
		teq	ip, #0
484
		beq	.Lcfu_finished
L
Linus Torvalds 已提交
485 486 487 488
		cmp	ip, #2
		strb	r3, [r0], #1
		movge	r3, r7, get_byte_3
		strgeb	r3, [r0], #1
489
USER(	TUSER(	ldrgtb) r3, [r1], #0)			@ May fault
L
Linus Torvalds 已提交
490
		strgtb	r3, [r0], #1
491
		b	.Lcfu_finished
L
Linus Torvalds 已提交
492

493
.Lcfu_3fupi:	subs	r2, r2, #4
L
Linus Torvalds 已提交
494
		addmi	ip, r2, #4
495
		bmi	.Lcfu_3nowords
L
Linus Torvalds 已提交
496
		mov	r3, r7, pull #24
497
USER(	TUSER(	ldr)	r7, [r1], #4)			@ May fault
L
Linus Torvalds 已提交
498 499 500 501 502
		orr	r3, r3, r7, push #8
		str	r3, [r0], #4
		mov	ip, r1, lsl #32 - PAGE_SHIFT
		rsb	ip, ip, #0
		movs	ip, ip, lsr #32 - PAGE_SHIFT
503
		beq	.Lcfu_3fupi
L
Linus Torvalds 已提交
504 505 506 507
		cmp	r2, ip
		movlt	ip, r2
		sub	r2, r2, ip
		subs	ip, ip, #16
508
		blt	.Lcfu_3rem8lp
509

510
.Lcfu_3cpy8lp:	mov	r3, r7, pull #24
L
Linus Torvalds 已提交
511 512 513 514 515 516 517 518 519 520
		ldmia	r1!, {r4 - r7}			@ Shouldnt fault
		orr	r3, r3, r4, push #8
		mov	r4, r4, pull #24
		orr	r4, r4, r5, push #8
		mov	r5, r5, pull #24
		orr	r5, r5, r6, push #8
		mov	r6, r6, pull #24
		orr	r6, r6, r7, push #8
		stmia	r0!, {r3 - r6}
		subs	ip, ip, #16
521
		bpl	.Lcfu_3cpy8lp
L
Linus Torvalds 已提交
522

523
.Lcfu_3rem8lp:	tst	ip, #8
L
Linus Torvalds 已提交
524 525 526 527 528 529 530 531
		movne	r3, r7, pull #24
		ldmneia	r1!, {r4, r7}			@ Shouldnt fault
		orrne	r3, r3, r4, push #8
		movne	r4, r4, pull #24
		orrne	r4, r4, r7, push #8
		stmneia	r0!, {r3 - r4}
		tst	ip, #4
		movne	r3, r7, pull #24
532
USER(	TUSER(	ldrne) r7, [r1], #4)			@ May fault
L
Linus Torvalds 已提交
533 534 535
		orrne	r3, r3, r7, push #8
		strne	r3, [r0], #4
		ands	ip, ip, #3
536 537
		beq	.Lcfu_3fupi
.Lcfu_3nowords:	mov	r3, r7, get_byte_3
L
Linus Torvalds 已提交
538
		teq	ip, #0
539
		beq	.Lcfu_finished
L
Linus Torvalds 已提交
540 541
		cmp	ip, #2
		strb	r3, [r0], #1
542
USER(	TUSER(	ldrgeb) r3, [r1], #1)			@ May fault
L
Linus Torvalds 已提交
543
		strgeb	r3, [r0], #1
544
USER(	TUSER(	ldrgtb) r3, [r1], #1)			@ May fault
L
Linus Torvalds 已提交
545
		strgtb	r3, [r0], #1
546
		b	.Lcfu_finished
547
ENDPROC(__copy_from_user)
L
Linus Torvalds 已提交
548

549
		.pushsection .fixup,"ax"
L
Linus Torvalds 已提交
550 551 552 553 554 555 556 557 558 559 560 561
		.align	0
		/*
		 * We took an exception.  r0 contains a pointer to
		 * the byte not copied.
		 */
9001:		ldr	r2, [sp], #4			@ void *to
		sub	r2, r0, r2			@ bytes copied
		ldr	r1, [sp], #4			@ unsigned long count
		subs	r4, r1, r2			@ bytes left to copy
		movne	r1, r4
		blne	__memzero
		mov	r0, r4
R
Russell King 已提交
562
		ldmfd	sp!, {r4 - r7, pc}
563
		.popsection
L
Linus Torvalds 已提交
564