public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
	libc-alpha@sourceware.org, Rui Ueyama <rui314@gmail.com>,
	Rui Ueyama <ruiu@bluewhale.systems>,
	schwab@linux-m68k.org, Andrew Waterman <andrew@sifive.com>,
	Florian Weimer <fweimer@redhat.com>
Subject: Re: [PATCH v6 0/3] RISC-V: Implement TLS Descriptors.
Date: Wed, 1 May 2024 10:36:36 +0900	[thread overview]
Message-ID: <09A14C77-9EEA-4707-9E36-D3AAF8A98B24@gmail.com> (raw)
In-Reply-To: <b0c7d88a-307f-4d94-9e47-1b1487c6f7c9@linaro.org>

> On May 1, 2024, at 3:33, Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> wrote:
> 
> On 30/04/24 14:05, Palmer Dabbelt wrote:
>> On Thu, 28 Mar 2024 23:18:31 PDT (-0700), ishitatsuyuki@gmail.com wrote:
>>> This patchset implements TLS Descriptors (TLSDESC) for RISC-V targets, per
>>> the ratified specification at [1].
>>> 
>>> Partial support for TLSDESC is in binutils trunk. In [2] there is
>>> additional support for relaxation which is required to pass
>>> tst-tls1-static. GCC needs to be patched with [3].
>>> 
>>> Passes binutils and gcc tests for rv32gcv and rv64gcv. For glibc I only
>>> tested elf/ as other subsystems sometimes doesn't work well under qemu.
>>> 
>>> This contribution is made on behalf of Blue Whale Systems, which has
>>> copyright assignment on file with the FSF.
>>> 
>>> v2: Fix end-of-file newlines.
>>> v3: Fix segfaulting on the slow path of TLSDESC resolver.
>>>     Fix handling of lazy relocations.
>>> v4: Fix compiler warnings.
>>>     Fix fast path stack alignment pointed out by Andrew.
>>>     Fix style issues pointed out by Adhemerval.
>>>     Include 2 missing prerequisite commits.
>>>     Update localplt list.
>>> v5: Add stubs for save/restore of vector registers.
>>>     Add comments and reordered sections for readability in the TLSDESC assembly.
>>>     Add clobber test sequence for tst-gnu2-tls2.
>>> v6: Fix R_RISCV_NUM.
>>>     Elaborate on the include guard commit (thanks Fangrui).
>>> 
>>> [1]: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373
>>> [2]: https://inbox.sourceware.org/binutils/20240220175556.304692-1-ishitatsuyuki@gmail.com/
>>> [3]: https://inbox.sourceware.org/gcc-patches/20240329055239.29719-1-ishitatsuyuki@gmail.com/
>>> 
>>> Tatsuyuki Ishi (3):
>>>   RISC-V: Add include guard for dl-tls.h.
>>>   RISC-V: Add TLSDESC reloc definitions.
>>>   RISC-V: Implement TLS Descriptors.
>>> 
>>>  elf/elf.h                                   |   7 +-
>>>  sysdeps/riscv/Makefile                      |  10 +
>>>  sysdeps/riscv/dl-lookupcfg.h                |  27 ++
>>>  sysdeps/riscv/dl-machine.h                  |  50 +++-
>>>  sysdeps/riscv/dl-tls.h                      |   4 +
>>>  sysdeps/riscv/dl-tlsdesc.S                  | 269 ++++++++++++++++++++
>>>  sysdeps/riscv/dl-tlsdesc.h                  |  48 ++++
>>>  sysdeps/riscv/linkmap.h                     |   1 +
>>>  sysdeps/riscv/preconfigure                  |   1 +
>>>  sysdeps/riscv/tlsdesc.c                     |  38 +++
>>>  sysdeps/riscv/tlsdesc.sym                   |  19 ++
>>>  sysdeps/riscv/tst-gnu2-tls2.c               |  33 +++
>>>  sysdeps/unix/sysv/linux/riscv/localplt.data |   2 +
>>>  13 files changed, 507 insertions(+), 2 deletions(-)
>>>  create mode 100644 sysdeps/riscv/dl-lookupcfg.h
>>>  create mode 100644 sysdeps/riscv/dl-tlsdesc.S
>>>  create mode 100644 sysdeps/riscv/dl-tlsdesc.h
>>>  create mode 100644 sysdeps/riscv/tlsdesc.c
>>>  create mode 100644 sysdeps/riscv/tlsdesc.sym
>>>  create mode 100644 sysdeps/riscv/tst-gnu2-tls2.c
>> 
>> This generally LGTM, but IIUC we're waiting on a glibc-wide decision as to what the stable ABIs should be around TLS before moving forward.
> 
> If I recall correctly, my latest remarks for this patch was:
> 
> 1. Missing gcc/binutils upstream support (usually we wait the patches 
>   to be upstream on the required projects)

