An ia32 LOCK/XADD bug.
Roland McGrath
roland@frob.com
Thu May 17 01:02:00 GMT 2001
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));
More information about the Libc-alpha
mailing list