[PATCH] [BZ 18034] [AArch64] Lazy TLSDESC relocation data race fix

Szabolcs Nagy szabolcs.nagy@arm.com
Mon Jun 1 10:25:00 GMT 2015


On 27/05/15 14:02, Torvald Riegel wrote:
> On Wed, 2015-05-27 at 12:27 +0100, Szabolcs Nagy wrote:
>> On 26/05/15 21:37, Torvald Riegel wrote:
>>> This should have relaxed atomic accesses for all things concurrently
>>> accessed.  As a result, you can drop the volatile qualification I

removed volatile from aarch64 tlsdesc.c, but kept it in
elf/tlsdeschtab.h for now.

>>> You should also document why the relaxed MO load in
>>> _dl_tlsdesc_resolve_early_return_p is sufficient (see the other part of

i added a comment to the _dl_tlsdesc_resolve_early_return_p
call in aarch64 tlsdesc.c about the retry loop.

attached the updated patch:

- The c code now follows the glibc concurrency guidelines
(using relaxed atomics instead of volatile and release store
instead of barrier on the write side).
- Fixed the atomics in elf/tlsdeschtab.h too.
- Updated the comments.

the write is side now compiled to: (stlr has store-release semantics)

 158:   91002261        add     x1, x19, #0x8
 15c:   f9000020        str     x0, [x1]
 160:   90000000        adrp    x0, 0 <_dl_tlsdesc_return_lazy>
                        160: R_AARCH64_ADR_PREL_PG_HI21 _dl_tlsdesc_return_lazy
 164:   91000000        add     x0, x0, #0x0
                        164: R_AARCH64_ADD_ABS_LO12_NC  _dl_tlsdesc_return_lazy
 168:   c89ffe60        stlr    x0, [x19]

the read side is: (ldar has load-acquire semantics)

0000000000000008 <_dl_tlsdesc_return_lazy>:
   8:   c8dffc1f        ldar    xzr, [x0]
   c:   f9400400        ldr     x0, [x0,#8]
  10:   d65f03c0        ret

Changelog:

2015-06-01  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	[BZ #18034]
	* sysdeps/aarch64/dl-tlsdesc.h (_dl_tlsdesc_return_lazy): Declare.
	* sysdeps/aarch64/dl-tlsdesc.S (_dl_tlsdesc_return_lazy): Define.
	(_dl_tlsdesc_undefweak): Guarantee TLSDESC entry and argument load-load
	ordering using ldar.
	(_dl_tlsdesc_dynamic): Likewise.
	(_dl_tlsdesc_return_lazy): Likewise.
	* sysdeps/aarch64/tlsdesc.c (_dl_tlsdesc_resolve_rela_fixup): Use
	relaxed atomics instead of volatile and synchronize with release store.
	(_dl_tlsdesc_resolve_hold_fixup): Use relaxed atomics instead of
	volatile.
	* elf/tlsdeschtab.h (_dl_tlsdesc_resolve_early_return_p): Likewise.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tlsdesc-v3.diff
Type: text/x-patch
Size: 6670 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20150601/1411f092/attachment.bin>


More information about the Libc-alpha mailing list