For a status update, binutils have partial TLSDESC support (without relaxation) committed and GCC have all the required patches committed. This means tst-tls-static-1 will still fail with upstream toolchain, though.

> 2. Call the internal __tls_get_addr on _dl_tlsdesc_dynamic to avoid
>   the PLT call.

This was a trivial change, and I will include it in the next version.

> 3. Decide how RISCV would like to handle different ABI constraint for
>   the _dl_tlsdesc_dynamic, now that you are moving to support ifunc
>   and thus allowing a more generic glibc build.  You can either make
>   the _dl_tlsdesc_dynamic with multiple ifunc variants (as x86 does),
>   or check the chip support through the riscv_hwprobe on the function
>   itself and only save/restore the support ABI register.

Note that we don’t really have any of the cpu_features scaffolding in RISC-V, so going down the IFUNC route seems a lot more annoying. I’m working on adding a call to riscv_hwprobe in _dl_tlsdesc_dynamic. I need some more time to figure out how to configure user mode QEMU to test all the code paths.

As for TLS ABI decision, it would be good if we decide on a calling convention, but shipping a stub that saves / restores all vector registers should also be OK (which is what the current revision do).

Tatsuyuki

      reply	other threads:[~2024-05-01  1:36 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-17 18:12 [PATCH] " Tatsuyuki Ishi
2023-08-17 18:35 ` Andreas Schwab
2023-09-08 10:55 ` [PATCH v2] " Tatsuyuki Ishi
2023-09-13 17:26 ` [PATCH v3] " Tatsuyuki Ishi
2023-09-13 19:14   ` Adhemerval Zanella Netto
2023-09-14  8:39     ` Tatsuyuki Ishi
2023-09-14 12:09       ` Adhemerval Zanella Netto
2024-01-27  2:22         ` Fangrui Song
2023-09-13 19:07 ` [PATCH] " Andrew Waterman
2023-09-14  8:40 ` [PATCH v4 0/3] " Tatsuyuki Ishi
2023-09-14  8:40   ` [PATCH v4 1/3] RISC-V: Add include guard for dl-tls.h Tatsuyuki Ishi
2024-01-27  1:14     ` Fangrui Song
2023-09-14  8:40   ` [PATCH v4 2/3] RISC-V: Add TLSDESC reloc definitions Tatsuyuki Ishi
2024-01-27  1:12     ` Fangrui Song
2023-09-14  8:40   ` [PATCH v4 3/3] RISC-V: Implement TLS Descriptors Tatsuyuki Ishi
2023-11-23 11:39     ` Florian Weimer
2024-03-29  5:55 ` [PATCH v5 0/3] " Tatsuyuki Ishi
2024-03-29  5:55   ` [PATCH v5 1/3] RISC-V: Add include guard for dl-tls.h Tatsuyuki Ishi
2024-03-29  5:55   ` [PATCH v5 2/3] RISC-V: Add TLSDESC reloc definitions Tatsuyuki Ishi
2024-03-29  5:55   ` [PATCH v5 3/3] RISC-V: Implement TLS Descriptors Tatsuyuki Ishi
2024-03-29  6:18 ` [PATCH v6 0/3] " Tatsuyuki Ishi
2024-03-29  6:18   ` [PATCH v6 1/3] RISC-V: Add include guard for dl-tls.h Tatsuyuki Ishi
2024-04-03 11:48     ` Adhemerval Zanella Netto
2024-03-29  6:18   ` [PATCH v6 2/3] RISC-V: Add TLSDESC reloc definitions Tatsuyuki Ishi
2024-04-03  5:10     ` Fangrui Song
2024-04-03  8:03     ` Andreas Schwab
2024-03-29  6:18   ` [PATCH v6 3/3] RISC-V: Implement TLS Descriptors Tatsuyuki Ishi
2024-04-01 13:23     ` Florian Weimer
2024-04-01 19:29     ` Adhemerval Zanella Netto
2024-04-02  3:36       ` Tatsuyuki Ishi
2024-04-02 13:35         ` Adhemerval Zanella Netto
2024-04-02 15:25           ` Palmer Dabbelt
2024-04-02 15:32             ` Adhemerval Zanella Netto
2024-04-02 16:37               ` Palmer Dabbelt
2024-04-30 17:05   ` [PATCH v6 0/3] " Palmer Dabbelt
2024-04-30 18:33     ` Adhemerval Zanella Netto
2024-05-01  1:36       ` Tatsuyuki Ishi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=09A14C77-9EEA-4707-9E36-D3AAF8A98B24@gmail.com \
    --to=ishitatsuyuki@gmail.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=andrew@sifive.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=palmer@dabbelt.com \
    --cc=rui314@gmail.com \
    --cc=ruiu@bluewhale.systems \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).