This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: An ia32 LOCK/XADD bug.
- To: Ulrich Drepper <drepper at cygnus dot com>
- Subject: Re: An ia32 LOCK/XADD bug.
- From: "H . J . Lu" <hjl at lucon dot org>
- Date: Thu, 17 May 2001 00:35:57 -0700
- Cc: GNU C Library <libc-alpha at sourceware dot cygnus dot com>,binutils at sourceware dot cygnus dot com
- References: <20010516125536.A6006@lucon.org> <20010517001556.B16213@lucon.org> <m3heykmo00.fsf@otr.mynet>
On Thu, May 17, 2001 at 12:30:07AM -0700, Ulrich Drepper wrote:
> "H . J . Lu" <hjl@lucon.org> writes:
>
> > is an illegal instruction on ia32. I cannot find anything in Intel
> > reference manual to say you cannot have LOCK on insn where DST/SRC are
> > reg or same. My questions are
>
> It is definitely illegal. The lock prefix works on the part of the
> processor which handles memory access.
>
> The problem I have is to see where you actually find this code in glibc.
sysdeps/i386/i486/atomicity.h.
>
> > 1. How to write a correct exchange_and_add? Is exchange_and_add_1 ok?
>
> This is exactly what we do in sysdeps/i386/i486/atomicity.h.
Please take a second look and take a few more seconds. What a patch?
Ok, no ChangeLog entry.
>
> > 2. If "lock xadd %edx,%edx" is really an illegal instruction on ia32,
> > how should we fix gas to detect that?
>
> Some IA-32 specific code has to check that an instruction with a lock
> prefix always has a memory operand. Don't know where to insert this.
>
It may be tough. I can put in some testcases to make gas to fail :-).
H.J.
---
--- sysdeps/i386/i486/atomicity.h.ill Sat Apr 7 00:28:07 2001
+++ sysdeps/i386/i486/atomicity.h Thu May 17 00:29:21 2001
@@ -28,7 +28,7 @@ __attribute__ ((unused))
exchange_and_add (volatile uint32_t *mem, uint32_t val)
{
register uint32_t result;
- __asm__ __volatile__ ("lock; xaddl %0,%2"
+ __asm__ __volatile__ ("lock; xaddl %0,%1"
: "=r" (result), "=m" (*mem) : "0" (val), "1" (*mem));
return result;
}