[CRIU] [PATCH] arm: fix atomic_{add,sub}_return

Andrei Vagin avagin at gmail.com
Sun Apr 21 11:32:37 MSK 2019


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 at gmail.com>
---
 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



More information about the CRIU mailing list