From nobody Thu Dec 09 21:23:43 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4E75218D0E15; Thu, 9 Dec 2021 21:23:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J96Tq72l0z3Jsx; Thu, 9 Dec 2021 21:23:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6B32A62BE; Thu, 9 Dec 2021 21:23:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1B9LNhdb047050; Thu, 9 Dec 2021 21:23:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B9LNhko047049; Thu, 9 Dec 2021 21:23:43 GMT (envelope-from git) Date: Thu, 9 Dec 2021 21:23:43 GMT Message-Id: <202112092123.1B9LNhko047049@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 4c2f5bfbfa48 - main - libc: Fix the alignment of the TCB to match rtld for several architectures. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4c2f5bfbfa48b33b11912e7308ebd6f98fb6e647 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639085024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PmE1XKPsHNQZF/byu2/5pw7DFTHlhL2gtZv+NqnZLuY=; b=tSlz6qU+f6bVwzHxluaQl1gyH78MDih4hBCzF4GtHN+eFn1HQQvWIqP0mPmfqLbpKJLs7J nzFQ6QVqDzp3CiPtvAsE8Uj36T8DO3/0+5P4Uw23vDOlRqFCN6Wj8X/fglEIF7M3jG9AKY 9hYI4NzUqnDRTO/DENlPrA15Iv3nvZLV4oSgUKs386Kpeqmpu+rr6n6bBF60eAFR8/xxgo qiENs42cd/XADfJYFvFDYCYKSQbgoilXdGLYcspdjxqubETh9JxkdZiFjZMj7pMBZVEonr /NKJNkCUeivGuEnrzukgpdhFTbnTdAQOg+AhgFpLhxg7/zF+11TSEdHTRIfcOg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639085024; a=rsa-sha256; cv=none; b=d5NihHwdmoqvoHheZZFabCAHg423sdYFrlnRfMKXaqTVlC8xpXKBnhUaD5spx6QMhMVHpC o3YDn+ZjqRk+ASkcbybQHTQ7ZUU6d48vGeSUInVktpx0yNcTpHw0BNBA1r4MM8JU4plpFl 7ftMWcTseZQONXHCt6hhQeW7H2jZKpAMlz3qMr9fpI8cLcReE3+yJ5/lTCdpTZu3IFQX6Z HEW1V9qs9aliy6Y2PAgSTJrTtyLZqF93gblPXcq9f0B5tEd1V9WU+At+mvoWo6svPO/R3C KXx1yJ5ilquvWKrqvzaHUXhrSjX6qxBs0H0ok4HsFSF4ViKIFhTQ2Bfp7PggNA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=4c2f5bfbfa48b33b11912e7308ebd6f98fb6e647 commit 4c2f5bfbfa48b33b11912e7308ebd6f98fb6e647 Author: John Baldwin AuthorDate: 2021-12-09 21:16:57 +0000 Commit: John Baldwin CommitDate: 2021-12-09 21:16:57 +0000 libc: Fix the alignment of the TCB to match rtld for several architectures. - Use 16 byte alignment rather than 8 for aarch64, powerpc64, and RISC-V. - Use 8 byte alignment rather than 4 for 32-bit arm, mips, and powerpc. I suspect that mips64 should be using 16 byte alignment, but both libc and rtld currently use 8 byte alignment. Reviewed by: kib, jrtc27 Sponsored by: The University of Cambridge, Google Inc. Differential Revision: https://reviews.freebsd.org/D33350 --- lib/libc/gen/tls.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c index d90aac028b88..5995cf605ed3 100644 --- a/lib/libc/gen/tls.c +++ b/lib/libc/gen/tls.c @@ -72,11 +72,14 @@ void _rtld_free_tls(void *tls, size_t tcbsize, size_t tcbalign); void *__libc_allocate_tls(void *oldtls, size_t tcbsize, size_t tcbalign); void __libc_free_tls(void *tls, size_t tcbsize, size_t tcbalign); -#if defined(__amd64__) +#if defined(__amd64__) || defined(__aarch64__) || defined(__riscv) #define TLS_TCB_ALIGN 16 -#elif defined(__aarch64__) || defined(__arm__) || defined(__i386__) || \ - defined(__mips__) || defined(__powerpc__) || defined(__riscv) -#define TLS_TCB_ALIGN sizeof(void *) +#elif defined(__arm__) || defined(__mips__) +#define TLS_TCB_ALIGN 8 +#elif defined(__powerpc__) +#define TLS_TCB_ALIGN TLS_TCB_SIZE +#elif defined(__i386__) +#define TLS_TCB_ALIGN 4 #else #error TLS_TCB_ALIGN undefined for target architecture #endif