microblaze: uaccess.h: Fix timerfd syscall
authorMichal Simek <monstr@monstr.eu>
Mon, 15 Oct 2012 09:49:22 +0000 (11:49 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Thu, 13 Dec 2012 13:38:53 +0000 (14:38 +0100)
__pu_val must be volatile to ensure that the value is not lost.

It was causing the problem with timerfd syscall
where using inline asm at the end of function call doesn't
save u64 bit value to the stack.
In comparison both cases you can find out this fragment
where you can see the first part which is saved u64
value to stack and then using it in __put_user_asm_8 macro.
Origin broken implementation misses the first two swi instructions.

swi r22, r1, 28 /* missing without volatile */
swi r23, r1, 32
...
addik r4, r1, 28
lwi r3, r4, 0
swi r3, r25, 0
lwi r3, r4, 4
swi r3, r25, 4
addk r3, r0, r0

NOTE: Moving __put_val initialization after declaration
has not impact on this bug. It is just coding style issue.

Signed-off-by: Michal Simek <monstr@monstr.eu>
arch/microblaze/include/asm/uaccess.h

index ef25f7538d4a04090180c1062b5d1c965d06156e..927540d3cb7d1ee9ddb62a6b1b0915f758dc8761 100644 (file)
@@ -298,11 +298,10 @@ extern long __user_bad(void);
 
 #define __put_user_check(x, ptr, size)                                 \
 ({                                                                     \
-       typeof(*(ptr)) __pu_val;                                        \
+       typeof(*(ptr)) volatile __pu_val = x;                                   \
        typeof(*(ptr)) __user *__pu_addr = (ptr);                       \
        int __pu_err = 0;                                               \
                                                                        \
-       __pu_val = (x);                                                 \
        if (access_ok(VERIFY_WRITE, __pu_addr, size)) {                 \
                switch (size) {                                         \
                case 1:                                                 \