arm: fix atomic_{add,sub}_return

Submitted by Andrei Vagin on April 21, 2019, 8:32 a.m.

Details

Message ID 20190421083237.32652-1-avagin@gmail.com
State Accepted
Series "arm: fix atomic_{add,sub}_return"
Commit 5412247572763ba6bc32b08b20e45aa6a81e286f
Headers show

Commit Message

Andrei Vagin April 21, 2019, 8:32 a.m.
Now, this code doesn't pass this simple test:

        atomic_t a;;
        int c = 0;
        atomic_set(&a, c);
        c = atomic_inc(&a);
        if (c != 0) {
                pr_err("c = %x &a = %p\n", c, &a);
                return 1;
        }

08:28:51.771: 26187: ERR: fd.c:36: c = 7ef47a60 &a = 0x7ef47a60

Reported-by: Mr Jenkins
Signed-off-by: Andrei Vagin <avagin@gmail.com>
---
 test/zdtm/lib/arch/arm/include/asm/atomic.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/test/zdtm/lib/arch/arm/include/asm/atomic.h b/test/zdtm/lib/arch/arm/include/asm/atomic.h
index bcf3fe31b..0ff76408d 100644
--- a/test/zdtm/lib/arch/arm/include/asm/atomic.h
+++ b/test/zdtm/lib/arch/arm/include/asm/atomic.h
@@ -25,8 +25,8 @@  static inline unsigned int atomic_add_return(int i, atomic_t *v)
 "	strex	%1, %0, [%3]\n"
 "	teq	%1, #0\n"
 "	bne	1b\n"
-	: "=&r" (result), "=&r" (tmp), "+Qo" (v)
-        : "r" (&v), "Ir" (i)
+	: "=&r" (result), "=&r" (tmp), "+Qo" (*v)
+        : "r" (v), "Ir" (i)
 	: "cc");
 
 	smp_mb();
@@ -47,8 +47,8 @@  static inline unsigned int atomic_sub_return(int i, atomic_t *v)
 "	strex	%1, %0, [%3]\n"
 "	teq	%1, #0\n"
 "	bne	1b\n"
-	: "=&r" (result), "=&r" (tmp), "+Qo" (v)
-	: "r" (&v), "Ir" (i)
+	: "=&r" (result), "=&r" (tmp), "+Qo" (*v)
+	: "r" (v), "Ir" (i)
 	: "cc");
 
 	smp_mb();

Comments

Dmitry Safonov April 23, 2019, 2:28 p.m.
On Sun, 21 Apr 2019 at 09:33, Andrei Vagin <avagin@gmail.com> wrote:
>
> Now, this code doesn't pass this simple test:
>
>         atomic_t a;;
>         int c = 0;
>         atomic_set(&a, c);
>         c = atomic_inc(&a);
>         if (c != 0) {
>                 pr_err("c = %x &a = %p\n", c, &a);
>                 return 1;
>         }
>
> 08:28:51.771: 26187: ERR: fd.c:36: c = 7ef47a60 &a = 0x7ef47a60
>
> Reported-by: Mr Jenkins
> Signed-off-by: Andrei Vagin <avagin@gmail.com>

Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>

P.S.
Oops, I should have noted this at that time:
https://lists.openvz.org/pipermail/criu/2018-June/041611.html
(commit 19de949023af)

> ---
>  test/zdtm/lib/arch/arm/include/asm/atomic.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/test/zdtm/lib/arch/arm/include/asm/atomic.h b/test/zdtm/lib/arch/arm/include/asm/atomic.h
> index bcf3fe31b..0ff76408d 100644
> --- a/test/zdtm/lib/arch/arm/include/asm/atomic.h
> +++ b/test/zdtm/lib/arch/arm/include/asm/atomic.h
> @@ -25,8 +25,8 @@ static inline unsigned int atomic_add_return(int i, atomic_t *v)
>  "      strex   %1, %0, [%3]\n"
>  "      teq     %1, #0\n"
>  "      bne     1b\n"
> -       : "=&r" (result), "=&r" (tmp), "+Qo" (v)
> -        : "r" (&v), "Ir" (i)
> +       : "=&r" (result), "=&r" (tmp), "+Qo" (*v)
> +        : "r" (v), "Ir" (i)
>         : "cc");
>
>         smp_mb();
> @@ -47,8 +47,8 @@ static inline unsigned int atomic_sub_return(int i, atomic_t *v)
>  "      strex   %1, %0, [%3]\n"
>  "      teq     %1, #0\n"
>  "      bne     1b\n"
> -       : "=&r" (result), "=&r" (tmp), "+Qo" (v)
> -       : "r" (&v), "Ir" (i)
> +       : "=&r" (result), "=&r" (tmp), "+Qo" (*v)
> +       : "r" (v), "Ir" (i)
>         : "cc");
>
>         smp_mb();
> --
> 2.20.1
>
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu