2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
2010-09-13 15:03:21 +00:00
|
|
|
#include <asm/domain.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
.text
|
|
|
|
|
|
|
|
#define PAGE_SHIFT 12
|
|
|
|
|
2006-06-21 13:44:52 +00:00
|
|
|
/* Prototype: int __copy_to_user(void *to, const char *from, size_t n)
|
2005-04-16 22:20:36 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lc2u_dest_not_aligned:
|
2005-04-16 22:20:36 +00:00
|
|
|
rsb ip, ip, #4
|
|
|
|
cmp ip, #2
|
|
|
|
ldrb r3, [r1], #1
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(strb) r3, [r0], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
ldrgeb r3, [r1], #1
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(strgeb) r3, [r0], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
ldrgtb r3, [r1], #1
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(strgtb) r3, [r0], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
sub r2, r2, ip
|
2005-11-11 21:51:47 +00:00
|
|
|
b .Lc2u_dest_aligned
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-06-21 13:44:52 +00:00
|
|
|
ENTRY(__copy_to_user)
|
2005-04-16 22:20:36 +00:00
|
|
|
stmfd sp!, {r2, r4 - r7, lr}
|
|
|
|
cmp r2, #4
|
2005-11-11 21:51:47 +00:00
|
|
|
blt .Lc2u_not_enough
|
2005-04-16 22:20:36 +00:00
|
|
|
ands ip, r0, #3
|
2005-11-11 21:51:47 +00:00
|
|
|
bne .Lc2u_dest_not_aligned
|
|
|
|
.Lc2u_dest_aligned:
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
ands ip, r1, #3
|
2005-11-11 21:51:47 +00:00
|
|
|
bne .Lc2u_src_not_aligned
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Seeing as there has to be at least 8 bytes to copy, we can
|
|
|
|
* copy one word, and force a user-mode page fault...
|
|
|
|
*/
|
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lc2u_0fupi: subs r2, r2, #4
|
2005-04-16 22:20:36 +00:00
|
|
|
addmi ip, r2, #4
|
2005-11-11 21:51:47 +00:00
|
|
|
bmi .Lc2u_0nowords
|
2005-04-16 22:20:36 +00:00
|
|
|
ldr r3, [r1], #4
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(str) r3, [r0], #4) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lc2u_0fupi
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* 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
|
2005-11-11 21:51:47 +00:00
|
|
|
blt .Lc2u_0rem8lp
|
2005-11-04 17:15:43 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lc2u_0cpy8lp: ldmia r1!, {r3 - r6}
|
2005-04-16 22:20:36 +00:00
|
|
|
stmia r0!, {r3 - r6} @ Shouldnt fault
|
|
|
|
ldmia r1!, {r3 - r6}
|
|
|
|
subs ip, ip, #32
|
|
|
|
stmia r0!, {r3 - r6} @ Shouldnt fault
|
2005-11-11 21:51:47 +00:00
|
|
|
bpl .Lc2u_0cpy8lp
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lc2u_0rem8lp: cmn ip, #16
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2010-09-13 15:03:21 +00:00
|
|
|
T(strne) r3, [r0], #4 @ Shouldnt fault
|
2005-04-16 22:20:36 +00:00
|
|
|
ands ip, ip, #3
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lc2u_0fupi
|
|
|
|
.Lc2u_0nowords: teq ip, #0
|
|
|
|
beq .Lc2u_finished
|
|
|
|
.Lc2u_nowords: cmp ip, #2
|
2005-04-16 22:20:36 +00:00
|
|
|
ldrb r3, [r1], #1
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(strb) r3, [r0], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
ldrgeb r3, [r1], #1
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(strgeb) r3, [r0], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
ldrgtb r3, [r1], #1
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(strgtb) r3, [r0], #1) @ May fault
|
2005-11-11 21:51:47 +00:00
|
|
|
b .Lc2u_finished
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lc2u_not_enough:
|
2005-04-16 22:20:36 +00:00
|
|
|
movs ip, r2
|
2005-11-11 21:51:47 +00:00
|
|
|
bne .Lc2u_nowords
|
|
|
|
.Lc2u_finished: mov r0, #0
|
2006-06-25 10:23:45 +00:00
|
|
|
ldmfd sp!, {r2, r4 - r7, pc}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lc2u_src_not_aligned:
|
2005-04-16 22:20:36 +00:00
|
|
|
bic r1, r1, #3
|
|
|
|
ldr r7, [r1], #4
|
|
|
|
cmp ip, #2
|
2005-11-11 21:51:47 +00:00
|
|
|
bgt .Lc2u_3fupi
|
|
|
|
beq .Lc2u_2fupi
|
|
|
|
.Lc2u_1fupi: subs r2, r2, #4
|
2005-04-16 22:20:36 +00:00
|
|
|
addmi ip, r2, #4
|
2005-11-11 21:51:47 +00:00
|
|
|
bmi .Lc2u_1nowords
|
2005-04-16 22:20:36 +00:00
|
|
|
mov r3, r7, pull #8
|
|
|
|
ldr r7, [r1], #4
|
|
|
|
orr r3, r3, r7, push #24
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(str) r3, [r0], #4) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
mov ip, r0, lsl #32 - PAGE_SHIFT
|
|
|
|
rsb ip, ip, #0
|
|
|
|
movs ip, ip, lsr #32 - PAGE_SHIFT
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lc2u_1fupi
|
2005-04-16 22:20:36 +00:00
|
|
|
cmp r2, ip
|
|
|
|
movlt ip, r2
|
|
|
|
sub r2, r2, ip
|
|
|
|
subs ip, ip, #16
|
2005-11-11 21:51:47 +00:00
|
|
|
blt .Lc2u_1rem8lp
|
2005-11-04 17:15:43 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lc2u_1cpy8lp: mov r3, r7, pull #8
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2005-11-11 21:51:47 +00:00
|
|
|
bpl .Lc2u_1cpy8lp
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lc2u_1rem8lp: tst ip, #8
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2010-09-13 15:03:21 +00:00
|
|
|
T(strne) r3, [r0], #4 @ Shouldnt fault
|
2005-04-16 22:20:36 +00:00
|
|
|
ands ip, ip, #3
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lc2u_1fupi
|
|
|
|
.Lc2u_1nowords: mov r3, r7, get_byte_1
|
2005-04-16 22:20:36 +00:00
|
|
|
teq ip, #0
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lc2u_finished
|
2005-04-16 22:20:36 +00:00
|
|
|
cmp ip, #2
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(strb) r3, [r0], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
movge r3, r7, get_byte_2
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(strgeb) r3, [r0], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
movgt r3, r7, get_byte_3
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(strgtb) r3, [r0], #1) @ May fault
|
2005-11-11 21:51:47 +00:00
|
|
|
b .Lc2u_finished
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lc2u_2fupi: subs r2, r2, #4
|
2005-04-16 22:20:36 +00:00
|
|
|
addmi ip, r2, #4
|
2005-11-11 21:51:47 +00:00
|
|
|
bmi .Lc2u_2nowords
|
2005-04-16 22:20:36 +00:00
|
|
|
mov r3, r7, pull #16
|
|
|
|
ldr r7, [r1], #4
|
|
|
|
orr r3, r3, r7, push #16
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(str) r3, [r0], #4) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
mov ip, r0, lsl #32 - PAGE_SHIFT
|
|
|
|
rsb ip, ip, #0
|
|
|
|
movs ip, ip, lsr #32 - PAGE_SHIFT
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lc2u_2fupi
|
2005-04-16 22:20:36 +00:00
|
|
|
cmp r2, ip
|
|
|
|
movlt ip, r2
|
|
|
|
sub r2, r2, ip
|
|
|
|
subs ip, ip, #16
|
2005-11-11 21:51:47 +00:00
|
|
|
blt .Lc2u_2rem8lp
|
2005-11-04 17:15:43 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lc2u_2cpy8lp: mov r3, r7, pull #16
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2005-11-11 21:51:47 +00:00
|
|
|
bpl .Lc2u_2cpy8lp
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lc2u_2rem8lp: tst ip, #8
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2010-09-13 15:03:21 +00:00
|
|
|
T(strne) r3, [r0], #4 @ Shouldnt fault
|
2005-04-16 22:20:36 +00:00
|
|
|
ands ip, ip, #3
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lc2u_2fupi
|
|
|
|
.Lc2u_2nowords: mov r3, r7, get_byte_2
|
2005-04-16 22:20:36 +00:00
|
|
|
teq ip, #0
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lc2u_finished
|
2005-04-16 22:20:36 +00:00
|
|
|
cmp ip, #2
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(strb) r3, [r0], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
movge r3, r7, get_byte_3
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(strgeb) r3, [r0], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
ldrgtb r3, [r1], #0
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(strgtb) r3, [r0], #1) @ May fault
|
2005-11-11 21:51:47 +00:00
|
|
|
b .Lc2u_finished
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lc2u_3fupi: subs r2, r2, #4
|
2005-04-16 22:20:36 +00:00
|
|
|
addmi ip, r2, #4
|
2005-11-11 21:51:47 +00:00
|
|
|
bmi .Lc2u_3nowords
|
2005-04-16 22:20:36 +00:00
|
|
|
mov r3, r7, pull #24
|
|
|
|
ldr r7, [r1], #4
|
|
|
|
orr r3, r3, r7, push #8
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(str) r3, [r0], #4) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
mov ip, r0, lsl #32 - PAGE_SHIFT
|
|
|
|
rsb ip, ip, #0
|
|
|
|
movs ip, ip, lsr #32 - PAGE_SHIFT
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lc2u_3fupi
|
2005-04-16 22:20:36 +00:00
|
|
|
cmp r2, ip
|
|
|
|
movlt ip, r2
|
|
|
|
sub r2, r2, ip
|
|
|
|
subs ip, ip, #16
|
2005-11-11 21:51:47 +00:00
|
|
|
blt .Lc2u_3rem8lp
|
2005-11-04 17:15:43 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lc2u_3cpy8lp: mov r3, r7, pull #24
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2005-11-11 21:51:47 +00:00
|
|
|
bpl .Lc2u_3cpy8lp
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lc2u_3rem8lp: tst ip, #8
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2010-09-13 15:03:21 +00:00
|
|
|
T(strne) r3, [r0], #4 @ Shouldnt fault
|
2005-04-16 22:20:36 +00:00
|
|
|
ands ip, ip, #3
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lc2u_3fupi
|
|
|
|
.Lc2u_3nowords: mov r3, r7, get_byte_3
|
2005-04-16 22:20:36 +00:00
|
|
|
teq ip, #0
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lc2u_finished
|
2005-04-16 22:20:36 +00:00
|
|
|
cmp ip, #2
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(strb) r3, [r0], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
ldrgeb r3, [r1], #1
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(strgeb) r3, [r0], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
ldrgtb r3, [r1], #0
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(strgtb) r3, [r0], #1) @ May fault
|
2005-11-11 21:51:47 +00:00
|
|
|
b .Lc2u_finished
|
2008-08-28 10:22:32 +00:00
|
|
|
ENDPROC(__copy_to_user)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-04-19 09:15:03 +00:00
|
|
|
.pushsection .fixup,"ax"
|
2005-04-16 22:20:36 +00:00
|
|
|
.align 0
|
2006-06-25 10:23:45 +00:00
|
|
|
9001: ldmfd sp!, {r0, r4 - r7, pc}
|
2010-04-19 09:15:03 +00:00
|
|
|
.popsection
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-06-21 13:44:52 +00:00
|
|
|
/* Prototype: unsigned long __copy_from_user(void *to,const void *from,unsigned long n);
|
2005-04-16 22:20:36 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lcfu_dest_not_aligned:
|
2005-04-16 22:20:36 +00:00
|
|
|
rsb ip, ip, #4
|
|
|
|
cmp ip, #2
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(ldrb) r3, [r1], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
strb r3, [r0], #1
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(ldrgeb) r3, [r1], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
strgeb r3, [r0], #1
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(ldrgtb) r3, [r1], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
strgtb r3, [r0], #1
|
|
|
|
sub r2, r2, ip
|
2005-11-11 21:51:47 +00:00
|
|
|
b .Lcfu_dest_aligned
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-06-21 13:44:52 +00:00
|
|
|
ENTRY(__copy_from_user)
|
2005-04-16 22:20:36 +00:00
|
|
|
stmfd sp!, {r0, r2, r4 - r7, lr}
|
|
|
|
cmp r2, #4
|
2005-11-11 21:51:47 +00:00
|
|
|
blt .Lcfu_not_enough
|
2005-04-16 22:20:36 +00:00
|
|
|
ands ip, r0, #3
|
2005-11-11 21:51:47 +00:00
|
|
|
bne .Lcfu_dest_not_aligned
|
|
|
|
.Lcfu_dest_aligned:
|
2005-04-16 22:20:36 +00:00
|
|
|
ands ip, r1, #3
|
2005-11-11 21:51:47 +00:00
|
|
|
bne .Lcfu_src_not_aligned
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Seeing as there has to be at least 8 bytes to copy, we can
|
|
|
|
* copy one word, and force a user-mode page fault...
|
|
|
|
*/
|
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lcfu_0fupi: subs r2, r2, #4
|
2005-04-16 22:20:36 +00:00
|
|
|
addmi ip, r2, #4
|
2005-11-11 21:51:47 +00:00
|
|
|
bmi .Lcfu_0nowords
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(ldr) r3, [r1], #4)
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lcfu_0fupi
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* 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
|
2005-11-11 21:51:47 +00:00
|
|
|
blt .Lcfu_0rem8lp
|
2005-11-04 17:15:43 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lcfu_0cpy8lp: ldmia r1!, {r3 - r6} @ Shouldnt fault
|
2005-04-16 22:20:36 +00:00
|
|
|
stmia r0!, {r3 - r6}
|
|
|
|
ldmia r1!, {r3 - r6} @ Shouldnt fault
|
|
|
|
subs ip, ip, #32
|
|
|
|
stmia r0!, {r3 - r6}
|
2005-11-11 21:51:47 +00:00
|
|
|
bpl .Lcfu_0cpy8lp
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lcfu_0rem8lp: cmn ip, #16
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2010-09-13 15:03:21 +00:00
|
|
|
T(ldrne) r3, [r1], #4 @ Shouldnt fault
|
2005-04-16 22:20:36 +00:00
|
|
|
strne r3, [r0], #4
|
|
|
|
ands ip, ip, #3
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lcfu_0fupi
|
|
|
|
.Lcfu_0nowords: teq ip, #0
|
|
|
|
beq .Lcfu_finished
|
|
|
|
.Lcfu_nowords: cmp ip, #2
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(ldrb) r3, [r1], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
strb r3, [r0], #1
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(ldrgeb) r3, [r1], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
strgeb r3, [r0], #1
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(ldrgtb) r3, [r1], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
strgtb r3, [r0], #1
|
2005-11-11 21:51:47 +00:00
|
|
|
b .Lcfu_finished
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lcfu_not_enough:
|
2005-04-16 22:20:36 +00:00
|
|
|
movs ip, r2
|
2005-11-11 21:51:47 +00:00
|
|
|
bne .Lcfu_nowords
|
|
|
|
.Lcfu_finished: mov r0, #0
|
2005-04-16 22:20:36 +00:00
|
|
|
add sp, sp, #8
|
2006-06-25 10:23:45 +00:00
|
|
|
ldmfd sp!, {r4 - r7, pc}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lcfu_src_not_aligned:
|
2005-04-16 22:20:36 +00:00
|
|
|
bic r1, r1, #3
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(ldr) r7, [r1], #4) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
cmp ip, #2
|
2005-11-11 21:51:47 +00:00
|
|
|
bgt .Lcfu_3fupi
|
|
|
|
beq .Lcfu_2fupi
|
|
|
|
.Lcfu_1fupi: subs r2, r2, #4
|
2005-04-16 22:20:36 +00:00
|
|
|
addmi ip, r2, #4
|
2005-11-11 21:51:47 +00:00
|
|
|
bmi .Lcfu_1nowords
|
2005-04-16 22:20:36 +00:00
|
|
|
mov r3, r7, pull #8
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(ldr) r7, [r1], #4) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lcfu_1fupi
|
2005-04-16 22:20:36 +00:00
|
|
|
cmp r2, ip
|
|
|
|
movlt ip, r2
|
|
|
|
sub r2, r2, ip
|
|
|
|
subs ip, ip, #16
|
2005-11-11 21:51:47 +00:00
|
|
|
blt .Lcfu_1rem8lp
|
2005-11-04 17:15:43 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lcfu_1cpy8lp: mov r3, r7, pull #8
|
2005-04-16 22:20:36 +00:00
|
|
|
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}
|
2005-11-11 21:51:47 +00:00
|
|
|
bpl .Lcfu_1cpy8lp
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lcfu_1rem8lp: tst ip, #8
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(ldrne) r7, [r1], #4) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
orrne r3, r3, r7, push #24
|
|
|
|
strne r3, [r0], #4
|
|
|
|
ands ip, ip, #3
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lcfu_1fupi
|
|
|
|
.Lcfu_1nowords: mov r3, r7, get_byte_1
|
2005-04-16 22:20:36 +00:00
|
|
|
teq ip, #0
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lcfu_finished
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2005-11-11 21:51:47 +00:00
|
|
|
b .Lcfu_finished
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lcfu_2fupi: subs r2, r2, #4
|
2005-04-16 22:20:36 +00:00
|
|
|
addmi ip, r2, #4
|
2005-11-11 21:51:47 +00:00
|
|
|
bmi .Lcfu_2nowords
|
2005-04-16 22:20:36 +00:00
|
|
|
mov r3, r7, pull #16
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(ldr) r7, [r1], #4) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lcfu_2fupi
|
2005-04-16 22:20:36 +00:00
|
|
|
cmp r2, ip
|
|
|
|
movlt ip, r2
|
|
|
|
sub r2, r2, ip
|
|
|
|
subs ip, ip, #16
|
2005-11-11 21:51:47 +00:00
|
|
|
blt .Lcfu_2rem8lp
|
|
|
|
|
2005-11-04 17:15:43 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lcfu_2cpy8lp: mov r3, r7, pull #16
|
2005-04-16 22:20:36 +00:00
|
|
|
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}
|
2005-11-11 21:51:47 +00:00
|
|
|
bpl .Lcfu_2cpy8lp
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lcfu_2rem8lp: tst ip, #8
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(ldrne) r7, [r1], #4) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
orrne r3, r3, r7, push #16
|
|
|
|
strne r3, [r0], #4
|
|
|
|
ands ip, ip, #3
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lcfu_2fupi
|
|
|
|
.Lcfu_2nowords: mov r3, r7, get_byte_2
|
2005-04-16 22:20:36 +00:00
|
|
|
teq ip, #0
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lcfu_finished
|
2005-04-16 22:20:36 +00:00
|
|
|
cmp ip, #2
|
|
|
|
strb r3, [r0], #1
|
|
|
|
movge r3, r7, get_byte_3
|
|
|
|
strgeb r3, [r0], #1
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(ldrgtb) r3, [r1], #0) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
strgtb r3, [r0], #1
|
2005-11-11 21:51:47 +00:00
|
|
|
b .Lcfu_finished
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lcfu_3fupi: subs r2, r2, #4
|
2005-04-16 22:20:36 +00:00
|
|
|
addmi ip, r2, #4
|
2005-11-11 21:51:47 +00:00
|
|
|
bmi .Lcfu_3nowords
|
2005-04-16 22:20:36 +00:00
|
|
|
mov r3, r7, pull #24
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(ldr) r7, [r1], #4) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lcfu_3fupi
|
2005-04-16 22:20:36 +00:00
|
|
|
cmp r2, ip
|
|
|
|
movlt ip, r2
|
|
|
|
sub r2, r2, ip
|
|
|
|
subs ip, ip, #16
|
2005-11-11 21:51:47 +00:00
|
|
|
blt .Lcfu_3rem8lp
|
2005-11-04 17:15:43 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lcfu_3cpy8lp: mov r3, r7, pull #24
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2005-11-11 21:51:47 +00:00
|
|
|
bpl .Lcfu_3cpy8lp
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-11 21:51:47 +00:00
|
|
|
.Lcfu_3rem8lp: tst ip, #8
|
2005-04-16 22:20:36 +00:00
|
|
|
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
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(ldrne) r7, [r1], #4) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
orrne r3, r3, r7, push #8
|
|
|
|
strne r3, [r0], #4
|
|
|
|
ands ip, ip, #3
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lcfu_3fupi
|
|
|
|
.Lcfu_3nowords: mov r3, r7, get_byte_3
|
2005-04-16 22:20:36 +00:00
|
|
|
teq ip, #0
|
2005-11-11 21:51:47 +00:00
|
|
|
beq .Lcfu_finished
|
2005-04-16 22:20:36 +00:00
|
|
|
cmp ip, #2
|
|
|
|
strb r3, [r0], #1
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(ldrgeb) r3, [r1], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
strgeb r3, [r0], #1
|
2010-09-13 15:03:21 +00:00
|
|
|
USER( T(ldrgtb) r3, [r1], #1) @ May fault
|
2005-04-16 22:20:36 +00:00
|
|
|
strgtb r3, [r0], #1
|
2005-11-11 21:51:47 +00:00
|
|
|
b .Lcfu_finished
|
2008-08-28 10:22:32 +00:00
|
|
|
ENDPROC(__copy_from_user)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-04-19 09:15:03 +00:00
|
|
|
.pushsection .fixup,"ax"
|
2005-04-16 22:20:36 +00:00
|
|
|
.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
|
2006-06-25 10:23:45 +00:00
|
|
|
ldmfd sp!, {r4 - r7, pc}
|
2010-04-19 09:15:03 +00:00
|
|
|
.popsection
|
2005-04-16 22:20:36 +00:00
|
|
|
|