Subject: bug in _atomic_cas_64 ?
To: None <port-amd64@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: port-amd64
Date: 12/10/2007 13:16:01
--gKMricLos+KVdGMg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,
after updating my source tree I found I couldn't boot a amd64 XEN kernel
any more, it failed very early with a rwlock assertion failure. Looking
closer I found the owner field of the rwlock was tructated to 32bits, and
I found _atomic_cas_64 was using a 32bit register. Is the attached patch
correct ?

-- 
Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
     NetBSD: 26 ans d'experience feront toujours la difference
--

--gKMricLos+KVdGMg
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff

Index: lib/libc/arch/x86_64/atomic/atomic.S
===================================================================
RCS file: /cvsroot/src/common/lib/libc/arch/x86_64/atomic/atomic.S,v
retrieving revision 1.6
diff -u -r1.6 atomic.S
--- lib/libc/arch/x86_64/atomic/atomic.S	9 Dec 2007 17:33:56 -0000	1.6
+++ lib/libc/arch/x86_64/atomic/atomic.S	10 Dec 2007 12:13:12 -0000
@@ -210,7 +210,7 @@
 NENTRY(_atomic_cas_64)
 	movq	%rsi, %rax
 	LOCK(24)
-	cmpxchgl %edx, (%rdi)
+	cmpxchgq %rdx, (%rdi)
 	/* %eax now contains the old value */
 	ret
 

--gKMricLos+KVdGMg--