This is the mail archive of the glibc-bugs@sourceware.org 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]
Other format: [Raw text]

[Bug libc/18034] [aarch64] Lazy TLSDESC relocation has data race


https://sourceware.org/bugzilla/show_bug.cgi?id=18034

--- Comment #5 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  c71c89e5c72baf43fd44d08dda8ab846eec5b1d6 (commit)
       via  08325735c2efb0257b8c07ac0ff91e44c27ecbf8 (commit)
      from  2a8c2c7b335ed07f63c246077fa672d8eaed23e4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c71c89e5c72baf43fd44d08dda8ab846eec5b1d6

commit c71c89e5c72baf43fd44d08dda8ab846eec5b1d6
Author: Szabolcs Nagy <nsz@port70.net>
Date:   Wed Jun 17 12:44:53 2015 +0100

    [AArch64] Fix cfi_adjust_cfa_offset usage in dl-tlsdesc.S

    Some of the cfi annotations used incorrect sign.

        * sysdeps/aarch64/dl-tlsdesc.S (_dl_tlsdesc_return_lazy): Fix
        cfi_adjust_cfa_offset argument.
        (_dl_tlsdesc_undefweak, _dl_tlsdesc_dynamic): Likewise.
        (_dl_tlsdesc_resolve_rela, _dl_tlsdesc_resolve_hold): Likewise.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=08325735c2efb0257b8c07ac0ff91e44c27ecbf8

commit 08325735c2efb0257b8c07ac0ff91e44c27ecbf8
Author: Szabolcs Nagy <nsz@port70.net>
Date:   Wed Jun 17 12:37:49 2015 +0100

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

    Lazy TLSDESC initialization needs to be synchronized with concurrent TLS
    accesses.  The TLS descriptor contains a function pointer (entry) and an
    argument that is accessed from the entry function.  With lazy
initialization
    the first call to the entry function updates the entry and the argument to
    their final value.  A final entry function must make sure that it accesses
an
    initialized argument, this needs synchronization on systems with weak
memory
    ordering otherwise the writes of the first call can be observed out of
order.

    There are at least two issues with the current code:

    tlsdesc.c (i386, x86_64, arm, aarch64) uses volatile memory accesses on the
    write side (in the initial entry function) instead of C11 atomics.

    And on systems with weak memory ordering (arm, aarch64) the read side
    synchronization is missing from the final entry functions (dl-tlsdesc.S).

    This patch only deals with aarch64.

    * Write side:

    Volatile accesses were replaced with C11 relaxed atomics, and a release
    store was used for the initialization of entry so the read side can
    synchronize with it.

    * Read side:

    TLS access generated by the compiler and an entry function code is roughly

      ldr x1, [x0]    // load the entry
      blr x1          // call it

    entryfunc:
      ldr x0, [x0,#8] // load the arg
      ret

    Various alternatives were considered to force the ordering in the entry
    function between the two loads:

    (1) barrier

    entryfunc:
      dmb ishld
      ldr x0, [x0,#8]

    (2) address dependency (if the address of the second load depends on the
    result of the first one the ordering is guaranteed):

    entryfunc:
      ldr x1,[x0]
      and x1,x1,#8
      orr x1,x1,#8
      ldr x0,[x0,x1]

    (3) load-acquire (ARMv8 instruction that is ordered before subsequent
    loads and stores)

    entryfunc:
      ldar xzr,[x0]
      ldr x0,[x0,#8]

    Option (1) is the simplest but slowest (note: this runs at every TLS
    access), options (2) and (3) do one extra load from [x0] (same address
    loads are ordered so it happens-after the load on the call site),
    option (2) clobbers x1 which is problematic because existing gcc does
    not expect that, so approach (3) was chosen.

    A new _dl_tlsdesc_return_lazy entry function was introduced for lazily
    relocated static TLS, so non-lazy static TLS can avoid the synchronization
    cost.

        [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.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                    |   20 +++++++++++++++++
 NEWS                         |   14 ++++++------
 elf/tlsdeschtab.h            |    8 ++++--
 sysdeps/aarch64/dl-tlsdesc.S |   47 +++++++++++++++++++++++++++++++++++++----
 sysdeps/aarch64/dl-tlsdesc.h |    3 ++
 sysdeps/aarch64/tlsdesc.c    |   36 +++++++++++++++++++++----------
 6 files changed, 101 insertions(+), 27 deletions(-)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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