This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: An ia32 LOCK/XADD bug.
- To: "H . J . Lu" <hjl at lucon dot org>
- Subject: Re: An ia32 LOCK/XADD bug.
- From: Roland McGrath <roland at frob dot com>
- Date: Thu, 17 May 2001 04:03:31 -0400 (EDT)
- Cc: GNU C Library <libc-alpha at sourceware dot cygnus dot com>, binutils at sourceware dot cygnus dot com
Well, my manual from Intel has a description of XADD that says, "This
instruction can be used with a LOCK prefix." When I tried it just now,
"lock; xadd" does work when one of the operands is a memory reference
rather than both operands being registers.
The assembly code you showed for exchange_and_add_2 is clearly not useful
for any kind of atomic memory update, since it only operates on registers.
I would be more worried about that than exactly which pointless xadd
instructions generate faults.
It looks to me like exchange_and_add is broken.
It reads:
__asm__ __volatile__ ("lock; xaddl %0,%2"
: "=r" (result), "=m" (*mem) : "0" (val), "1"
(*mem));
where it should read:
__asm__ __volatile__ ("lock; xaddl %0,%1"
: "=r" (result), "=m" (*mem) : "0" (val), "1"
(*mem));