From patchwork Sun Dec 22 20:51:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 103622 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CB0503858433 for ; Sun, 22 Dec 2024 20:52:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CB0503858433 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=AvQox6Lm X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [158.69.130.18]) by sourceware.org (Postfix) with ESMTPS id 70808385840F for ; Sun, 22 Dec 2024 20:51:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 70808385840F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 70808385840F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.130.18 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734900696; cv=none; b=AseusMjJKkbxqXQQX06cfC+pqT0VIKHY4CfGAQE2oJotbkvNreNUf0A5o9aTYEA3Z9b51ZcuZw20a+BkKDpdhiPAy39cqeGInY6g0UWPKuv55G6VtKlmaIjrOUo6+A8daIY0twabCmuS19OFVXyO3PR0XMsFWkS8otOt1wq9S6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734900696; c=relaxed/simple; bh=oKGsqn8U4Vlh+RtxJSXbl/jzTsDLaXauvZ5A2oDrRLU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=YJTc1inht+3HMUL74FnD/l58i5YCuOZhn7pvUGMEXdC+8ED6c+sAwcGpDWkI84Pss0frRhXgpPiRTgALfxNE4irr2UbsEbxUOWGmxTArQwVWjvNcX99z8jszsurzdYWnU2bsIXiXUSNwAyMIoZmhFxfu+Sm64BEOmQ4DeGiOBJI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70808385840F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1734900696; bh=oKGsqn8U4Vlh+RtxJSXbl/jzTsDLaXauvZ5A2oDrRLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AvQox6LmkS4xzqCGdfydcGUvnS2i4vndoI4h+NIZaA/A/hODEvqpmzwNl+udMSLCx jvbk0RaFaFx6NZAzTY68osDSyCrU2ArBAkKLQu2vMwIAVJ+9T7rhvTxG/dzFgCm2I0 ybM2Hb4d+DaQ8YBxA/DrG6b76Hrmbnqshk1JMkXHVmjQ9mJUYGwKSYeRhc2oH+6Z0W GUnSSMEz+R0A7Q54Y1BcBdqFw8/DNpf/Xq2bf1FxHeANFbWsgwGW+EuLBtDDyzm/d0 JRuWn2TFYwLEHCY7uXlQv2HPa040W3eR8fWUG+iEXwuvypXuILXdiLbchTyn5wQ3lm +uA1RelI5wfSg== Received: from mjeanson-kernel.internal.efficios.com (96-127-217-162.qc.cable.ebox.net [96.127.217.162]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4YGYGv70DTz1cKB; Sun, 22 Dec 2024 15:51:35 -0500 (EST) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , John David Anglin Subject: [PATCH] nptl: hppa: replace __get_cr27 with __thread_pointer Date: Sun, 22 Dec 2024 20:51:19 +0000 Message-Id: <20241222205119.393726-1-mjeanson@efficios.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241101192339.123141-2-mjeanson@efficios.com> References: <20241101192339.123141-2-mjeanson@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org The addition of the new thread_pointer.h header on HPPA resulted in duplicated inline asm to get the current thread pointer from the cr27 register. Include thread_pointer.h in tls.h and replace __get/set_cr27() with __set_/thread_pointer() with the appropriate casts. Signed-off-by: Michael Jeanson --- Cc: John David Anglin --- sysdeps/hppa/nptl/thread_pointer.h | 10 ++++++++++ sysdeps/hppa/nptl/tls.h | 26 ++++++-------------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/sysdeps/hppa/nptl/thread_pointer.h b/sysdeps/hppa/nptl/thread_pointer.h index 96f5e9b4c0..acd6fa5901 100644 --- a/sysdeps/hppa/nptl/thread_pointer.h +++ b/sysdeps/hppa/nptl/thread_pointer.h @@ -27,4 +27,14 @@ __thread_pointer (void) return __thread_register; } +/* We write to cr27, clobber r26 as the input argument, and clobber + r31 as the link register. */ +static inline void +__set_thread_pointer(void *__thread_pointer) +{ + asm ( "ble 0xe0(%%sr2, %%r0)\n\t" + "copy %0, %%r26" + : : "r" (__thread_pointer) : "r26", "r31" ); +} + #endif /* _SYS_THREAD_POINTER_H */ diff --git a/sysdeps/hppa/nptl/tls.h b/sysdeps/hppa/nptl/tls.h index 82055fa8a3..c97bdbcff1 100644 --- a/sysdeps/hppa/nptl/tls.h +++ b/sysdeps/hppa/nptl/tls.h @@ -40,6 +40,8 @@ /* Get the thread descriptor definition. */ # include +# include + typedef struct { dtv_t *dtv; @@ -62,7 +64,7 @@ typedef struct /* Install new dtv for current thread. */ # define INSTALL_NEW_DTV(dtv) \ - ({ tcbhead_t *__tcbp = (tcbhead_t *)__get_cr27(); \ + ({ tcbhead_t *__tcbp = (tcbhead_t *)__thread_pointer(); \ __tcbp->dtv = dtv; \ }) @@ -74,21 +76,21 @@ typedef struct special attention since 'errno' is not yet available and if the operation can cause a failure 'errno' must not be touched. */ # define TLS_INIT_TP(tcbp) \ - ({ __set_cr27(tcbp); true; }) + ({ __set_thread_pointer((void *) tcbp); true; }) /* Value passed to 'clone' for initialization of the thread register. */ # define TLS_DEFINE_INIT_TP(tp, pd) void *tp = (pd) + 1 /* Return the address of the dtv for the current thread. */ # define THREAD_DTV() \ - ({ tcbhead_t *__tcbp = (tcbhead_t *)__get_cr27(); \ + ({ tcbhead_t *__tcbp = (tcbhead_t *)__thread_pointer(); \ __tcbp->dtv; \ }) /* Return the thread descriptor for the current thread. */ # define THREAD_SELF \ ({ struct pthread *__self; \ - __self = __get_cr27(); \ + __self = (struct pthread *)__thread_pointer(); \ __self - 1; \ }) @@ -100,22 +102,6 @@ typedef struct # include -static inline struct pthread *__get_cr27(void) -{ - long cr27; - asm ("mfctl %%cr27, %0" : "=r" (cr27) : ); - return (struct pthread *) cr27; -} - -/* We write to cr27, clobber r26 as the input argument, and clobber - r31 as the link register. */ -static inline void __set_cr27(struct pthread *cr27) -{ - asm ( "ble 0xe0(%%sr2, %%r0)\n\t" - "copy %0, %%r26" - : : "r" (cr27) : "r26", "r31" ); -} - /* Get and set the global scope generation counter in struct pthread. */ #define THREAD_GSCOPE_FLAG_UNUSED 0 #define THREAD_GSCOPE_FLAG_USED 1