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 @@ ...@@ -17,7 +17,7 @@
* *
* Inputs: r0 contains the address * Inputs: r0 contains the address
* Outputs: r0 is the error code * Outputs: r0 is the error code
* r1, r2 contains the zero-extended value * r2, r3 contains the zero-extended value
* lr corrupted * lr corrupted
* *
* No other registers must be altered. (see include/asm-arm/uaccess.h * No other registers must be altered. (see include/asm-arm/uaccess.h
...@@ -32,39 +32,39 @@ ...@@ -32,39 +32,39 @@
.global __get_user_1 .global __get_user_1
__get_user_1: __get_user_1:
1: ldrbt r1, [r0] 1: ldrbt r2, [r0]
mov r0, #0 mov r0, #0
mov pc, lr mov pc, lr
.global __get_user_2 .global __get_user_2
__get_user_2: __get_user_2:
2: ldrbt r1, [r0], #1 2: ldrbt r2, [r0], #1
3: ldrbt r2, [r0] 3: ldrbt r3, [r0]
#ifndef __ARMEB__ #ifndef __ARMEB__
orr r1, r1, r2, lsl #8 orr r2, r2, r3, lsl #8
#else #else
orr r1, r2, r1, lsl #8 orr r2, r3, r2, lsl #8
#endif #endif
mov r0, #0 mov r0, #0
mov pc, lr mov pc, lr
.global __get_user_4 .global __get_user_4
__get_user_4: __get_user_4:
4: ldrt r1, [r0] 4: ldrt r2, [r0]
mov r0, #0 mov r0, #0
mov pc, lr mov pc, lr
.global __get_user_8 .global __get_user_8
__get_user_8: __get_user_8:
5: ldrt r1, [r0], #4 5: ldrt r2, [r0], #4
6: ldrt r2, [r0] 6: ldrt r3, [r0]
mov r0, #0 mov r0, #0
mov pc, lr mov pc, lr
__get_user_bad_8: __get_user_bad_8:
mov r2, #0 mov r3, #0
__get_user_bad: __get_user_bad:
mov r1, #0 mov r2, #0
mov r0, #-EFAULT mov r0, #-EFAULT
mov pc, lr mov pc, lr
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* __put_user_X * __put_user_X
* *
* Inputs: r0 contains the address * Inputs: r0 contains the address
* r1, r2 contains the value * r2, r3 contains the value
* Outputs: r0 is the error code * Outputs: r0 is the error code
* lr corrupted * lr corrupted
* *
...@@ -32,33 +32,33 @@ ...@@ -32,33 +32,33 @@
.global __put_user_1 .global __put_user_1
__put_user_1: __put_user_1:
1: strbt r1, [r0] 1: strbt r2, [r0]
mov r0, #0 mov r0, #0
mov pc, lr mov pc, lr
.global __put_user_2 .global __put_user_2
__put_user_2: __put_user_2:
mov ip, r1, lsr #8 mov ip, r2, lsr #8
#ifndef __ARMEB__ #ifndef __ARMEB__
2: strbt r1, [r0], #1 2: strbt r2, [r0], #1
3: strbt ip, [r0] 3: strbt ip, [r0]
#else #else
2: strbt ip, [r0], #1 2: strbt ip, [r0], #1
3: strbt r1, [r0] 3: strbt r2, [r0]
#endif #endif
mov r0, #0 mov r0, #0
mov pc, lr mov pc, lr
.global __put_user_4 .global __put_user_4
__put_user_4: __put_user_4:
4: strt r1, [r0] 4: strt r2, [r0]
mov r0, #0 mov r0, #0
mov pc, lr mov pc, lr
.global __put_user_8 .global __put_user_8
__put_user_8: __put_user_8:
5: strt r1, [r0], #4 5: strt r2, [r0], #4
6: strt r2, [r0] 6: strt r3, [r0]
mov r0, #0 mov r0, #0
mov pc, lr mov pc, lr
......
...@@ -108,35 +108,35 @@ extern int __get_user_4(void *); ...@@ -108,35 +108,35 @@ extern int __get_user_4(void *);
extern int __get_user_8(void *); extern int __get_user_8(void *);
extern int __get_user_bad(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__ ( \ __asm__ __volatile__ ( \
__asmeq("%0", "r0") __asmeq("%1", "r1") \ __asmeq("%0", "r0") __asmeq("%1", "r2") \
"bl __get_user_" #__s \ "bl __get_user_" #__s \
: "=&r" (__e), "=r" (__r1) \ : "=&r" (__e), "=r" (__r2) \
: "0" (__p) \ : "0" (__p) \
: __i, "cc") : __i, "cc")
#define get_user(x,p) \ #define get_user(x,p) \
({ \ ({ \
const register typeof(*(p)) __user *__p asm("r0") = (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"); \ register int __e asm("r0"); \
switch (sizeof(*(__p))) { \ switch (sizeof(*(__p))) { \
case 1: \ case 1: \
__get_user_x(__r1, __p, __e, 1, "lr"); \ __get_user_x(__r2, __p, __e, 1, "lr"); \
break; \ break; \
case 2: \ case 2: \
__get_user_x(__r1, __p, __e, 2, "r2", "lr"); \ __get_user_x(__r2, __p, __e, 2, "r3", "lr"); \
break; \ break; \
case 4: \ case 4: \
__get_user_x(__r1, __p, __e, 4, "lr"); \ __get_user_x(__r2, __p, __e, 4, "lr"); \
break; \ break; \
case 8: \ case 8: \
__get_user_x(__r1, __p, __e, 8, "lr"); \ __get_user_x(__r2, __p, __e, 8, "lr"); \
break; \ break; \
default: __e = __get_user_bad(); break; \ default: __e = __get_user_bad(); break; \
} \ } \
x = __r1; \ x = __r2; \
__e; \ __e; \
}) })
...@@ -227,31 +227,31 @@ extern int __put_user_4(void *, unsigned int); ...@@ -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_8(void *, unsigned long long);
extern int __put_user_bad(void); extern int __put_user_bad(void);
#define __put_user_x(__r1,__p,__e,__s) \ #define __put_user_x(__r2,__p,__e,__s) \
__asm__ __volatile__ ( \ __asm__ __volatile__ ( \
__asmeq("%0", "r0") __asmeq("%2", "r1") \ __asmeq("%0", "r0") __asmeq("%2", "r2") \
"bl __put_user_" #__s \ "bl __put_user_" #__s \
: "=&r" (__e) \ : "=&r" (__e) \
: "0" (__p), "r" (__r1) \ : "0" (__p), "r" (__r2) \
: "ip", "lr", "cc") : "ip", "lr", "cc")
#define put_user(x,p) \ #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);\ const register typeof(*(p)) __user *__p asm("r0") = (p);\
register int __e asm("r0"); \ register int __e asm("r0"); \
switch (sizeof(*(__p))) { \ switch (sizeof(*(__p))) { \
case 1: \ case 1: \
__put_user_x(__r1, __p, __e, 1); \ __put_user_x(__r2, __p, __e, 1); \
break; \ break; \
case 2: \ case 2: \
__put_user_x(__r1, __p, __e, 2); \ __put_user_x(__r2, __p, __e, 2); \
break; \ break; \
case 4: \ case 4: \
__put_user_x(__r1, __p, __e, 4); \ __put_user_x(__r2, __p, __e, 4); \
break; \ break; \
case 8: \ case 8: \
__put_user_x(__r1, __p, __e, 8); \ __put_user_x(__r2, __p, __e, 8); \
break; \ break; \
default: __e = __put_user_bad(); 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