Commit 23b7d672 authored by Russell King's avatar Russell King

[ARM] Ensure user ops pass 64-bit constants in even,odd registers.

Always pass values to get_user and put_user in an even numbered
register, and optionally the next odd numbered register.  This
ensures that we are compatible with compiler enhancements.
parent 3b27bf69
......@@ -17,7 +17,7 @@
*
* Inputs: r0 contains the address
* Outputs: r0 is the error code
* r1, r2 contains the zero-extended value
* r2, r3 contains the zero-extended value
* lr corrupted
*
* No other registers must be altered. (see include/asm-arm/uaccess.h
......@@ -32,39 +32,39 @@
.global __get_user_1
__get_user_1:
1: ldrbt r1, [r0]
1: ldrbt r2, [r0]
mov r0, #0
mov pc, lr
.global __get_user_2
__get_user_2:
2: ldrbt r1, [r0], #1
3: ldrbt r2, [r0]
2: ldrbt r2, [r0], #1
3: ldrbt r3, [r0]
#ifndef __ARMEB__
orr r1, r1, r2, lsl #8
orr r2, r2, r3, lsl #8
#else
orr r1, r2, r1, lsl #8
orr r2, r3, r2, lsl #8
#endif
mov r0, #0
mov pc, lr
.global __get_user_4
__get_user_4:
4: ldrt r1, [r0]
4: ldrt r2, [r0]
mov r0, #0
mov pc, lr
.global __get_user_8
__get_user_8:
5: ldrt r1, [r0], #4
6: ldrt r2, [r0]
5: ldrt r2, [r0], #4
6: ldrt r3, [r0]
mov r0, #0
mov pc, lr
__get_user_bad_8:
mov r2, #0
mov r3, #0
__get_user_bad:
mov r1, #0
mov r2, #0
mov r0, #-EFAULT
mov pc, lr
......
......@@ -16,7 +16,7 @@
* __put_user_X
*
* Inputs: r0 contains the address
* r1, r2 contains the value
* r2, r3 contains the value
* Outputs: r0 is the error code
* lr corrupted
*
......@@ -32,33 +32,33 @@
.global __put_user_1
__put_user_1:
1: strbt r1, [r0]
1: strbt r2, [r0]
mov r0, #0
mov pc, lr
.global __put_user_2
__put_user_2:
mov ip, r1, lsr #8
mov ip, r2, lsr #8
#ifndef __ARMEB__
2: strbt r1, [r0], #1
2: strbt r2, [r0], #1
3: strbt ip, [r0]
#else
2: strbt ip, [r0], #1
3: strbt r1, [r0]
3: strbt r2, [r0]
#endif
mov r0, #0
mov pc, lr
.global __put_user_4
__put_user_4:
4: strt r1, [r0]
4: strt r2, [r0]
mov r0, #0
mov pc, lr
.global __put_user_8
__put_user_8:
5: strt r1, [r0], #4
6: strt r2, [r0]
5: strt r2, [r0], #4
6: strt r3, [r0]
mov r0, #0
mov pc, lr
......
......@@ -108,35 +108,35 @@ extern int __get_user_4(void *);
extern int __get_user_8(void *);
extern int __get_user_bad(void);
#define __get_user_x(__r1,__p,__e,__s,__i...) \
#define __get_user_x(__r2,__p,__e,__s,__i...) \
__asm__ __volatile__ ( \
__asmeq("%0", "r0") __asmeq("%1", "r1") \
__asmeq("%0", "r0") __asmeq("%1", "r2") \
"bl __get_user_" #__s \
: "=&r" (__e), "=r" (__r1) \
: "=&r" (__e), "=r" (__r2) \
: "0" (__p) \
: __i, "cc")
#define get_user(x,p) \
({ \
const register typeof(*(p)) __user *__p asm("r0") = (p);\
register typeof(*(p)) __r1 asm("r1"); \
register typeof(*(p)) __r2 asm("r2"); \
register int __e asm("r0"); \
switch (sizeof(*(__p))) { \
case 1: \
__get_user_x(__r1, __p, __e, 1, "lr"); \
__get_user_x(__r2, __p, __e, 1, "lr"); \
break; \
case 2: \
__get_user_x(__r1, __p, __e, 2, "r2", "lr"); \
__get_user_x(__r2, __p, __e, 2, "r3", "lr"); \
break; \
case 4: \
__get_user_x(__r1, __p, __e, 4, "lr"); \
__get_user_x(__r2, __p, __e, 4, "lr"); \
break; \
case 8: \
__get_user_x(__r1, __p, __e, 8, "lr"); \
__get_user_x(__r2, __p, __e, 8, "lr"); \
break; \
default: __e = __get_user_bad(); break; \
} \
x = __r1; \
x = __r2; \
__e; \
})
......@@ -227,31 +227,31 @@ extern int __put_user_4(void *, unsigned int);
extern int __put_user_8(void *, unsigned long long);
extern int __put_user_bad(void);
#define __put_user_x(__r1,__p,__e,__s) \
#define __put_user_x(__r2,__p,__e,__s) \
__asm__ __volatile__ ( \
__asmeq("%0", "r0") __asmeq("%2", "r1") \
__asmeq("%0", "r0") __asmeq("%2", "r2") \
"bl __put_user_" #__s \
: "=&r" (__e) \
: "0" (__p), "r" (__r1) \
: "0" (__p), "r" (__r2) \
: "ip", "lr", "cc")
#define put_user(x,p) \
({ \
const register typeof(*(p)) __r1 asm("r1") = (x); \
const register typeof(*(p)) __r2 asm("r2") = (x); \
const register typeof(*(p)) __user *__p asm("r0") = (p);\
register int __e asm("r0"); \
switch (sizeof(*(__p))) { \
case 1: \
__put_user_x(__r1, __p, __e, 1); \
__put_user_x(__r2, __p, __e, 1); \
break; \
case 2: \
__put_user_x(__r1, __p, __e, 2); \
__put_user_x(__r2, __p, __e, 2); \
break; \
case 4: \
__put_user_x(__r1, __p, __e, 4); \
__put_user_x(__r2, __p, __e, 4); \
break; \
case 8: \
__put_user_x(__r1, __p, __e, 8); \
__put_user_x(__r2, __p, __e, 8); \
break; \
default: __e = __put_user_bad(); break; \
} \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment