diff options
author | Feng Kan <fkan@apm.com> | 2015-09-23 14:55:39 -0400 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2015-10-07 06:34:44 -0400 |
commit | 404268828c74ba06b1f21584b26edafb381c9d7d (patch) | |
tree | 3bd7d62e4a98e500158921d80021fcf0f7c35f11 /arch/arm64/lib/copy_from_user.S | |
parent | e5c88e3f2fb35dca5f3e46d65095bf5d008595b7 (diff) |
arm64: copy_to-from-in_user optimization using copy template
This patch optimize copy_to-from-in_user for arm 64bit architecture. The
copy template is used as template file for all the copy*.S files. Minor
change was made to it to accommodate the copy to/from/in user files.
Signed-off-by: Feng Kan <fkan@apm.com>
Signed-off-by: Balamurugan Shanmugam <bshanmugam@apm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm64/lib/copy_from_user.S')
-rw-r--r-- | arch/arm64/lib/copy_from_user.S | 78 |
1 files changed, 44 insertions, 34 deletions
diff --git a/arch/arm64/lib/copy_from_user.S b/arch/arm64/lib/copy_from_user.S index 1be9ef27be97..4699cd74f87e 100644 --- a/arch/arm64/lib/copy_from_user.S +++ b/arch/arm64/lib/copy_from_user.S | |||
@@ -18,6 +18,7 @@ | |||
18 | 18 | ||
19 | #include <asm/alternative.h> | 19 | #include <asm/alternative.h> |
20 | #include <asm/assembler.h> | 20 | #include <asm/assembler.h> |
21 | #include <asm/cache.h> | ||
21 | #include <asm/cpufeature.h> | 22 | #include <asm/cpufeature.h> |
22 | #include <asm/sysreg.h> | 23 | #include <asm/sysreg.h> |
23 | 24 | ||
@@ -31,49 +32,58 @@ | |||
31 | * Returns: | 32 | * Returns: |
32 | * x0 - bytes not copied | 33 | * x0 - bytes not copied |
33 | */ | 34 | */ |
35 | |||
36 | .macro ldrb1 ptr, regB, val | ||
37 | USER(9998f, ldrb \ptr, [\regB], \val) | ||
38 | .endm | ||
39 | |||
40 | .macro strb1 ptr, regB, val | ||
41 | strb \ptr, [\regB], \val | ||
42 | .endm | ||
43 | |||
44 | .macro ldrh1 ptr, regB, val | ||
45 | USER(9998f, ldrh \ptr, [\regB], \val) | ||
46 | .endm | ||
47 | |||
48 | .macro strh1 ptr, regB, val | ||
49 | strh \ptr, [\regB], \val | ||
50 | .endm | ||
51 | |||
52 | .macro ldr1 ptr, regB, val | ||
53 | USER(9998f, ldr \ptr, [\regB], \val) | ||
54 | .endm | ||
55 | |||
56 | .macro str1 ptr, regB, val | ||
57 | str \ptr, [\regB], \val | ||
58 | .endm | ||
59 | |||
60 | .macro ldp1 ptr, regB, regC, val | ||
61 | USER(9998f, ldp \ptr, \regB, [\regC], \val) | ||
62 | .endm | ||
63 | |||
64 | .macro stp1 ptr, regB, regC, val | ||
65 | stp \ptr, \regB, [\regC], \val | ||
66 | .endm | ||
67 | |||
68 | end .req x5 | ||
34 | ENTRY(__copy_from_user) | 69 | ENTRY(__copy_from_user) |
35 | ALTERNATIVE("nop", __stringify(SET_PSTATE_PAN(0)), ARM64_HAS_PAN, \ | 70 | ALTERNATIVE("nop", __stringify(SET_PSTATE_PAN(0)), ARM64_HAS_PAN, \ |
36 | CONFIG_ARM64_PAN) | 71 | CONFIG_ARM64_PAN) |
37 | add x5, x1, x2 // upper user buffer boundary | 72 | add end, x0, x2 |
38 | subs x2, x2, #16 | 73 | #include "copy_template.S" |
39 | b.mi 1f | ||
40 | 0: | ||
41 | USER(9f, ldp x3, x4, [x1], #16) | ||
42 | subs x2, x2, #16 | ||
43 | stp x3, x4, [x0], #16 | ||
44 | b.pl 0b | ||
45 | 1: adds x2, x2, #8 | ||
46 | b.mi 2f | ||
47 | USER(9f, ldr x3, [x1], #8 ) | ||
48 | sub x2, x2, #8 | ||
49 | str x3, [x0], #8 | ||
50 | 2: adds x2, x2, #4 | ||
51 | b.mi 3f | ||
52 | USER(9f, ldr w3, [x1], #4 ) | ||
53 | sub x2, x2, #4 | ||
54 | str w3, [x0], #4 | ||
55 | 3: adds x2, x2, #2 | ||
56 | b.mi 4f | ||
57 | USER(9f, ldrh w3, [x1], #2 ) | ||
58 | sub x2, x2, #2 | ||
59 | strh w3, [x0], #2 | ||
60 | 4: adds x2, x2, #1 | ||
61 | b.mi 5f | ||
62 | USER(9f, ldrb w3, [x1] ) | ||
63 | strb w3, [x0] | ||
64 | 5: mov x0, #0 | ||
65 | ALTERNATIVE("nop", __stringify(SET_PSTATE_PAN(1)), ARM64_HAS_PAN, \ | 74 | ALTERNATIVE("nop", __stringify(SET_PSTATE_PAN(1)), ARM64_HAS_PAN, \ |
66 | CONFIG_ARM64_PAN) | 75 | CONFIG_ARM64_PAN) |
76 | mov x0, #0 // Nothing to copy | ||
67 | ret | 77 | ret |
68 | ENDPROC(__copy_from_user) | 78 | ENDPROC(__copy_from_user) |
69 | 79 | ||
70 | .section .fixup,"ax" | 80 | .section .fixup,"ax" |
71 | .align 2 | 81 | .align 2 |
72 | 9: sub x2, x5, x1 | 82 | 9998: |
73 | mov x3, x2 | 83 | sub x0, end, dst |
74 | 10: strb wzr, [x0], #1 // zero remaining buffer space | 84 | 9999: |
75 | subs x3, x3, #1 | 85 | strb wzr, [dst], #1 // zero remaining buffer space |
76 | b.ne 10b | 86 | cmp dst, end |
77 | mov x0, x2 // bytes not copied | 87 | b.lo 9999b |
78 | ret | 88 | ret |
79 | .previous | 89 | .previous |