From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id 1C1883858D20 for ; Tue, 30 Apr 2024 18:33:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1C1883858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1C1883858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::634 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714502038; cv=none; b=LNP4xpwg7gXuHnYRe72ll6MLsNY9V2J6gB9WBGz6IGMi6JCvwwtWFLBnT1seBlcIewSQ2wns+o1f2POLquwraU41ipFnTRw3K/ZL0R4HKoyplS1UhPuac83mCPEgTbP/c7MQz0QwaemdYQzyCbhCWjQzuB79qWuY2ZZYoYFsmFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714502038; c=relaxed/simple; bh=vRbHIUeD6keQMGFIk920uoKescE+3nCPXZMGiRCy1H4=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=jr192bcFFM8urNzfYLAfnt7QU3riv1FsPDJ/Bdz3l5ZdGGuGT/DFRkLVQzo5dwew66HTEFTAvXSCyCQhi47w1GxT0yxgW0juohruclCGKXfONudIPT9zVOAEaQaMqdlBLH+V5vcwHSlxSDzLlds9kLksIRppnMUbZlAGFf/oiIQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1e2b1cd446fso50850665ad.3 for ; Tue, 30 Apr 2024 11:33:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714502027; x=1715106827; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=/CSMBYwK/5H3j9N3fk9IAOXfI2jS4piZzlFf5amLC+w=; b=so33qMszJc4ZW4ZUMXBtg/zvkXJ6gS+98R4R2Vy+lTlmM0s5wKhbeghlsWB0dA80ct mp9o9BGLoGChAksOBg8DsJwQpL+vQwtxKkt0LtgZdIaVFhZnAyC1Rapy5/HHLvLnIy0x 6O3srk8Y5FROUrj9eE5t7JEaLMeRYFaE89XXHjN30XSd6Ajuh0AtmDs27KVPH5zjzCC5 9R7clgL2YCl7xCOPNZ3zS2i2uL2UsBrPFfn9Zsp3j8xGKmwjl2hA+67Skgyu15EK9UBw hf5Q1GmjsPt8hqQUXLepe15TFuHySpKob31bK8opUhzBLY7cAXX8fl9aMjGNtqCFIYtj 061Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714502027; x=1715106827; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/CSMBYwK/5H3j9N3fk9IAOXfI2jS4piZzlFf5amLC+w=; b=DvzY+TtDOEEmsXcbtgjztBu+a2cgE2XD3qkxZOAXYEvGDG9767+w/ULQg0W+qJ0xyW IbefM7tuyxKJDM+4SaXqSB+7gUvPlgyaWCoj6N59vw0JaPD47DkKNR3Pu1zlLwedA0Bv mBilSEruxXhqOOtTV509xqNmx/aRmgXUec357Pdlo7L6sVKBWRgRR2WHhWY0aRqnvdeM ssjTd9hLLXcejNwxb5koCv7hmSBeg13G3SLdl+3zhxj3zHVe+IYtgzeyMas3F7ejm3xd 36/pzJ++O4mRT2BWUc9VRCPBIvvRhCQmJVinf1lhXmE0Zd8zSCf9gYS4a3PwJ/mae+lT cuSw== X-Gm-Message-State: AOJu0Ywr8I6BAXdVZREI4gjDVBGUXnmS83EqBt2dDFvUgz7PF0U0ws2Z c3YNo87mzRS/Wl1WHHDLbwJdju1oe6zlQt5DXATG1xU/Dy5iRrjB93GpxXdCVb1+hjrbUQTyf7U I X-Google-Smtp-Source: AGHT+IETQuWcm6NYgG9g8SNexhZHvOqPQXO/FBH/lOOoDRom0tQNJmDZB2x1Zigd0RFuRzTO+4OeCg== X-Received: by 2002:a17:902:e88d:b0:1e4:3ed8:e264 with SMTP id w13-20020a170902e88d00b001e43ed8e264mr320896plg.43.1714502026904; Tue, 30 Apr 2024 11:33:46 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c1:e3c5:d5b:1509:7f55:16c2? ([2804:1b3:a7c1:e3c5:d5b:1509:7f55:16c2]) by smtp.gmail.com with ESMTPSA id u1-20020a170902e80100b001e4344a7601sm22757165plg.42.2024.04.30.11.33.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Apr 2024 11:33:46 -0700 (PDT) Message-ID: Date: Tue, 30 Apr 2024 15:33:43 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 0/3] RISC-V: Implement TLS Descriptors. To: Palmer Dabbelt , ishitatsuyuki@gmail.com Cc: libc-alpha@sourceware.org, rui314@gmail.com, ruiu@bluewhale.systems, schwab@linux-m68k.org, Andrew Waterman , fweimer@redhat.com References: Content-Language: en-US From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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) 2. Call the internal __tls_get_addr on _dl_tlsdesc_dynamic to avoid the PLT call. 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.