This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: An ia32 LOCK/XADD bug.


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));


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]