From nobody Wed Jul 31 17:23:36 2024 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 4WYzTN52Zhz5SFZ1; Wed, 31 Jul 2024 17:23:36 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WYzTN4BSSz4HR1; Wed, 31 Jul 2024 17:23:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722446616; 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=YdjjIQ6CyfdOKPzCQmsi35yLwx2D/DYQ6SnIw+Xqh/g=; b=xcnJVTRhOd2tWLhs1z0RK+iDCbIbEx/1EnmEEXVryyv1siXXc/GwnePupe7yVdFa6ywZ9f 5bO711RsEmhNqU116aHjDAb9YeSsO91htmb00fFrql5TyHZGznNpl51BRv9SrZhIr7RTFm bsOqQ6cBH8miPWJ5uWPcQs14VdthWuPt4vjAoe0UXUyi42MWQeeoRJsOhfwaSo40uZL1MN zhwD2MO3gJgf5mFMIb2J/LPjDGHr93PDO0KMp88o1bJmVd4HUQ/DxJ3pNVt2r54hoN8fPl rADwi4dReMbIKOBk6arkk1OwPUfxKZI50WAayAapmWgzR1Pm5puOPqy9Y2gASw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722446616; a=rsa-sha256; cv=none; b=mjxrcOwJc/ALJP1ynVtTwmHdRZFe0t2QunvtjPwMoZFQ8mX2Pkz0BmUP6vdoml1RCw/ML8 JHAXVB43xM35Z4eo256XHWv/ilZTQzYxKG7Yc3YL83CE5D7PRSqSNPc5NB3yA+gAEZTy4A oOQjqaO5xHxyU0ujs6Pp/9KD/iMlDpayZibN1w/zKH0G5fvSIpBvjZ1PbfS1TvTe1CaZbd WczIkrCXPKSLcySLoq8rKRmi9/KLlFMCcyPZyJtGN+pgj4y7Ko1DgMPwTfcauv1PxMb40C rL48EmOAhil5QxcZrcaWeI15a9F7KBi8ozaVtWzNbcmhKbntpFFcAVCHEZ7LkQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722446616; 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=YdjjIQ6CyfdOKPzCQmsi35yLwx2D/DYQ6SnIw+Xqh/g=; b=fvzfIHMbGQM624gTIb8RI4j4AsTV8JqxE2Bleunym+nCd2hb65scDkEa7tsCCu6Ntzj1KB 9oirv2djj7PTn1Ue7ClrfmZt+3k6P5Qz+pnRw1B6DXxe2lQ0lkVAnox6JH8ZgJFRX33eO3 lYZeAO6CWhuAvWmbFIMuWehq1/0dJReUDUzzGddSlJ4dF5VCVtV7XAdclMtGbuF5g9PXne 3sZFT2mlxWnxkPIa+j367uhSMuSh3+qPnJBakLChbSYFViJOcukhS6cki+639bf2mIbxjM jzZSkQvHJrE+5DU6WRXI2ov+zGhhYUl0b4jM0uZa9PPBj4FRNt+eoykJOnYH7g== 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 4WYzTN3p8Sz18mn; Wed, 31 Jul 2024 17:23:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46VHNae8072753; Wed, 31 Jul 2024 17:23:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46VHNauV072750; Wed, 31 Jul 2024 17:23:36 GMT (envelope-from git) Date: Wed, 31 Jul 2024 17:23:36 GMT Message-Id: <202407311723.46VHNauV072750@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michal Meloun Subject: git: bd774d7aa111 - stable/14 - libthr: Preresolve selected EABI symbols on arm. 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mmel X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: bd774d7aa1117f531b2894a6428aa2792f7bedc8 Auto-Submitted: auto-generated The branch stable/14 has been updated by mmel: URL: https://cgit.FreeBSD.org/src/commit/?id=bd774d7aa1117f531b2894a6428aa2792f7bedc8 commit bd774d7aa1117f531b2894a6428aa2792f7bedc8 Author: Michal Meloun AuthorDate: 2024-07-24 15:11:27 +0000 Commit: Michal Meloun CommitDate: 2024-07-31 12:10:58 +0000 libthr: Preresolve selected EABI symbols on arm. Add the ability to pre-resolve architecture-specific EABI symbols and use it on arm for selected EABI functions. These functions can be called with rtld bind lock write-locked, so they should be resolved in forward. Reported by: Mark Millard , John F Carr Reviewed by: kib, imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D46104 (cherry picked from commit 5670b8cc3672d5a6bc2c41eb48d7d01343c43ad0) --- lib/libthr/arch/aarch64/include/pthread_md.h | 5 +++ lib/libthr/arch/amd64/include/pthread_md.h | 5 +++ lib/libthr/arch/arm/Makefile.inc | 3 ++ lib/libthr/arch/arm/thr_rtld_arm.c | 67 ++++++++++++++++++++++++++++ lib/libthr/arch/i386/include/pthread_md.h | 5 +++ lib/libthr/arch/powerpc/include/pthread_md.h | 5 +++ lib/libthr/arch/riscv/include/pthread_md.h | 10 +++++ lib/libthr/thread/thr_private.h | 1 + lib/libthr/thread/thr_rtld.c | 3 ++ 9 files changed, 104 insertions(+) diff --git a/lib/libthr/arch/aarch64/include/pthread_md.h b/lib/libthr/arch/aarch64/include/pthread_md.h index 75e6abf445ba..305abed55d3c 100644 --- a/lib/libthr/arch/aarch64/include/pthread_md.h +++ b/lib/libthr/arch/aarch64/include/pthread_md.h @@ -49,4 +49,9 @@ _get_curthread(void) return (_tcb_get()->tcb_thread); } +static __inline void +_thr_resolve_machdep(void) +{ +} + #endif /* _PTHREAD_MD_H_ */ diff --git a/lib/libthr/arch/amd64/include/pthread_md.h b/lib/libthr/arch/amd64/include/pthread_md.h index fa0802e64ebb..5b1486b151c0 100644 --- a/lib/libthr/arch/amd64/include/pthread_md.h +++ b/lib/libthr/arch/amd64/include/pthread_md.h @@ -54,4 +54,9 @@ _get_curthread(void) #define HAS__UMTX_OP_ERR 1 +static __inline void +_thr_resolve_machdep(void) +{ +} + #endif diff --git a/lib/libthr/arch/arm/Makefile.inc b/lib/libthr/arch/arm/Makefile.inc new file mode 100644 index 000000000000..4e770cf6b90f --- /dev/null +++ b/lib/libthr/arch/arm/Makefile.inc @@ -0,0 +1,3 @@ +.PATH: ${.CURDIR}/arch/arm +SRCS+= \ + thr_rtld_arm.c diff --git a/lib/libthr/arch/arm/thr_rtld_arm.c b/lib/libthr/arch/arm/thr_rtld_arm.c new file mode 100644 index 000000000000..35f5fe56cfff --- /dev/null +++ b/lib/libthr/arch/arm/thr_rtld_arm.c @@ -0,0 +1,67 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024, Michal Meloun + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#include "thr_private.h" + +int __aeabi_idiv(int , int ); +unsigned __aeabi_uidiv(unsigned, unsigned ); + +struct {int q; int r;} __aeabi_idivmod(int, int ); +struct {unsigned q; unsigned r;} __aeabi_uidivmod(unsigned, unsigned); + +struct {int64_t q; int64_t r;} __aeabi_ldivmod(int64_t, int64_t); +struct {uint64_t q; uint64_t r;} __aeabi_uldivmod(uint64_t, uint64_t); + +void __aeabi_memset(void *dest, size_t n, int c); +void __aeabi_memclr(void *dest, size_t n); +void __aeabi_memmove(void *dest, void *src, size_t n); +void __aeabi_memcpy(void *dest, void *src, size_t n); +void __aeabi_memcmp(void *dest, void *src, size_t n); + +void +_thr_resolve_machdep(void) +{ + char tmp[2]; + + __aeabi_idiv(1, 1); + __aeabi_uidiv(1, 1); + + __aeabi_idivmod(1, 1); + __aeabi_uidivmod(1, 1); + + __aeabi_ldivmod(1, 1); + __aeabi_uldivmod(1, 1); + + __aeabi_memset(tmp, 1, 0); + __aeabi_memclr(tmp, 1); + __aeabi_memmove(tmp, tmp + 1, 1); + __aeabi_memcpy(tmp, tmp + 1, 1); + __aeabi_memcmp(tmp, tmp + 1, 1); +} diff --git a/lib/libthr/arch/i386/include/pthread_md.h b/lib/libthr/arch/i386/include/pthread_md.h index 2a396abe3824..cb9af559db32 100644 --- a/lib/libthr/arch/i386/include/pthread_md.h +++ b/lib/libthr/arch/i386/include/pthread_md.h @@ -54,4 +54,9 @@ _get_curthread(void) #define HAS__UMTX_OP_ERR 1 +static __inline void +_thr_resolve_machdep(void) +{ +} + #endif diff --git a/lib/libthr/arch/powerpc/include/pthread_md.h b/lib/libthr/arch/powerpc/include/pthread_md.h index 14f1703b5460..31fa9820b26a 100644 --- a/lib/libthr/arch/powerpc/include/pthread_md.h +++ b/lib/libthr/arch/powerpc/include/pthread_md.h @@ -51,4 +51,9 @@ _get_curthread(void) #define HAS__UMTX_OP_ERR 1 +static __inline void +_thr_resolve_machdep(void) +{ +} + #endif /* _PTHREAD_MD_H_ */ diff --git a/lib/libthr/arch/riscv/include/pthread_md.h b/lib/libthr/arch/riscv/include/pthread_md.h index 343f4cae8486..2f70aa5edf25 100644 --- a/lib/libthr/arch/riscv/include/pthread_md.h +++ b/lib/libthr/arch/riscv/include/pthread_md.h @@ -56,4 +56,14 @@ _get_curthread(void) return (NULL); } +static __inline void +_thr_resolve_machdep(void) +{ +} + +static __inline void +_thr_resolve_machdep(void) +{ +} + #endif /* _PTHREAD_MD_H_ */ diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h index f89941f96c78..7b8a2d6569f9 100644 --- a/lib/libthr/thread/thr_private.h +++ b/lib/libthr/thread/thr_private.h @@ -1103,6 +1103,7 @@ int __Tthr_mutex_trylock(pthread_mutex_t *); bool __thr_get_main_stack_base(char **base); bool __thr_get_main_stack_lim(size_t *lim); int _Tthr_sigqueue(pthread_t pthread, int sig, const union sigval value); +void _thr_resolve_machdep(void); __END_DECLS __NULLABILITY_PRAGMA_POP diff --git a/lib/libthr/thread/thr_rtld.c b/lib/libthr/thread/thr_rtld.c index 54560a2f7df2..55197a9c5461 100644 --- a/lib/libthr/thread/thr_rtld.c +++ b/lib/libthr/thread/thr_rtld.c @@ -276,6 +276,9 @@ _thr_rtld_init(void) _thr_signal_block_check_fast(); _thr_signal_block_setup(curthread); + /* resolve machine depended functions, if any */ + _thr_resolve_machdep(); + uc_len = __getcontextx_size(); uc = alloca(uc_len); getcontext(uc);