From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id iCKmNUaBCWc2JwoAWB0awg (envelope-from ) for ; Fri, 11 Oct 2024 15:49:26 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RUcz72kv; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id AD9C31E358; Fri, 11 Oct 2024 15:49:26 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-7.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,URIBL_BLOCKED,URIBL_DBL_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E9A181E05C for ; Fri, 11 Oct 2024 15:49:25 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8B072385772C for ; Fri, 11 Oct 2024 19:49:25 +0000 (GMT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 54A0B3858D26 for ; Fri, 11 Oct 2024 19:49:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 54A0B3858D26 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 54A0B3858D26 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728676149; cv=none; b=IUadUtxRx6uXRFVN2XvmIulgMOCMEQMAU8e7m9qlfh+iClsXErahN3pc5SJQLYU8cwvODuzcLIlED9yjRjdZSfCBawOCFIrZqSKmkDmNfltH38+3zAnuxrawVrwUw5Gy9a/UfJFaXT389quSknaL6mtuVx2aTB+A/YxmfrzYNm8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728676149; c=relaxed/simple; bh=PhQGENXu0jD520cz9aBIdvSfLztE6SvRh9EfXW5W5kE=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=mRxy2cEOKaxH8uzIwS+TlznENFNoAl1Pa0P4KfQESF5IyHGkTQsPMUoapA25TwLwZ/JuRG4TbWLHhzh5KnlRnP3446ETrCEXLHuisGUiLfCjb6uD9Ll0pGH2kGE6Np3DABhl87p6jBs9L0sK8H1teXVf/PdaQyFTtw++IP1jls0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728676147; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CcGxbbAkVsFBqlIvYgfwOyPDHzEQ3oCg0fPyW7vxE9Q=; b=RUcz72kvirpKGiL+967eryHgCr/fQc/ENTAcUm9x/jj3+yyf8HeWZIqVfnDFfLqz4OMI5R 8Ai1BfbaPWnmNf2dZvoV3+NT4xgG4yrnyN5BAVWzJIVIFL3ei0nqeC60a3ST+CMzDnJp7R 8r5zd+Qj0GR1M5sUmNw48zPEeuhysUs= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-113-0_JWJSXZPX6C1fV6euiP7g-1; Fri, 11 Oct 2024 15:49:04 -0400 X-MC-Unique: 0_JWJSXZPX6C1fV6euiP7g-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CC80D1944F03; Fri, 11 Oct 2024 19:48:59 +0000 (UTC) Received: from f40-zbm-amd (unknown [10.22.64.14]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E20301955EA1; Fri, 11 Oct 2024 19:48:58 +0000 (UTC) Date: Fri, 11 Oct 2024 12:48:54 -0700 From: Kevin Buettner To: Luis Machado Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 05/11] Internal TLS support for aarch64, x86_64, riscv, ppc64, and s390x Message-ID: <20241011124854.118126cb@f40-zbm-amd> In-Reply-To: <2e2cd12e-4b1d-45db-92f8-ed37ef469fbb@arm.com> References: <20241010022552.47637-1-kevinb@redhat.com> <20241010022552.47637-6-kevinb@redhat.com> <2e2cd12e-4b1d-45db-92f8-ed37ef469fbb@arm.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On Fri, 11 Oct 2024 09:12:55 +0100 Luis Machado wrote: > Thanks for the patch. > > On 10/10/24 03:16, Kevin Buettner wrote: > > For each architecture, aarch64, x86_64, riscv, ppc64, and s390x, > > this commit defines a suitable 'get_tls_dtv_addr' method and, > > when necessary, a 'get_tls_dtp_offset' method. > > > > It also registers linux_get_thread_local_address, defined in > > linux-tdep.c (in an earlier commit), as the get_thread_local_address > > gdbarch method. It also registers its architecture specific code > > using linux_register_tls_methods(). > > > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24548 > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31563 > > --- > > gdb/aarch64-linux-tdep.c | 53 +++++++++++++++++++++++++++ > > gdb/amd64-linux-tdep.c | 37 +++++++++++++++++++ > > gdb/ppc-linux-tdep.c | 62 ++++++++++++++++++++++++++++++++ > > gdb/riscv-linux-tdep.c | 78 ++++++++++++++++++++++++++++++++++++++++ > > gdb/s390-linux-tdep.c | 43 ++++++++++++++++++++++ > > 5 files changed, 273 insertions(+) > > > > diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c > > index c608a84bc71..b03c2162a1a 100644 > > --- a/gdb/aarch64-linux-tdep.c > > +++ b/gdb/aarch64-linux-tdep.c > > @@ -35,6 +35,7 @@ > > #include "target/target.h" > > #include "expop.h" > > #include "auxv.h" > > +#include "inferior.h" > > > > #include "regcache.h" > > #include "regset.h" > > @@ -2693,6 +2694,55 @@ aarch64_use_target_description_from_corefile_notes (gdbarch *gdbarch, > > return true; > > } > > > > +/* Fetch and return the TLS DTV (dynamic thread vector) address for PTID. > > + Throw a suitable TLS error if something goes wrong. */ > > + > > +static CORE_ADDR > > +aarch64_linux_get_tls_dtv_addr (struct gdbarch *gdbarch, ptid_t ptid, > > + linux_libc libc) > > +{ > > + /* On aarch64, the thread pointer is found in the tpidr register. */ > > + regcache *regcache > > + = get_thread_arch_regcache (current_inferior (), ptid, gdbarch); > > + aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); > > + target_fetch_registers (regcache, tdep->tls_regnum_base); > > + ULONGEST thr_ptr; > > + if (regcache->cooked_read (tdep->tls_regnum_base, &thr_ptr) != REG_VALID) > > Since we're relying on TPIDR now, might be worth mentioning it is currently the > first register in the TLS feature. Just in case things change later on? I've changed the relevant comment in my local sources to read as follows: /* On aarch64, the thread pointer is found in the TPIDR register. Note that this is the first register in the TLS feature - see features/aarch64-tls.c - and it will always be present. */ Kevin