Skip to contentSkip to conversation

ARM v6/v7 cmpxchg64 shouldn't clear upper 32 bits of the old/new value

PATCH Superseded Will Deacon 1 participant 3 messages May 8, 2013 – May 10, 2013 2 messages not in the archive

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 ARM v6/v7 cmpxchg64 shouldn't clear upper 32 bits of the old/new value

In reply to a message not in the archive
Quoted 9 lines · jaccon.bastiaansen at gmail.com

From: Jaccon Bastiaansen <[email protected]>

The implementation of cmpxchg64() for the ARM v6 and v7 architecture casts parameter 2 and 3 (the old and new 64bit values) to an unsigned long before calling the atomic_cmpxchg64() function. This clears the top 32 bits of the old and new values, resulting in the wrong values being compare-exchanged.

This bug is introduced by commit 3e0f5a15f5003f4576c35498814f0f1567860449

Please truncate the commit id to 12 characters and stick the title string in brackets afterwards, e.g. 123456789abc ("will's broken commit"),

Quoted 1 line

Change-Id: I8e8a4c09c525ed8056385c9dc4d65163c28307dc

You can drop the Change-Id.

Quoted 18 lines
---
 arch/arm/include/asm/cmpxchg.h |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/include/asm/cmpxchg.h +2 -2
index 7eb18c1..4f009c1 100644
@@ -233,15 +233,15 @@ static inline unsigned long __cmpxchg_local(volatile void *ptr,
 	((__typeof__(*(ptr)))atomic64_cmpxchg(container_of((ptr),	\
 						atomic64_t,		\
 						counter),		\
-					      (unsigned long)(o),	\
-					      (unsigned long)(n)))
+					      (unsigned long long)(o),	\
+					      (unsigned long long)(n)))
 

arch/arm/include/asm/cmpxchg.h static inline unsigned long __cmpxchg_local(volatile void *ptr, · line 246

Quoted 10 lines
arch/arm/include/asm/cmpxchg.h +2 -2
 #define cmpxchg64_local(ptr, o, n)					\
 	((__typeof__(*(ptr)))local64_cmpxchg(container_of((ptr),	\
 						local64_t,		\
 						a),			\
-					     (unsigned long)(o),	\
-					     (unsigned long)(n)))
+					     (unsigned long long)(o),	\
+					     (unsigned long long)(n)))
 
 #endif	/* __LINUX_ARM_ARCH__ >= 6 */

With the above cleanup:

Will

#3 lore raw

PATCH v2 1/1 ARM v6/v7 cmpxchg64 shouldn't clear upper 32 bits of the old/new value

In reply to a message not in the archive
Quoted 7 lines · Jaccon Bastiaansen

The implementation of cmpxchg64() for the ARM v6 and v7 architecture casts parameter 2 and 3 (the old and new 64bit values) to an unsigned long before calling the atomic_cmpxchg64() function. This clears the top 32 bits of the old and new values, resulting in the wrong values being compare-exchanged.

This bug is introduced by commit 3e0f5a15f500 (ARM: 7404/1: cmpxchg64: use atomic64

Best to line-wrap this at 76 chars.

Quoted 3 lines

and local64 routines for cmpxchg64)

Please add the following above your S-o-B:

Then below your S-o-B, add:

KernelVersion: 3.9

and send the patch to patches at arm.linux.org.uk

Cheers,

Will

#4 lore raw

PATCH v2 1/1 ARM v6/v7 cmpxchg64 shouldn't clear upper 32 bits of the old/new value

Hi Jaccon,

Quoted 17 lines · Will Deacon
Quoted 7 lines · Jaccon Bastiaansen

The implementation of cmpxchg64() for the ARM v6 and v7 architecture casts parameter 2 and 3 (the old and new 64bit values) to an unsigned long before calling the atomic_cmpxchg64() function. This clears the top 32 bits of the old and new values, resulting in the wrong values being compare-exchanged.

This bug is introduced by commit 3e0f5a15f500 (ARM: 7404/1: cmpxchg64: use atomic64

Best to line-wrap this at 76 chars.

Quoted 3 lines

and local64 routines for cmpxchg64)

Please add the following above your S-o-B:

Quoted 8 lines

Then below your S-o-B, add:

KernelVersion: 3.9

and send the patch to patches at arm.linux.org.uk

Did you manage to do this? I can't see anything pending or queued in rmk's tree...

Cheers,

Will