NetBSD Problem Report #48635
From www@NetBSD.org Tue Mar 4 03:26:34 2014
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id CF5E2A583A
for <gnats-bugs@gnats.NetBSD.org>; Tue, 4 Mar 2014 03:26:33 +0000 (UTC)
Message-Id: <20140304032631.D61AAA64B7@mollari.NetBSD.org>
Date: Tue, 4 Mar 2014 03:26:31 +0000 (UTC)
From: dennis.c.ferguson@gmail.com
Reply-To: dennis.c.ferguson@gmail.com
To: gnats-bugs@NetBSD.org
Subject: ARM atomic_cas_64() probably not working
X-Send-Pr-Version: www-1.0
>Number: 48635
>Category: port-arm
>Synopsis: ARM atomic_cas_64() probably not working
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: port-arm-maintainer
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Mar 04 03:30:00 +0000 2014
>Closed-Date: Wed Mar 05 21:16:51 +0000 2014
>Last-Modified: Wed Mar 05 21:16:51 +0000 2014
>Originator: Dennis Ferguson
>Release: 6.99.33
>Organization:
none at all
>Environment:
NetBSD beagle10.to.akit-ferguson.com 6.99.31 NetBSD 6.99.31 (BEAGLEBONE) #1: Sun Feb 16 03:15:09 EST 2014 root@b1.to.mistimed.ca:/build/beagle/obj/sys/arch/evbarm/compile/BEAGLEBONE evbarm
>Description:
In common/lib/libc/arch/arm/atomic/atomic_cas_64.S, the start
of the function pushes 3 registers onto the stack and then
loads the third function argument from the stack into 2 of
those registers, i.e.
ENTRY_NP(_atomic_cas_64)
push {r4, r5, r6} /* save temporaries */
mov ip, r0 /* we need r0 for return value */
#ifdef __ARM_EABI__
ldrd r4, r5, [sp] /* fetch new value */
#else
ldr r4, [sp, #0] /* fetch new value */
ldr r5, [sp, #4] /* fetch new value */
The problem is that while "new value" was at the top (bottom?)
of the stack when the function was entered it is 12 bytes offset
from there by the time the code loads it.
I also noticed that every other function in source files
in this directory pushes an even number of registers on the stack,
even at the expense of unnecessarily saving an extra register,
but this one only pushes 3 registers. I don't know if that's
a problem or not; the patch below assumes it isn't.
>How-To-Repeat:
Noticed by inspection.
>Fix:
Index: common/lib/libc/arch/arm/atomic/atomic_cas_64.S
===================================================================
RCS file: /cvsroot/src/common/lib/libc/arch/arm/atomic/atomic_cas_64.S,v
retrieving revision 1.5
diff -u -r1.5 atomic_cas_64.S
--- common/lib/libc/arch/arm/atomic/atomic_cas_64.S 30 Nov 2013 21:09:11 -0000 1.5
+++ common/lib/libc/arch/arm/atomic/atomic_cas_64.S 4 Mar 2014 03:15:40 -0000
@@ -39,10 +39,10 @@
push {r4, r5, r6} /* save temporaries */
mov ip, r0 /* we need r0 for return value */
#ifdef __ARM_EABI__
- ldrd r4, r5, [sp] /* fetch new value */
+ ldrd r4, r5, [sp, #12] /* fetch new value */
#else
- ldr r4, [sp, #0] /* fetch new value */
- ldr r5, [sp, #4] /* fetch new value */
+ ldr r4, [sp, #12] /* fetch new value */
+ ldr r5, [sp, #16] /* fetch new value */
mov r3, r2 /* r2 will be overwritten by r1 which ... */
mov r2, r1 /* r1 will be overwritten by ldrexd */
#endif
>Release-Note:
>Audit-Trail:
From: "Matt Thomas" <matt@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/48635 CVS commit: src/common/lib/libc/arch/arm/atomic
Date: Tue, 4 Mar 2014 03:50:37 +0000
Module Name: src
Committed By: matt
Date: Tue Mar 4 03:50:37 UTC 2014
Modified Files:
src/common/lib/libc/arch/arm/atomic: atomic_cas_64.S
Log Message:
Fix non-EABI loading of argument. Deal with endian issues.
Fixes PR/48635
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/common/lib/libc/arch/arm/atomic/atomic_cas_64.S
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->feedback
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Tue, 04 Mar 2014 07:53:45 +0000
State-Changed-Why:
Fixed by matt's patch?
From: Dennis Ferguson <dennis.c.ferguson@gmail.com>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-arm/48635 (ARM atomic_cas_64() probably not working)
Date: Wed, 5 Mar 2014 15:45:31 -0500
On 4 Mar, 2014, at 02:53 , wiz@NetBSD.org wrote:
> State-Changed-Why:
> Fixed by matt's patch?
Yes, thanks. It is good the way it is now.
State-Changed-From-To: feedback->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Wed, 05 Mar 2014 21:16:51 +0000
State-Changed-Why:
Confirmed fixed, thanks for your help!
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.