diff options
author | Daniel Thompson <daniel.thompson@linaro.org> | 2014-07-10 15:58:08 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-07-18 07:29:34 -0400 |
commit | e38361d032f12f42ddc6d8e2028f6668da696d14 (patch) | |
tree | 43b60217fbff7e9edc93f6466647548e5e5b8da3 /arch/arm/lib | |
parent | bc994c77ce82576209dcf08f71de9ae51b0b100f (diff) |
ARM: 8091/2: add get_user() support for 8 byte types
Recent contributions, including to DRM and binder, introduce 64-bit
values in their interfaces. A common motivation for this is to allow
the same ABI for 32- and 64-bit userspaces (and therefore also a shared
ABI for 32/64 hybrid userspaces). Anyhow, the developers would like to
avoid gotchas like having to use copy_from_user().
This feature is already implemented on x86-32 and the majority of other
32-bit architectures. The current list of get_user_8 hold out
architectures are: arm, avr32, blackfin, m32r, metag, microblaze,
mn10300, sh.
Credit:
My name sits rather uneasily at the top of this patch. The v1 and
v2 versions of the patch were written by Rob Clark and to produce v4
I mostly copied code from Russell King and H. Peter Anvin. However I
have mangled the patch sufficiently that *blame* is rightfully mine
even if credit should more widely shared.
Changelog:
v5: updated to use the ret macro (requested by Russell King)
v4: remove an inlined add on big endian systems (spotted by Russell King),
used __ARMEB__ rather than BIG_ENDIAN (to match rest of file),
cleared r3 on EFAULT during __get_user_8.
v3: fix a couple of checkpatch issues
v2: pass correct size to check_uaccess, and better handling of narrowing
double word read with __get_user_xb() (Russell King's suggestion)
v1: original
Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/lib')
-rw-r--r-- | arch/arm/lib/getuser.S | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/arch/arm/lib/getuser.S b/arch/arm/lib/getuser.S index 0f958e3d8180..938600098b88 100644 --- a/arch/arm/lib/getuser.S +++ b/arch/arm/lib/getuser.S | |||
@@ -18,7 +18,7 @@ | |||
18 | * Inputs: r0 contains the address | 18 | * Inputs: r0 contains the address |
19 | * r1 contains the address limit, which must be preserved | 19 | * r1 contains the address limit, which must be preserved |
20 | * Outputs: r0 is the error code | 20 | * Outputs: r0 is the error code |
21 | * r2 contains the zero-extended value | 21 | * r2, r3 contains the zero-extended value |
22 | * lr corrupted | 22 | * lr corrupted |
23 | * | 23 | * |
24 | * No other registers must be altered. (see <asm/uaccess.h> | 24 | * No other registers must be altered. (see <asm/uaccess.h> |
@@ -66,15 +66,50 @@ ENTRY(__get_user_4) | |||
66 | ret lr | 66 | ret lr |
67 | ENDPROC(__get_user_4) | 67 | ENDPROC(__get_user_4) |
68 | 68 | ||
69 | ENTRY(__get_user_8) | ||
70 | check_uaccess r0, 8, r1, r2, __get_user_bad | ||
71 | #ifdef CONFIG_THUMB2_KERNEL | ||
72 | 5: TUSER(ldr) r2, [r0] | ||
73 | 6: TUSER(ldr) r3, [r0, #4] | ||
74 | #else | ||
75 | 5: TUSER(ldr) r2, [r0], #4 | ||
76 | 6: TUSER(ldr) r3, [r0] | ||
77 | #endif | ||
78 | mov r0, #0 | ||
79 | ret lr | ||
80 | ENDPROC(__get_user_8) | ||
81 | |||
82 | #ifdef __ARMEB__ | ||
83 | ENTRY(__get_user_lo8) | ||
84 | check_uaccess r0, 8, r1, r2, __get_user_bad | ||
85 | #ifdef CONFIG_CPU_USE_DOMAINS | ||
86 | add r0, r0, #4 | ||
87 | 7: ldrt r2, [r0] | ||
88 | #else | ||
89 | 7: ldr r2, [r0, #4] | ||
90 | #endif | ||
91 | mov r0, #0 | ||
92 | ret lr | ||
93 | ENDPROC(__get_user_lo8) | ||
94 | #endif | ||
95 | |||
96 | __get_user_bad8: | ||
97 | mov r3, #0 | ||
69 | __get_user_bad: | 98 | __get_user_bad: |
70 | mov r2, #0 | 99 | mov r2, #0 |
71 | mov r0, #-EFAULT | 100 | mov r0, #-EFAULT |
72 | ret lr | 101 | ret lr |
73 | ENDPROC(__get_user_bad) | 102 | ENDPROC(__get_user_bad) |
103 | ENDPROC(__get_user_bad8) | ||
74 | 104 | ||
75 | .pushsection __ex_table, "a" | 105 | .pushsection __ex_table, "a" |
76 | .long 1b, __get_user_bad | 106 | .long 1b, __get_user_bad |
77 | .long 2b, __get_user_bad | 107 | .long 2b, __get_user_bad |
78 | .long 3b, __get_user_bad | 108 | .long 3b, __get_user_bad |
79 | .long 4b, __get_user_bad | 109 | .long 4b, __get_user_bad |
110 | .long 5b, __get_user_bad8 | ||
111 | .long 6b, __get_user_bad8 | ||
112 | #ifdef __ARMEB__ | ||
113 | .long 7b, __get_user_bad | ||
114 | #endif | ||
80 | .popsection | 115 | .popsection |