From patchwork Fri Aug 2 19:02:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1968475 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=uDjvDtSV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFbS73qQz1ydv for ; Sat, 3 Aug 2024 05:03:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 39BE5385DDD1 for ; Fri, 2 Aug 2024 19:03:15 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by sourceware.org (Postfix) with ESMTPS id 53BAB3858D26 for ; Fri, 2 Aug 2024 19:02:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 53BAB3858D26 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 53BAB3858D26 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=167.114.26.122 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625371; cv=none; b=TBnJkf1VY7MpcvE/1uDiPyBdHsy0PWpwbGFX68GSoaFoxvMGHQn+rTF4r4d89hW18sRw889x4RKDbE5dASZT/Z0gIFq4Qx1hUzN4NUtzUm4EsIC4cDMW6todXc20eymTjFhaL9u5VnKJrPszBZ7wyVDKE+tB+KKHmiDYqA5400I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625371; c=relaxed/simple; bh=YtjTB70CPtjxgL6UoJmheHldBKpGh+H2tJ7tNHu5Zqk=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=x5XP5jEFCsu+GnyZiQRvAIHJk0lQB18rNcyliNsfQpqhuFt6c03W1nu3NkNRarODk1jgBOicye6RBW+zmnwV7xIJlc+aaymAfTBDtuCB5ochSCFGyTj59wt1j5Mtuo7XYwmQxvVV97J9aDCso1VT9hL/ntak4syvdF488uwvEqY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625369; bh=YtjTB70CPtjxgL6UoJmheHldBKpGh+H2tJ7tNHu5Zqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uDjvDtSVmHO3xToJgOuoqCjoloOJBMtVPQLTuJ1roJ4a+sy1ivn9zZMde0R6ryTj5 iHVa34GJLqBeLsw3Hvr8fVRqyd37s2pz/kegdCyxxxXwR1XbRlnmhqyO8mBbD7M/1v qojHr+U8D9L9ka/JGqLrs5DQ0SxpK9toZKduZ+CyO9cfiDabKvgB05Jq9z+CfMIDLz 6dfk6Vkyx0G6huyjnucjq5Cv5F7wAiS7oSK7Aii6ZPdsePT5QYRgm+pGAqDawN7isQ g7Q9S3cFYNrd585D79tz9vTxImnybJDnSIhEU1MfyVYp/fFaXQZDWCAM1581dUQ5eF qVKd1z6Tu60GA== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFZw6mbrz1F3g; Fri, 2 Aug 2024 15:02:48 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 01/17] elf: Add rseq auxvals Date: Fri, 2 Aug 2024 15:02:14 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-1-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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~incoming=patchwork.ozlabs.org@sourceware.org Get the rseq feature size and alignment requirement from the auxiliary vector for use inside the dynamic loader. This will be used in the TLS block allocator to compute the size and alignment of the rseq area block for the extended ABI support and at thread creation to determine the size of the rseq registration. Signed-off-by: Michael Jeanson --- Open questions: - Should '_dl_rseq_feature_size' and '_dl_rseq_align' be in GLRO? If not where else? - Since RSEQ is Linux specific, should the changes in 'elf/' and 'sysdeps/generic/' be moved to 'sysdeps/unix/sysv/linux/'? If so, I'm unsure how it would work for GLRO variables. --- elf/dl-support.c | 8 ++++++++ elf/rtld_static_init.c | 6 ++++++ sysdeps/generic/ldsodefs.h | 8 ++++++++ sysdeps/unix/sysv/linux/dl-parse_auxv.h | 5 +++++ sysdeps/unix/sysv/linux/dl-sysdep.c | 2 ++ sysdeps/unix/sysv/linux/rseq-internal.h | 6 ++++++ 6 files changed, 35 insertions(+) diff --git a/elf/dl-support.c b/elf/dl-support.c index 451932dd03..1133644491 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -131,6 +131,14 @@ int _dl_starting_up = 1; /* Random data provided by the kernel. */ void *_dl_random; +/* Size of the supported rseq features. + Populated from the auxiliary vector with a minimum of '20'. */ +size_t _dl_rseq_feature_size; + +/* Alignment requirement of the rseq area. + Populated from the auxiliary vector with a minimum of '32'. */ +size_t _dl_rseq_align; + /* Get architecture specific initializer. */ #include #include diff --git a/elf/rtld_static_init.c b/elf/rtld_static_init.c index e918e4ebdf..c845531601 100644 --- a/elf/rtld_static_init.c +++ b/elf/rtld_static_init.c @@ -78,6 +78,12 @@ __rtld_static_init (struct link_map *map) extern __typeof (dl->_dl_tls_static_size) _dl_tls_static_size attribute_hidden; dl->_dl_tls_static_size = _dl_tls_static_size; + extern __typeof (dl->_dl_rseq_feature_size) _dl_rseq_feature_size + attribute_hidden; + dl->_dl_rseq_feature_size = _dl_rseq_feature_size; + extern __typeof (dl->_dl_rseq_align) _dl_rseq_align + attribute_hidden; + dl->_dl_rseq_align = _dl_rseq_align; dl->_dl_find_object = _dl_find_object; __rtld_static_init_arch (map, dl); diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 656e8a3fa0..8f91a08952 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -610,6 +610,14 @@ struct rtld_global_ro See comments in elf/dl-tls.c where it is initialized. */ EXTERN size_t _dl_tls_static_surplus; + /* Size of the supported rseq features. + Populated from the auxiliary vector with a minimum of '20'. */ + EXTERN size_t _dl_rseq_feature_size; + + /* Alignment requirement of the rseq area. + Populated from the auxiliary vector with a minimum of '32'. */ + EXTERN size_t _dl_rseq_align; + /* Name of the shared object to be profiled (if any). */ EXTERN const char *_dl_profile; /* Filename of the output file. */ diff --git a/sysdeps/unix/sysv/linux/dl-parse_auxv.h b/sysdeps/unix/sysv/linux/dl-parse_auxv.h index ea2a58ecb1..b3ebaa80d5 100644 --- a/sysdeps/unix/sysv/linux/dl-parse_auxv.h +++ b/sysdeps/unix/sysv/linux/dl-parse_auxv.h @@ -21,6 +21,7 @@ #include #include #include +#include typedef ElfW(Addr) dl_parse_auxv_t[AT_MINSIGSTKSZ + 1]; @@ -59,5 +60,9 @@ void _dl_parse_auxv (ElfW(auxv_t) *av, dl_parse_auxv_t auxv_values) GLRO(dl_sysinfo) = auxv_values[AT_SYSINFO]; #endif + GLRO (dl_rseq_feature_size) = MAX (auxv_values[AT_RSEQ_FEATURE_SIZE], + RSEQ_MIN_FEATURE_SIZE); + GLRO (dl_rseq_align) = MAX (auxv_values[AT_RSEQ_ALIGN], RSEQ_MIN_ALIGN); + DL_PLATFORM_AUXV } diff --git a/sysdeps/unix/sysv/linux/dl-sysdep.c b/sysdeps/unix/sysv/linux/dl-sysdep.c index a8ec2d7c18..01a39d2a74 100644 --- a/sysdeps/unix/sysv/linux/dl-sysdep.c +++ b/sysdeps/unix/sysv/linux/dl-sysdep.c @@ -209,6 +209,8 @@ _dl_show_auxv (void) [AT_L2_CACHEGEOMETRY - 2] = { "L2_CACHEGEOMETRY: 0x", hex }, [AT_L3_CACHESIZE - 2] = { "L3_CACHESIZE: ", dec }, [AT_L3_CACHEGEOMETRY - 2] = { "L3_CACHEGEOMETRY: 0x", hex }, + [AT_RSEQ_FEATURE_SIZE - 2] = { "RSEQ_FEATURE_SIZE: ", dec }, + [AT_RSEQ_ALIGN - 2] = { "RSEQ_ALIGN: ", dec }, }; unsigned int idx = (unsigned int) (av->a_type - 2); diff --git a/sysdeps/unix/sysv/linux/rseq-internal.h b/sysdeps/unix/sysv/linux/rseq-internal.h index 7ea935b4ad..1de56329cd 100644 --- a/sysdeps/unix/sysv/linux/rseq-internal.h +++ b/sysdeps/unix/sysv/linux/rseq-internal.h @@ -30,6 +30,12 @@ #define RSEQ_AREA_SIZE_INITIAL 32 #define RSEQ_AREA_SIZE_INITIAL_USED 20 +/* Minimum feature size of the rseq area. */ +#define RSEQ_MIN_FEATURE_SIZE 20 + +/* Minimum alignment of the rseq area. */ +#define RSEQ_MIN_ALIGN 32 + /* The variables are in .data.relro but are not yet write-protected. */ extern unsigned int _rseq_size attribute_hidden; extern ptrdiff_t _rseq_offset attribute_hidden; From patchwork Fri Aug 2 19:02:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1968476 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=MOMA90TU; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFbj2BK0z1yYq for ; Sat, 3 Aug 2024 05:03:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7DAA5385DDD1 for ; Fri, 2 Aug 2024 19:03:27 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [IPv6:2607:5300:203:b2ee::31e5]) by sourceware.org (Postfix) with ESMTPS id 923573858D34 for ; Fri, 2 Aug 2024 19:02:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 923573858D34 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 923573858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:5300:203:b2ee::31e5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625373; cv=none; b=hlkstFVfBu5YmN8s+4RqNqT8lnhxeBJPF8cb/N7sHZIrYur6Te9gkWDytgb712DGo4jsRswWyN+mPub85+YXpgF34pg21Hz86CvKySB4XZRYvCL/a5erBU/MUm+6jsQpHeGBI/vJAF90YhN49NDu9e6EA6x99SWo2G54GqB34vQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625373; c=relaxed/simple; bh=ps6deZZ7KDcZ5puBTu2fDpUqJEvIciXVypWJJInxH2M=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=WYECibcI6taeJX0fOBbk9fwtx1L9QiBUSIILCJ1x+FJmPgXyfz9PmAx4mfa7gT+cjIiXTCNTqQPgfMV4EliIUXuRYZmzuBi3MwKBfNP9NGrUOkYN+q9DeotqtP/0PSJNJAy9rJ3tnnCdnZ3UU1BTCrmpHGBoOe2nEUpaGAun5WI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625370; bh=ps6deZZ7KDcZ5puBTu2fDpUqJEvIciXVypWJJInxH2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MOMA90TUHYPpzcp43P64cqxM5gr57PbBIqdvE9SFV8Q5vxNJSvTPVAoLuPBOXALjA di+iwAvYvBgEUpERkGew2tK4LU6FQH+mXcpQ44HNxb66BayUpSVwBBUzD8zGOjOrs4 uCFTTtJnII9mGvKh33KOeedQQfEkOm0tCVpUIKUs30X1gBsTYWBSs69EIqZDuCMYbw OoezE0I8bOcqZo/umuGEvP6H9urpYAHrtMSLUne5du8Ld/0/Oju+kKMuPCyAjcDG35 Gs+TXPRKbrsJSZ0aSDKJCCIpEH84Rgq9wBM0epbe6UCgT4pT0HSihEuK3uWiaXPsVG lJuOyRvKuzebQ== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFZy0Qdqz1Fl0; Fri, 2 Aug 2024 15:02:50 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 02/17] Add generic 'extra TLS' Date: Fri, 2 Aug 2024 15:02:15 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-2-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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~incoming=patchwork.ozlabs.org@sourceware.org Add the logic to append an 'extra TLS' block in the TLS block allocator with a generic stub implementation. Signed-off-by: Michael Jeanson --- csu/libc-tls.c | 59 +++++++++++++++++++++++++++++++++++------- elf/dl-tls.c | 59 ++++++++++++++++++++++++++++++++++++++++++ sysdeps/generic/dl-extra_tls.h | 45 ++++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+), 9 deletions(-) diff --git a/csu/libc-tls.c b/csu/libc-tls.c index b7682bdf43..03a000c499 100644 --- a/csu/libc-tls.c +++ b/csu/libc-tls.c @@ -26,6 +26,7 @@ #include #include #include +#include #ifdef SHARED #error makefile bug, this file is for static only @@ -110,6 +111,7 @@ __libc_setup_tls (void) size_t filesz = 0; void *initimage = NULL; size_t align = 0; + size_t tls_blocks_size = 0; size_t max_align = TCB_ALIGNMENT; size_t tcb_offset; const ElfW(Phdr) *phdr; @@ -135,22 +137,67 @@ __libc_setup_tls (void) /* Calculate the size of the static TLS surplus, with 0 auditors. */ _dl_tls_static_surplus_init (0); + /* Extra TLS block for internal usage to append at the end of the TLS blocks + (in allocation order). On Linux systems this is where the rseq area will + be allocated. On other systems it is currently unused and both values will + be '0'. */ + size_t extra_tls_size = _dl_extra_tls_get_size(); + size_t extra_tls_align = _dl_extra_tls_get_align(); + + /* Increase the maximum alignment with the extra TLS alignment requirements + if necessary. */ + max_align = MAX (max_align, extra_tls_align); + /* We have to set up the TCB block which also (possibly) contains 'errno'. Therefore we avoid 'malloc' which might touch 'errno'. Instead we use 'sbrk' which would only uses 'errno' if it fails. In this case we are right away out of memory and the user gets what she/he deserves. */ #if TLS_TCB_AT_TP + /* Before the the thread pointer, add the aligned tls block size and then + align the extra tls block on top. */ + tls_blocks_size = roundup (roundup (memsz, align ?: 1) + extra_tls_size, + extra_tls_align); + + /* Record the extra TLS block offset from the thread pointer. + + With TLS_TCB_AT_TP the TLS blocks are allocated before the thread pointer + in reverse order. Our block is added last which results in it being the + first in the static TLS block, thus record the most negative offset. + + The alignment requirements of the pointer resulting from this offset and + the thread pointer are enforced by 'max_align' which is used to align the + tcb_offset. */ + _dl_extra_tls_set_offset(-tls_blocks_size); + /* Align the TCB offset to the maximum alignment, as _dl_allocate_tls_storage (in elf/dl-tls.c) does using __libc_memalign and dl_tls_static_align. */ - tcb_offset = roundup (memsz + GLRO(dl_tls_static_surplus), max_align); + tcb_offset = roundup (tls_blocks_size + GLRO(dl_tls_static_surplus), max_align); tlsblock = _dl_early_allocate (tcb_offset + TLS_INIT_TCB_SIZE + max_align); if (tlsblock == NULL) _startup_fatal_tls_error (); #elif TLS_DTV_AT_TP + /* Align memsz on top of the initial tcb. */ tcb_offset = roundup (TLS_INIT_TCB_SIZE, align ?: 1); - tlsblock = _dl_early_allocate (tcb_offset + memsz + max_align + + /* After the thread pointer, add the initial tcb plus the tls block size and + then align the extra TLS block on top. */ + tls_blocks_size = roundup (tcb_offset + memsz + extra_tls_size, extra_tls_align); + + /* Record the extra TLS block offset from the thread pointer. + + With TLS_DTV_AT_TP the TLS blocks are allocated after the thread pointer in + order. Our block is added last which results in it being the last in the + static TLS block, thus record the offset as the size of the static TLS + block minus the size of our block. The resulting offset will be positive. + + The alignment requirements of the pointer resulting from this offset and + the thread pointer are enforced by 'max_align' which is used to align the + tcb_offset. */ + _dl_extra_tls_set_offset(tls_blocks_size - extra_tls_size); + + tlsblock = _dl_early_allocate (tls_blocks_size + max_align + TLS_PRE_TCB_SIZE + GLRO(dl_tls_static_surplus)); if (tlsblock == NULL) @@ -209,11 +256,5 @@ __libc_setup_tls (void) /* static_slotinfo.slotinfo[1].gen = 0; -- Already zero. */ static_slotinfo.slotinfo[1].map = main_map; - memsz = roundup (memsz, align ?: 1); - -#if TLS_DTV_AT_TP - memsz += tcb_offset; -#endif - - init_static_tls (memsz, MAX (TCB_ALIGNMENT, max_align)); + init_static_tls (tls_blocks_size, MAX (TCB_ALIGNMENT, max_align)); } diff --git a/elf/dl-tls.c b/elf/dl-tls.c index 3d221273f1..e60eb721f4 100644 --- a/elf/dl-tls.c +++ b/elf/dl-tls.c @@ -36,6 +36,8 @@ #define TUNABLE_NAMESPACE rtld #include +#include + /* Surplus static TLS, GLRO(dl_tls_static_surplus), is used for - IE TLS in libc.so for all dlmopen namespaces except in the initial @@ -323,6 +325,33 @@ _dl_determine_tlsoffset (void) slotinfo[cnt].map->l_tls_offset = off; } + /* Insert the extra TLS block after the last TLS block. */ + + /* Extra TLS block for internal usage to append at the end of the TLS blocks + (in allocation order). On Linux systems this is where the rseq area will + be allocated. On other systems it is currently unused and both values will + be '0'. */ + size_t extra_tls_size = _dl_extra_tls_get_size(); + size_t extra_tls_align = _dl_extra_tls_get_align(); + + /* Align and add the extra TLS block to the global offset. */ + offset = roundup (offset, extra_tls_align) + extra_tls_size; + + /* Increase the maximum alignment with the extra TLS alignment requirements + if necessary. */ + max_align = MAX (max_align, extra_tls_align); + + /* Record the extra TLS offset. + + With TLS_TCB_AT_TP the TLS blocks are allocated before the thread pointer + in reverse order. Our block is added last which results in it being the + first in the static TLS block, thus record the most negative offset. + + The alignment requirements of the pointer resulting from this offset and + the thread pointer are enforced by 'max_align' which is used to align the + tcb_offset. */ + _dl_extra_tls_set_offset(-offset); + GL(dl_tls_static_used) = offset; GLRO (dl_tls_static_size) = (roundup (offset + GLRO(dl_tls_static_surplus), max_align) @@ -368,6 +397,36 @@ _dl_determine_tlsoffset (void) offset = off + slotinfo[cnt].map->l_tls_blocksize - firstbyte; } + /* Insert the extra TLS block after the last TLS block. */ + + /* Extra TLS block for internal usage to append at the end of the TLS blocks + (in allocation order). On Linux systems this is where the rseq area will + be allocated. On other systems it is currently unused and both values will + be '0'. */ + size_t extra_tls_size = _dl_extra_tls_get_size(); + size_t extra_tls_align = _dl_extra_tls_get_align(); + + /* Align the global offset to the beginning of the extra TLS block. */ + offset = roundup (offset, extra_tls_align); + + /* Record the extra TLS offset. + + With TLS_DTV_AT_TP the TLS blocks are allocated after the thread pointer in + order. Our block is added last which results in it being the last in the + static TLS block, thus record the offset as the size of the static TLS + block minus the size of our block. The resulting offset will be positive. + + The alignment requirements of the pointer resulting from this offset and + the thread pointer are enforced by 'max_align' which is used to align the + tcb_offset. */ + _dl_extra_tls_set_offset(offset); + + /* Add the extra TLS block to the global offset. */ + offset += extra_tls_size; + + /* Increase the max_align if necessary. */ + max_align = MAX (max_align, extra_tls_align); + GL(dl_tls_static_used) = offset; GLRO (dl_tls_static_size) = roundup (offset + GLRO(dl_tls_static_surplus), TCB_ALIGNMENT); diff --git a/sysdeps/generic/dl-extra_tls.h b/sysdeps/generic/dl-extra_tls.h new file mode 100644 index 0000000000..6e2c89828c --- /dev/null +++ b/sysdeps/generic/dl-extra_tls.h @@ -0,0 +1,45 @@ +/* extra tls utils for the dynamic linker. Generic stub version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _DL_EXTRA_TLS_H +#define _DL_EXTRA_TLS_H 1 +#include + +/* In this generic version, the extra TLS block is unused. */ + +/* Returns the size of the extra TLS block. */ +static inline size_t +_dl_extra_tls_get_size (void) +{ + return 0; +} + +/* Returns the alignment requirements of the extra TLS block. */ +static inline size_t +_dl_extra_tls_get_align (void) +{ + return 0; +} + +/* Record the offset of the extra TLS block from the thread pointer. */ +static inline void +_dl_extra_tls_set_offset (ptrdiff_t tls_offset) +{ +} + +#endif From patchwork Fri Aug 2 19:02:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1968480 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=mi1R3Fw9; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFdC0W8Dz1yYq for ; Sat, 3 Aug 2024 05:04:47 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4DC80385DDFA for ; Fri, 2 Aug 2024 19:04:45 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [IPv6:2607:5300:203:b2ee::31e5]) by sourceware.org (Postfix) with ESMTPS id 6AF173858D35 for ; Fri, 2 Aug 2024 19:02:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6AF173858D35 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 6AF173858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:5300:203:b2ee::31e5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625373; cv=none; b=BKVG2xpLLXvku03FnSMvesqdteaOIJfrLTEkCZTSxQ0s0FMbUF6Ysx82OU8c1w6tMfLw1HhwSTeLmfXMNCUwd0hbv51jzWOKQ8ehqPUjC8IhFGA5Ygf65EUHMg9cBJPISelV2z86ICoTqONqSYtx+OyZcOvC8SUxQ4YFZrGpLA4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625373; c=relaxed/simple; bh=rWb8xGo8aDKdAu3tsVYcmd/lNixOEMXfVbvldgp4HYE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=A/sn+MlZfSN9PykQLD4ZoxOZjJyiN6l7QdkBvEREUur9g5E+mT6gDudkQpwILloE1IvLuev1DiBdGHUJ/bRqC+TTjobxY6mLu3d4P3/LSdVbyjwj2k1q8NfRcXvpdVDdcgK2rVaqqnMoG6gjTojROjzVY3OuzNC8S/fB91Lf35w= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625371; bh=rWb8xGo8aDKdAu3tsVYcmd/lNixOEMXfVbvldgp4HYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mi1R3Fw9qD41++VczkTEwzV9//xgWo/zsFAwQIPLsgXH+y/Le3wj4z72GpTM0j29l VY00W+7s+EZe6D96alL1oNCAdF9Oc3mA98q48pt8rmc7omEU5ZxOeGCFRLbhv6jkFd gahwoSRbC2DrdN8DJTlgWF9oJt0H8I+crvRBcfz0N8Ed6F4ULQ+6p2leKM6y3UPzn8 VyJFqQl2gQOvSvHWBr00N4WZ2HkOnMQybS6R/nZ4B8GauBKRHt7CpE8DaSiCpIBN+M ZpffDEyQNt8F8gBLSMr0fGRnBd/ZRsLtAMx9vBuXxeGGSTvGoO8omQhwgnohl9sR68 K+qS/mpcLuBmg== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFZz00hmz1Fqw; Fri, 2 Aug 2024 15:02:50 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 03/17] Add Linux 'extra TLS' Date: Fri, 2 Aug 2024 15:02:16 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-3-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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~incoming=patchwork.ozlabs.org@sourceware.org Add the Linux implementation of 'extra TLS' which will allocate space for the rseq area at the end of the TLS blocks in allocation order. Signed-off-by: Michael Jeanson --- sysdeps/unix/sysv/linux/dl-extra_tls.h | 77 +++++++++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/rseq-internal.h | 3 ++ 2 files changed, 80 insertions(+) diff --git a/sysdeps/unix/sysv/linux/dl-extra_tls.h b/sysdeps/unix/sysv/linux/dl-extra_tls.h new file mode 100644 index 0000000000..10ca63ecb5 --- /dev/null +++ b/sysdeps/unix/sysv/linux/dl-extra_tls.h @@ -0,0 +1,77 @@ +/* extra tls block utils for the dynamic linker. Generic stub version. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _DL_EXTRA_TLS_H +#define _DL_EXTRA_TLS_H 1 + +#include +#include +#include +#include + +/* Returns the size of the extra TLS block. */ +static inline size_t +_dl_extra_tls_get_size (void) +{ + bool do_rseq = true; + do_rseq = TUNABLE_GET_FULL (glibc, pthread, rseq, int, NULL); + if (do_rseq) + { + /* Make sure the rseq area size is at least the minimum ABI size and a + multiple of the requested aligment. */ + return roundup (MAX (GLRO (dl_rseq_feature_size), RSEQ_AREA_MIN_SIZE), + GLRO (dl_rseq_align)); + } + + /* Even when disabled by tunable, an rseq area will be allocated to allow + application code to test the registration status with 'rseq->cpu_id >= 0'. + Default to the rseq ABI minimum size, this will ensure we don't use more + TLS than necessary. */ + return RSEQ_AREA_MIN_SIZE; +} + +/* Returns the alignment requirements of the extra TLS block. */ +static inline size_t +_dl_extra_tls_get_align (void) +{ + bool do_rseq = true; + do_rseq = TUNABLE_GET_FULL (glibc, pthread, rseq, int, NULL); + if (do_rseq) + { + return GLRO (dl_rseq_align); + } + + /* Even when disabled by tunable, an rseq area will be allocated to allow + application code to test the registration status with 'rseq->cpu_id >= 0'. + Default to the rseq ABI minimum alignment, this will ensure we don't use + more TLS than necessary. */ + return RSEQ_MIN_ALIGN; +} + +/* Record the offset of the extra TLS block from the thread pointer. */ +static inline void +_dl_extra_tls_set_offset (ptrdiff_t tls_offset) +{ +#ifdef RSEQ_SIG + /* Not all targets support __thread_pointer, so set __rseq_offset only if + the rseq registration may have happened because RSEQ_SIG is defined. */ + _rseq_offset = tls_offset; +#endif +} + +#endif diff --git a/sysdeps/unix/sysv/linux/rseq-internal.h b/sysdeps/unix/sysv/linux/rseq-internal.h index 1de56329cd..2c68b8c70c 100644 --- a/sysdeps/unix/sysv/linux/rseq-internal.h +++ b/sysdeps/unix/sysv/linux/rseq-internal.h @@ -30,6 +30,9 @@ #define RSEQ_AREA_SIZE_INITIAL 32 #define RSEQ_AREA_SIZE_INITIAL_USED 20 +/* Minimum size of the rseq area. */ +#define RSEQ_AREA_MIN_SIZE 32 + /* Minimum feature size of the rseq area. */ #define RSEQ_MIN_FEATURE_SIZE 20 From patchwork Fri Aug 2 19:02:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1968481 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=RHRlf7hx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFdG0P2Gz1yYq for ; Sat, 3 Aug 2024 05:04:50 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3A194385F018 for ; Fri, 2 Aug 2024 19:04:48 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [IPv6:2607:5300:203:b2ee::31e5]) by sourceware.org (Postfix) with ESMTPS id 442553858D39 for ; Fri, 2 Aug 2024 19:02:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 442553858D39 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 442553858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:5300:203:b2ee::31e5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625373; cv=none; b=d+6rgNsJLnmod7La/hMcRZmdwxkrSRUd9IZvn9VoYXqu1WPHfTqQiQxT0kfaPR6eYKhWv2Bc3P4Zegt2T+IeViObAjn+egy0dMzN0xBG5PWSdx4jlKXCmRbA78ZLbI4KuQ8fU6xHm61naxLK9x04hqRC1zIWwJnEB7NHJWFn5i8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625373; c=relaxed/simple; bh=QCeWDwSUTWbdyDfSbFGWW1mXm/KLvwAFiBh65+d217c=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=IzN7VVIky9+y0EBzDBs4o8TM/PHoqKF2CP6D6gLpMzF3suHv9VYGwoN92w33r2cJ6TFpOXm+72t3pAOZCnd/nPVvVeP32CK0ioBwpJ2M3IQ/zPTBwk+mtqt4frK92hmfgHAtPn4Nj7hmwhZXOYfxR4hx/sDNkH0cnFNj+RQCvhY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625372; bh=QCeWDwSUTWbdyDfSbFGWW1mXm/KLvwAFiBh65+d217c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RHRlf7hxWK7Y6ALIry8l4EqoeRsGUQ0VQbANT5YpPRZIO1WSOdGugen8DcxAKWIC9 X36R38HfH8Ql4/QoRv7llDDwuJ7QROtZGmumJ2w39vpz7E4wTDNN/FDHOTnEQlINO8 spq2eDA4t3EXmddHn3nU6Rv/XE6THx+dk708gPFtW4wIry3lNd32lMViaTc06VvuyH 4n+u+GyJBTeCxghtKmm4fUtnfWwH5zWPcvmJ9Dgqz8mHOmkWnrLlxAvEtFA+qLswpe viidyxQtBpYBcsoLwprIVtID1LdeyZclr8L6FAAGHcw5rY5RwxJZkH8sf1BAoXiQpI bwdoUZ+75+xrg== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFZz6SXzz1Fqx; Fri, 2 Aug 2024 15:02:51 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 04/17] nptl: Add for RISC-V Date: Fri, 2 Aug 2024 15:02:17 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-4-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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~incoming=patchwork.ozlabs.org@sourceware.org This will be required by the rseq extensible ABI implementation on all Linux architectures exposing the __rseq_size and __rseq_offset symbols to set the 'cpu_id' field so applications can test if rseq is registered. Signed-off-by: Michael Jeanson --- sysdeps/riscv/nptl/thread_pointer.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/sysdeps/riscv/nptl/thread_pointer.h b/sysdeps/riscv/nptl/thread_pointer.h new file mode 100644 index 0000000000..e7f6296e7d --- /dev/null +++ b/sysdeps/riscv/nptl/thread_pointer.h @@ -0,0 +1,34 @@ +/* __thread_pointer definition. riscv version. + Copyright (C) 2021-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#ifndef _SYS_THREAD_POINTER_H +#define _SYS_THREAD_POINTER_H + +static inline void * +__thread_pointer (void) +{ +#if __GNUC_PREREQ (10, 3) + return __builtin_thread_pointer (); +#else + void *__result; + __asm__ ("mv %0, tp" : "=r" (__result)); + return __result; +#endif /* !GCC 10.3 */ +} + +#endif /* _SYS_THREAD_POINTER_H */ From patchwork Fri Aug 2 19:02:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1968478 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=F3sksMLi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFcv0pfPz1ydv for ; Sat, 3 Aug 2024 05:04:31 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 54BAF385E457 for ; Fri, 2 Aug 2024 19:04:29 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by sourceware.org (Postfix) with ESMTPS id 30EE93858C53 for ; Fri, 2 Aug 2024 19:02:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 30EE93858C53 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 30EE93858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=167.114.26.122 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625376; cv=none; b=YUkCaeZhZyuR65j1K08SgTjv/yDmrGNgyZ/iLSAmGbTMlCrcz8HhTBs0abaA1702s7XvnpRxuaNG0lRxGGPaddmKTWiTFwuqXdNm6Lr3hFJQbXsGPbZuKOQc+/oKSTP566SGVJz8df13ec82Yt7fDakind4FPxXW3puE6fUbdp0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625376; c=relaxed/simple; bh=yVrUQ8rZkLYj8FVc5HB5BE2SmZ6oWAGNwcJwHsbA7v0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=m0XhJWyeAgf+JqLnfgISvaWXMVOcskd5PphZYiIujZmFj7xrQRwvebvfi0qYppULxP3WYglM1k3zhpkeXNBNA0mjx5NoeaUrE2ezoqdbKYvQN268u9viIvUqVqLxoM9gg943b3CGR6S20tzHEnZOQqx24IAIkHC+kirKyfGXTK8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625372; bh=yVrUQ8rZkLYj8FVc5HB5BE2SmZ6oWAGNwcJwHsbA7v0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F3sksMLiebkzy7k1qYwhehsqqfjjIvgYGzeVbdFMROkzYgijuG4Y9h9u804DPAeKe irjJms/iTj+cGvuAMIKharSmmGhs786Hv/4E05MHXNLYVIOs+dI3AoSAAtfaTZcCb+ 0DigmgyU5aBq7mlRMNgTyU/Ya3evzFkKGvv6yi+dq9gmVyVscQ60AR6uR70LVs76gE sOx0R16y8PWL5ru/mFgDRg8pupuiqJkD1gneykTTTVQk3JMH9HJPcIeL7pyE9x4yDa m7vUCoGfS5Tf5CLhWG53RZQoJQ9Iccl48XhckJsR2fIT0SGwmQ2EIrzFusr8CpkZWo bZki1GRSStWSA== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFb05dHzz1Fqy; Fri, 2 Aug 2024 15:02:52 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 05/17] nptl: Add for LoongArch Date: Fri, 2 Aug 2024 15:02:18 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-5-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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~incoming=patchwork.ozlabs.org@sourceware.org This will be required by the rseq extensible ABI implementation on all Linux architectures exposing the __rseq_size and __rseq_offset symbols to set the 'cpu_id' field so applications can test if rseq is registered. Signed-off-by: Michael Jeanson --- sysdeps/loongarch/nptl/thread_pointer.h | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/sysdeps/loongarch/nptl/thread_pointer.h b/sysdeps/loongarch/nptl/thread_pointer.h new file mode 100644 index 0000000000..9d46d29905 --- /dev/null +++ b/sysdeps/loongarch/nptl/thread_pointer.h @@ -0,0 +1,34 @@ +/* __thread_pointer definition. loongarch version. + Copyright (C) 2021-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#ifndef _SYS_THREAD_POINTER_H +#define _SYS_THREAD_POINTER_H + +static inline void * +__thread_pointer (void) +{ +#if __GNUC_PREREQ (14, 1) + return __builtin_thread_pointer (); +#else + void *__result; + __asm__ ("move %0, $tp" : "=r" (__result)); + return __result; +#endif /* !GCC 14 */ +} + +#endif /* _SYS_THREAD_POINTER_H */ From patchwork Fri Aug 2 19:02: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: 1968485 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=ISdP0VYp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFfC0QMDz1yZl for ; Sat, 3 Aug 2024 05:05:39 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 52E3B386076C for ; Fri, 2 Aug 2024 19:05:37 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by sourceware.org (Postfix) with ESMTPS id 117C6385B50B for ; Fri, 2 Aug 2024 19:02:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 117C6385B50B 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 117C6385B50B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=167.114.26.122 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625377; cv=none; b=IEzLZiqvKaAIMmQwDDVO/HN3nA8N6tZY+2Z/zHbDfqZTG/pIbL1VdEAPmQB2bk0aM+iupAxF8iLNlCnzIdNbonY324Avy5bw4g2Am0p3DZSsLumcHb0Yp0HBRYF5GJAwxvXyT8e9ozQbob1IuFSHUIjwM/qpFOdEH6uHlHkbQK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625377; c=relaxed/simple; bh=uBRxO72dAwjaGSfhCi3I9IGxcjVf27kXXV3jSm4Ebto=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=D1Gouwzkm8YI857sUyC7MrJ2U7sSr9zC3UOIQ1plVChFM9Gdg4jbw6R9zQw2Am7cxxAJtNU1v0PzYL4oGVLtgY163M4PzO667B5jgiKaA1/rF6Mmal1ebIyWWvAZMsHWCYaxBGCQJmTZqNCmTxPbcv83KImcHy8aZPGL6mSZ1SI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625373; bh=uBRxO72dAwjaGSfhCi3I9IGxcjVf27kXXV3jSm4Ebto=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ISdP0VYpLKAXL8YZCGKHMpaaB4rx3jhJkcCpv1rHealSJZHXuBt8iA4keAx7JkRex g0dXMjZBvmqOnlilibAxr7tzwX6XMHr0eZ9KR3REc4wWn6i35rzAtBHW/m+JmTUNQJ l3zKARZwCIEzEeusX1+7ScpQfndxzxOUSQ7LS0z7ug4R905Ay0pqgEceqJ9taBKSk2 NEVIx/68nHFnUMz9XLspnoKub4AejH/WqA2P2ub9l/a8IruTCERkIBoSXDBWMFRqY9 74JGx88IMFK7FZ2p59pY6dEePtycQ2Dg8FeqAHt4KU8or+HzHwzcAkO/XEuQazCFeD rY3QDFwpC0ptQ== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFb14z8dz1Fr0; Fri, 2 Aug 2024 15:02:53 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 06/17] nptl: Add for sparc Date: Fri, 2 Aug 2024 15:02:19 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-6-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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~incoming=patchwork.ozlabs.org@sourceware.org This will be required by the rseq extensible ABI implementation on all Linux architectures exposing the __rseq_size and __rseq_offset symbols to set the 'cpu_id' field so applications can test if rseq is registered. Signed-off-by: Michael Jeanson --- sysdeps/sparc/nptl/thread_pointer.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/sysdeps/sparc/nptl/thread_pointer.h b/sysdeps/sparc/nptl/thread_pointer.h new file mode 100644 index 0000000000..800180f0a9 --- /dev/null +++ b/sysdeps/sparc/nptl/thread_pointer.h @@ -0,0 +1,30 @@ +/* __thread_pointer definition. sparc version. + Copyright (C) 2021-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#ifndef _SYS_THREAD_POINTER_H +#define _SYS_THREAD_POINTER_H + +register void *__thread_register asm ("g7"); + +static inline void * +__thread_pointer (void) +{ + return __thread_register; +} + +#endif /* _SYS_THREAD_POINTER_H */ From patchwork Fri Aug 2 19:02:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1968477 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=KrfPI9hF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFct4yHxz1yYq for ; Sat, 3 Aug 2024 05:04:30 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E622F385DDF9 for ; Fri, 2 Aug 2024 19:04:28 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [IPv6:2607:5300:203:b2ee::31e5]) by sourceware.org (Postfix) with ESMTPS id E36AB385C6C7 for ; Fri, 2 Aug 2024 19:02:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E36AB385C6C7 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 E36AB385C6C7 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:5300:203:b2ee::31e5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625377; cv=none; b=iHdggzg66xlGPSTpSZWIweh22F2NjA/3hzHYawlGEQjN+NAOLHso/woBOh+SGhVE1ExxaqzQJhadngMOYdnxUYe56gGSjUE3BlqOc1lyXb8UQ1xekmeJqEDndTabz4QEep/d5eEbEDvf483ehMydBDGZoU3cvgfzCpyPikwyTps= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625377; c=relaxed/simple; bh=4cEI3WnY/55P6iPHOeHIt0taPHUI+xEqdm/n6l6641U=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=DQKiatAnAltOw+GXu1kSMx/GBUYr1PeRkyGXdu6nx3pK9VghsojQ+uiuoA0vHpcJXQXowQbTbsQgT3z0ozesB95b4F9wGO55ZNAJmTc38bYCXSdROOpujAZHkwqqDskBK4xFNVfijOa8BSnC4tmbOSAYhJSDXoIUwc07qtDkIXw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625374; bh=4cEI3WnY/55P6iPHOeHIt0taPHUI+xEqdm/n6l6641U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KrfPI9hFrryqRTN/CjQBYT6lWQze69d4eS0eoevCpZh1toH2jdHN/cs8Gx6pCEFmG 3JhBIe8Ka3kPWOBxFR3J92l99knMyW0Q+UsybDu/lC72KFVICIegzih5XG9VYQeApF pFPMnbvy/adbLSmJTkzFSuap7AyMQcrFHaFBr/cqSUnSkjiot5DRjdFzETgD2eXfID R39Vf0hI7sDmPSKxiZDI39Lf+6zW6Q1oWwdFtWTlGvwNIThF6X+navhHFSFpbwqXPK Vp3lRDxa8SoQ574UM5EfDRnf/uRsVocIF9lqZlOjEfMRicUQxMuSLzjE0y4K6IP5bs YDMIGSO81aggQ== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFb23xS2z1Fr1; Fri, 2 Aug 2024 15:02:54 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 07/17] nptl: Add for m68k Date: Fri, 2 Aug 2024 15:02:20 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-7-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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~incoming=patchwork.ozlabs.org@sourceware.org This will be required by the rseq extensible ABI implementation on all Linux architectures exposing the __rseq_size and __rseq_offset symbols to set the 'cpu_id' field so applications can test if rseq is registered. Signed-off-by: Michael Jeanson --- sysdeps/m68k/nptl/thread_pointer.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/sysdeps/m68k/nptl/thread_pointer.h b/sysdeps/m68k/nptl/thread_pointer.h new file mode 100644 index 0000000000..50f4df38da --- /dev/null +++ b/sysdeps/m68k/nptl/thread_pointer.h @@ -0,0 +1,30 @@ +/* __thread_pointer definition. m68k version. + Copyright (C) 2021-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#ifndef _SYS_THREAD_POINTER_H +#define _SYS_THREAD_POINTER_H + +extern void * __m68k_read_tp (void); + +static inline void * +__thread_pointer (void) +{ + return __m68k_read_tp(); +} + +#endif /* _SYS_THREAD_POINTER_H */ From patchwork Fri Aug 2 19:02:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1968479 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=SqRDP2Ce; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFcx2Dqkz1yYq for ; Sat, 3 Aug 2024 05:04:33 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 80B37385840C for ; Fri, 2 Aug 2024 19:04:31 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [IPv6:2607:5300:203:b2ee::31e5]) by sourceware.org (Postfix) with ESMTPS id BDE9D3858C48 for ; Fri, 2 Aug 2024 19:02:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BDE9D3858C48 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 BDE9D3858C48 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:5300:203:b2ee::31e5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625377; cv=none; b=Wuzx8ZrJZXNKrblc4qHp97iqlicfUtp68uieoxicJsopOVR5ogyptv3++lrx02zU90DpCl9tv1tysdb/olrOx62Nm+WGqbP9OQjIM0DvjqhDOGwFzhFw/qmyFynMrZu3WgquelZPTCZIYTSqbkzN7+huzu497yiU2Hj5AISxKCo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625377; c=relaxed/simple; bh=g8QI7f+Y2Sls9rafvl8j9etaPS7E9D014KGx7tk84CE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=E5mO2Bnj8uWBrtv2dU14ghs37ABLaUiEwvIS7Ncjne79BxslJQmI8qFqtVg04qOKc2xw6gIHx0ToulCHjYaynvTBbHXW/0GqQDlrIkCKvh0tcsKbiigoJBqw7bceuICmj4IZKs3Y1SI4A7t5GhVjm4hgwYlwjoony20BQSnB1GA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625375; bh=g8QI7f+Y2Sls9rafvl8j9etaPS7E9D014KGx7tk84CE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SqRDP2CebSpn5WHIGAno0u7cjKm5LOuADvzyow/ND8aZCTpMsx84Ll2OmmtcVLTJ0 49SVB8bb6VluXUOjYGDp/0DIuJaX3hZx5/Au2WxtmRoA9QXz8hLi91Rx+6q6eDFCZX 2If4FuOXnyUFLiKSX2hmTjhyA2nC9MEMbuRr0D2H0rwdLnl/G/kviXloKobXcrLIy0 UDuojkOS7WJFG2Wb6qwwvvNJSwD6Ka0vcUTTRPM9am/PHb+OUaT0zIMpbHOCKdTlt6 1nCf3akL+4bjbm4BLOEmARK7nhfKl6juIWuISQpYITOrjRK0HPqUsgJOdsSSyUOoEq WczYscuLFPdRw== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFb32mx5z1F3h; Fri, 2 Aug 2024 15:02:55 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 08/17] nptl: Add for or1k Date: Fri, 2 Aug 2024 15:02:21 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-8-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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~incoming=patchwork.ozlabs.org@sourceware.org This will be required by the rseq extensible ABI implementation on all Linux architectures exposing the __rseq_size and __rseq_offset symbols to set the 'cpu_id' field so applications can test if rseq is registered. Signed-off-by: Michael Jeanson --- sysdeps/or1k/nptl/thread_pointer.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/sysdeps/or1k/nptl/thread_pointer.h b/sysdeps/or1k/nptl/thread_pointer.h new file mode 100644 index 0000000000..a323fe079b --- /dev/null +++ b/sysdeps/or1k/nptl/thread_pointer.h @@ -0,0 +1,30 @@ +/* __thread_pointer definition. or1k version. + Copyright (C) 2021-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#ifndef _SYS_THREAD_POINTER_H +#define _SYS_THREAD_POINTER_H + +register void *__thread_register asm ("r10"); + +static inline void * +__thread_pointer (void) +{ + return __thread_register; +} + +#endif /* _SYS_THREAD_POINTER_H */ From patchwork Fri Aug 2 19:02:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1968484 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=vqH19Vdy; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFf933fYz1yZl for ; Sat, 3 Aug 2024 05:05:37 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AF61D3860C3D for ; Fri, 2 Aug 2024 19:05:35 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [IPv6:2607:5300:203:b2ee::31e5]) by sourceware.org (Postfix) with ESMTPS id 9AD163858C5F for ; Fri, 2 Aug 2024 19:02:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9AD163858C5F 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 9AD163858C5F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:5300:203:b2ee::31e5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625378; cv=none; b=aWaicj47/dgOf3NbN5Q4Xj3dzjc/ZXszYzwI1J82p/wWvBdPzebf2zvgcycNjadbxFu8zVwshJZ7fBFs4tdXX1VMubkbxRzT7ulJ3DdkTTbuxqZfcBDFEkpH+5O0yhH1RqZO7llIoURVzo49sv2cqYh0h4nvVS346K7to9C+rYI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625378; c=relaxed/simple; bh=TDFKqTgFbj1GBQtXdzgWclwbh5GrSaEX0I+TlIayXSA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=p+aS3CNg/nMJklFnTi1Xi5/Dnvj6TSx2YTIcozbBC5N1h+PESwtrqKJd+jc6FBfdo+AB6sJCxzSxcHzo51K8R6NrRlY8cNe9Fnq05aqbZziYwglIfufmfJGt7E8xUOaEHyXMVKc4giPLnx8RlAtdJh8fXzKk2NsidCmCGWsSAag= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625376; bh=TDFKqTgFbj1GBQtXdzgWclwbh5GrSaEX0I+TlIayXSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vqH19VdyxD80QFKihLlI6TMcGs/LzdnPaLxLq7ZUonFz4HWoTqruCXUY15D2sFmzS cIwcHkO+VQ+iNo/mW8yME+3urwzJeIl4NIWOBGGUEMr0KJFa+hN4y+4aiX4mPoWPVo 4N60MTavlYuyJRn9ptMMOneu/2B2lElQZfwTgyc4sKB1pSrH+LgF8DOK7/asU/i2mw 1+kTLqQtWYeetIL+OYFoHRwpuuhlK/tZ788aQRpOrS2XtA4hev4ZZG/YYw6cw3pnD2 ciF+H89S+30ZTr5g9laepul17QJ1rFFvRg+Xl9oQuPu9GVAGk3JrBQ9DVu94m2T+2y s4pXFD9GEDUAg== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFb41cRrz1F3j; Fri, 2 Aug 2024 15:02:56 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 09/17] nptl: Add for nios2 Date: Fri, 2 Aug 2024 15:02:22 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-9-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, 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~incoming=patchwork.ozlabs.org@sourceware.org This will be required by the rseq extensible ABI implementation on all Linux architectures exposing the __rseq_size and __rseq_offset symbols to set the 'cpu_id' field so applications can test if rseq is registered. Signed-off-by: Michael Jeanson --- sysdeps/nios2/nptl/thread_pointer.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/sysdeps/nios2/nptl/thread_pointer.h b/sysdeps/nios2/nptl/thread_pointer.h new file mode 100644 index 0000000000..0cd6fe2295 --- /dev/null +++ b/sysdeps/nios2/nptl/thread_pointer.h @@ -0,0 +1,30 @@ +/* __thread_pointer definition. nios2 version. + Copyright (C) 2021-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#ifndef _SYS_THREAD_POINTER_H +#define _SYS_THREAD_POINTER_H + +register void *__thread_register asm ("r23"); + +static inline void * +__thread_pointer (void) +{ + return __thread_register; +} + +#endif /* _SYS_THREAD_POINTER_H */ From patchwork Fri Aug 2 19:02:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1968483 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=coDzuTKS; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFf849gDz1yZl for ; Sat, 3 Aug 2024 05:05:36 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D3DB6385F028 for ; Fri, 2 Aug 2024 19:05:34 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by sourceware.org (Postfix) with ESMTPS id 71C59385DDCE for ; Fri, 2 Aug 2024 19:02:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 71C59385DDCE 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 71C59385DDCE Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=167.114.26.122 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625379; cv=none; b=PA84QBZubrqHv+1HrZ0LH1/AgsArTG3LJvLrMhJsyIAKHpBXJpj1hLlMjPNWz0pnQJTFxwMmoEf+UJf7LbrtN5nJh+8jUnooojsVE5CUMWrpX4823lFGYYRRZSXiD7yByz6+D9+OMBndnl/v+BjEhF/I+BG7ttf9nShSknYRDlc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625379; c=relaxed/simple; bh=X/8cJ0pb4gHWKHspLWJlCCZkkP2ZF1foGLk3UZp2oUo=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=AdNQb1pdafdQoqC8v0dyKcR5zm7vOlxspNLNv+ODcKiFruL889ks/hDDXHud6AkLcRbSBODu6VD+HI1s/tVcpU33jbDbyVb6lrpj3rI2AxA5WA3jOT1PXqHY5c4IqhDZ4KKQLO2tbVrrB6wEQgbPe7G0g0052IMHiLwD7/g9gww= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625377; bh=X/8cJ0pb4gHWKHspLWJlCCZkkP2ZF1foGLk3UZp2oUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=coDzuTKS9JW2WtRqokaTmB3yD3QLobPpRg3pEnHEgwv1+ZWUCVCBOgR9/mYN36VXm pNBSI16COJopBGWgGLupNc8bflwgW2RQcq7MAMpBt80rIt92wIChzNSsLtCgT7+NKB WJAF4R0B3nTlCzVtJsfZY2qtwlwqrL8y6I1k0khtoMSOo4U+FNaYFuGbDLyP30mPga 7dEtS11++64UgofYfWW2zAeYoamDeqsCUIWK9sn/FQBEvWTKg+IC3tGw03HSeyZWQ9 mD1doTtqyVsgs/LtrHG7v3zLnllzOb+UmM2A5NgRUaYlKSSy9Ohprle8eE7UDR/Wg8 unuFu4INLGRIw== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFb50RCGz1Fbv; Fri, 2 Aug 2024 15:02:57 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 10/17] nptl: Add for microblaze Date: Fri, 2 Aug 2024 15:02:23 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-10-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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~incoming=patchwork.ozlabs.org@sourceware.org This will be required by the rseq extensible ABI implementation on all Linux architectures exposing the __rseq_size and __rseq_offset symbols to set the 'cpu_id' field so applications can test if rseq is registered. Signed-off-by: Michael Jeanson --- sysdeps/microblaze/nptl/thread_pointer.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/sysdeps/microblaze/nptl/thread_pointer.h b/sysdeps/microblaze/nptl/thread_pointer.h new file mode 100644 index 0000000000..1c56a7debf --- /dev/null +++ b/sysdeps/microblaze/nptl/thread_pointer.h @@ -0,0 +1,30 @@ +/* __thread_pointer definition. microblaze version. + Copyright (C) 2021-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#ifndef _SYS_THREAD_POINTER_H +#define _SYS_THREAD_POINTER_H + +register void *__thread_register asm ("r21"); + +static inline void * +__thread_pointer (void) +{ + return __thread_register; +} + +#endif /* _SYS_THREAD_POINTER_H */ From patchwork Fri Aug 2 19:02:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1968487 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=QIN18tpM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFfy1YCGz1yZl for ; Sat, 3 Aug 2024 05:06:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6F2663864815 for ; Fri, 2 Aug 2024 19:06:16 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by sourceware.org (Postfix) with ESMTPS id 41C15385DDE9 for ; Fri, 2 Aug 2024 19:02:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 41C15385DDE9 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 41C15385DDE9 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=167.114.26.122 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625379; cv=none; b=toyQdDA8Jp7MxSl/TASIZKyB0zQeXmH1OEJmgHsedQAbS/FDACHbT72la3YMh8XOD7U3Iudw45brqKSLcsOqFwp22b1xPoLRWbQ2InnfT4U7JzL4MyfljS8/AEaTltWXHcsddsZ/tTNSlzovYJhMQqmAVoKV4sXjN9ccPDz9zDI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625379; c=relaxed/simple; bh=bJlJUlytqocYD59R8/azpnS3HqnC/ILkMDl3NUNhOw4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=izXcpxsjtstI66O8cS/2zsI8dXm1UJfaVo6Ls9MXgPbxlTd9opZB7Lc03X1h7xnYwucgF026Zx7KWUZb+m5k/bBWGp6zrDwHl5HPm/3+snKUZcIKPs7M4q/QCb6hf2qZ7tSzwCeYkvvYHUY2SFzV9kLGeL+wxb1elW1iJdnuPw0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625378; bh=bJlJUlytqocYD59R8/azpnS3HqnC/ILkMDl3NUNhOw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QIN18tpMV+10eyhE1TxmcCdIGAjvUdrk5zr0AXQLJMFotJkXlKIEfretfew1aPMVm xGcIXytj5FUVYhW+axjQooba7stuqSTQiyPhbGp720xFAFZadUY0a/LRx7RtbZsZf3 rYl8YyUW9cBZPH9Wx6ZaxZEck30yKmALsvslf60vCO/e3YBY3HuWaomYHxDgku3iLy XWSRSOn0fPJMQvKWJI7B8w4lzDwVUui6UBUa2j8QNE7zklHKuObJ1gZ/H8kJyniypO jxrU8/FR8nTpS9mT49D2Mcsz3FpWJZ2wa4yyF9jfpTsrNI2ujUk0FewKEkqdVkwmHx azueOI7ZrJ6xA== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFb56Hwzz1FYQ; Fri, 2 Aug 2024 15:02:57 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 11/17] nptl: Add for hppa Date: Fri, 2 Aug 2024 15:02:24 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-11-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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~incoming=patchwork.ozlabs.org@sourceware.org This will be required by the rseq extensible ABI implementation on all Linux architectures exposing the __rseq_size and __rseq_offset symbols to set the 'cpu_id' field so applications can test if rseq is registered. Signed-off-by: Michael Jeanson --- sysdeps/hppa/nptl/thread_pointer.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/sysdeps/hppa/nptl/thread_pointer.h b/sysdeps/hppa/nptl/thread_pointer.h new file mode 100644 index 0000000000..93380f3e52 --- /dev/null +++ b/sysdeps/hppa/nptl/thread_pointer.h @@ -0,0 +1,30 @@ +/* __thread_pointer definition. hppa version. + Copyright (C) 2021-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#ifndef _SYS_THREAD_POINTER_H +#define _SYS_THREAD_POINTER_H + +register void *__thread_register asm ("cr27"); + +static inline void * +__thread_pointer (void) +{ + return __thread_register; +} + +#endif /* _SYS_THREAD_POINTER_H */ From patchwork Fri Aug 2 19:02:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1968488 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=oyfgXke5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFg02Jnkz1yZl for ; Sat, 3 Aug 2024 05:06:20 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8239C3861820 for ; Fri, 2 Aug 2024 19:06:18 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by sourceware.org (Postfix) with ESMTPS id 1C3C1385DDE4 for ; Fri, 2 Aug 2024 19:02:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1C3C1385DDE4 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 1C3C1385DDE4 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=167.114.26.122 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625384; cv=none; b=Ry6Ymz9LtkusDdaDWYEmZgrnl0V3k9ZNnvd0vZcR/9Gh6U2pvtDaJh/18hicZEup7LWuHvDDFRx787yCCrdXDZuXsmZxBXdevGeL5Y9inevLP5FGk+77J170y4djNVwOrc1fDbAIgrAHak9zeKRs9NuEY/EqJ5sixugT5kMC1kU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625384; c=relaxed/simple; bh=WIL/OWLKux8StVDM3cnFmF+xbdRRUdWP+o0owx8sma8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=qcIAOBYrijp8rcPFwRHrxHyqcqopeu4cDCCFrmuGBTr3lkM1Dij+wK3citDLc6oNiDS2n7GQ3VcccirnV6vashDfGDwbTX59gc5Ii/eiG6oFbvnA0bcW0xOAunMPzmR0WfjFgFTeV+QsLmrSFWIpoJPTamBHlPC+UNf1s8Eg0Pw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625378; bh=WIL/OWLKux8StVDM3cnFmF+xbdRRUdWP+o0owx8sma8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oyfgXke5mo1+T8CHdUritgVJmiAD7SICMvczGIDTpsgNxvgiWBJvOQPejOXtCHAtK B0H+zfXEoqnffWSsB0xZ1LFFl8StpebTwjDnPhA9PJOpNJgp0PX3Xxw0OKy2A6S8Y9 VJM4Tqhp2qPf0tU8wIVZ4fVmTg7ck8/QOtvP5JheCvYnK0SCbXMYfBgCOjxxp/+92v ogBEt0f1AMe3vSJGgswxum4omvbBSPUOZ7F95c4LiPQIimK7NFkOLaaV87a4sX/RG/ Bns3CkubQkSjTq5sACK0X4hK0ATqJ+bUCrETCD3dFfP/d+e0C0nJU7Zfysci394W/e voCj7RU2/dcvQ== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFb65CDrz1Fl1; Fri, 2 Aug 2024 15:02:58 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 12/17] nptl: Add for csky Date: Fri, 2 Aug 2024 15:02:25 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-12-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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~incoming=patchwork.ozlabs.org@sourceware.org This will be required by the rseq extensible ABI implementation on all Linux architectures exposing the __rseq_size and __rseq_offset symbols to set the 'cpu_id' field so applications can test if rseq is registered. Signed-off-by: Michael Jeanson --- sysdeps/csky/nptl/thread_pointer.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/sysdeps/csky/nptl/thread_pointer.h b/sysdeps/csky/nptl/thread_pointer.h new file mode 100644 index 0000000000..d4847f691a --- /dev/null +++ b/sysdeps/csky/nptl/thread_pointer.h @@ -0,0 +1,30 @@ +/* __thread_pointer definition. csky version. + Copyright (C) 2021-2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#ifndef _SYS_THREAD_POINTER_H +#define _SYS_THREAD_POINTER_H + +register void *__thread_register asm ("r31"); + +static inline void * +__thread_pointer (void) +{ + return __thread_register; +} + +#endif /* _SYS_THREAD_POINTER_H */ From patchwork Fri Aug 2 19:02:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1968482 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=Jq6BDhQR; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFf173mrz1yZl for ; Sat, 3 Aug 2024 05:05:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3BF113860763 for ; Fri, 2 Aug 2024 19:05:28 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [IPv6:2607:5300:203:b2ee::31e5]) by sourceware.org (Postfix) with ESMTPS id E2192385DDC4 for ; Fri, 2 Aug 2024 19:02:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E2192385DDC4 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 E2192385DDC4 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:5300:203:b2ee::31e5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625384; cv=none; b=TGnwczxKxExNm6x9kme0qYItgLqxzDeCl+ZHk+pKtwunkX8oZhL8I+eQYMF8Gz/u4rEHGGD6SeT/oNZqnxzQsZJ0CX4owvhZLQ+6bZEfEyJkDtw+xqOQJxaj7raGRtCk94AV6EypvjMtTIVAuH60Sj6YxoNkLMs4f3R9mbMdjOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625384; c=relaxed/simple; bh=36M3TDuYP6v2jYxKrJK9e8aoGTVsMv5nppmXoUhTmbU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=W5jnUxb12SEld3Dt8jLoenMyLB4lHDFunalT/6vhRUlNY/fEyR2hJZ3imnHyyR4ebuB7Qk9FMyroEiINHSJqmv/dmm0DFZ+kLyftz55pg5fBsucawz5RsFb6T/jkWpgFNgDcC5qxc6xDb+aTd0LlActlYzvBEVEhq93WCayf2mk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625379; bh=36M3TDuYP6v2jYxKrJK9e8aoGTVsMv5nppmXoUhTmbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jq6BDhQRWFs6WzzfAWn50EpkLAOZ7RgpAaMXYqFxTS8PRXEsxKMDrljrkcn35p6uk gUgl5hAx9cjzvCtAh453ULDyP9+H9QO5L+fxLV8mrimdUWN42IbbkPfG2edfBOkzEP fLEDzF2BrxMKvEcu7C3S6pms4cs1RekNF2Y0Mq2DxkGndywkAuDjuLHCfow64JoO8l ZLiu+ZoiRSjBtIHStTRLJW4BRGg8MYltRKM7n5gDxCkyBKXZ9LT9EnQuCj23q8eT3x IYWOW97RX/RwerlGXbdNyOh18d2fAFKAksAlOdT+xUZNvhs4IaEvIBIWeOz51c52p7 QXgu81WcVbBDQ== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFb73sfpz1Fl2; Fri, 2 Aug 2024 15:02:59 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 13/17] nptl: add RSEQ_SIG for RISC-V Date: Fri, 2 Aug 2024 15:02:26 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-13-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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~incoming=patchwork.ozlabs.org@sourceware.org Enable RSEQ for RISC-V, support was added in Linux 5.18. Signed-off-by: Michael Jeanson --- sysdeps/unix/sysv/linux/riscv/bits/rseq.h | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/sysdeps/unix/sysv/linux/riscv/bits/rseq.h b/sysdeps/unix/sysv/linux/riscv/bits/rseq.h new file mode 100644 index 0000000000..dfc1fc9315 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/bits/rseq.h @@ -0,0 +1,44 @@ +/* Restartable Sequences Linux riscv architecture header. + Copyright (C) 2021-2024 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#ifndef _SYS_RSEQ_H +# error "Never use directly; include instead." +#endif + +/* RSEQ_SIG is a signature required before each abort handler code. + + It is a 32-bit value that maps to actual architecture code compiled + into applications and libraries. It needs to be defined for each + architecture. When choosing this value, it needs to be taken into + account that generating invalid instructions may have ill effects on + tools like objdump, and may also have impact on the CPU speculative + execution efficiency in some cases. + + Select the instruction "csrw mhartid, x0" as the RSEQ_SIG. Unlike + other architectures, the ebreak instruction has no immediate field for + distinguishing purposes. Hence, ebreak is not suitable as RSEQ_SIG. + "csrw mhartid, x0" can also satisfy the RSEQ requirement because it + is an uncommon instruction and will raise an illegal instruction + exception when executed in all modes. */ + +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define RSEQ_SIG 0xf1401073 +#else +/* RSEQ is currently only supported on Little-Endian. */ +#endif From patchwork Fri Aug 2 19:02:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1968486 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=ZnqOjMsj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFfq4L6Rz1yZl for ; Sat, 3 Aug 2024 05:06:11 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DCDFD384F02C for ; Fri, 2 Aug 2024 19:06:09 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [IPv6:2607:5300:203:b2ee::31e5]) by sourceware.org (Postfix) with ESMTPS id C4CF43858428 for ; Fri, 2 Aug 2024 19:03:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C4CF43858428 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 C4CF43858428 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:5300:203:b2ee::31e5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625385; cv=none; b=sVLUMbGDA+LfpRvhQcqWFCShp7/ImNY3mvcu8jC5KRDFLuVQTo+3q5KrJBxjfbQXcfwU+oHsZUboFo2S8wMG2sMjOgbxcQmZzEsucVJxkP+r/lozK3Y24J7mgoZtleH9IgsKpcCviP4HVeCS/mAiT83dcN69m8oHk28MZAx6MB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625385; c=relaxed/simple; bh=9I69ZhxQgSZGk0+qDJvi35BijcyLoLfcB/gboc8B98c=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=FQiYqzdOQQsrZ9beDlXUTH1dw/44mskSnupy8hIf+1bu36hLpB40gBp0f3UBmn6wbbjIfTnknOu0BWIrU6aHtQlgsSKT7FFp+fVVt3/iX/vfdfugsd2hyoicCkOk0aNSLonUGakcPa1lpcaBTxU0Z6sW4ir99U+tjEXqXWZMkXk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625380; bh=9I69ZhxQgSZGk0+qDJvi35BijcyLoLfcB/gboc8B98c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZnqOjMsjy3QRBmXfGF0VMyJT1NAYQCBC9yUduECLZXmul4wt48CG01F1pcvqvouxh YAr1CEvoK0rDNuiGvR4oA5kexbIsH4QcbImbDioxmjqFisBsAlHGoMW00PfmB0lYSY Ds3NIxRm/CZ/XVhPs/IXMG7EOVqfzZVGC9+/MhHGCMF4sIEyMWy9Z8fGSP09DlDP5y SjmGsyW2KDA++Ey15Q1JXZEIWhCNQuG+6ItHCQmwWqziHMq+gDDoMnQ9lFyTAsC1sI OVuuo+XcyYY2DipxxUVaa4AabgasFLVvfBUfP7INvNwt0Se9ptn6RGCRBDqf8QW+w8 sCO2cBESoKp/g== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFb832TRz1Fl3; Fri, 2 Aug 2024 15:03:00 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 14/17] nptl: Introduce RSEQ_GETMEM_VOLATILE and RSEQ_SETMEM Date: Fri, 2 Aug 2024 15:02:27 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-14-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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~incoming=patchwork.ozlabs.org@sourceware.org This will be used to access and write to the rseq area in the extra TLS block. Signed-off-by: Michael Jeanson --- sysdeps/i386/nptl/tcb-access.h | 61 ++++++++++++++++++++++++++++++++++++++++ sysdeps/nptl/tcb-access.h | 5 ++++ sysdeps/x86_64/nptl/tcb-access.h | 61 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+) diff --git a/sysdeps/i386/nptl/tcb-access.h b/sysdeps/i386/nptl/tcb-access.h index 4b6221e103..eb40906c48 100644 --- a/sysdeps/i386/nptl/tcb-access.h +++ b/sysdeps/i386/nptl/tcb-access.h @@ -123,3 +123,64 @@ "i" (offsetof (struct pthread, member)), \ "r" (idx)); \ }}) + + +#if IS_IN (rtld) +/* Use the hidden symbol in ld.so. */ +# define rseq_offset_sym _rseq_offset +#else +# define rseq_offset_sym __rseq_offset +#endif + +/* Read member of the RSEQ area directly. */ +#define RSEQ_GETMEM_VOLATILE(descr, member) \ + ({ __typeof (descr->member) __value; \ + _Static_assert (sizeof (__value) == 1 \ + || sizeof (__value) == 4 \ + || sizeof (__value) == 8, \ + "size of per-thread data"); \ + if (sizeof (__value) == 1) \ + asm volatile ("movb %%gs:%P2(%3),%b0" \ + : "=q" (__value) \ + : "0" (0), "i" (offsetof (struct rseq_area, member)), \ + "r" (rseq_offset_sym)); \ + else if (sizeof (__value) == 4) \ + asm volatile ("movl %%gs:%P1(%2),%0" \ + : "=r" (__value) \ + : "i" (offsetof (struct rseq_area, member)), \ + "r" (rseq_offset_sym)); \ + else /* 8 */ \ + { \ + asm volatile ("movl %%gs:%P1(%2),%%eax\n\t" \ + "movl %%gs:4+%P1(%2),%%edx" \ + : "=&A" (__value) \ + : "i" (offsetof (struct rseq_area, member)), \ + "r" (rseq_offset_sym)); \ + } \ + __value; }) + +/* Set member of the RSEQ area directly. */ +#define RSEQ_SETMEM(descr, member, value) \ + ({ \ + _Static_assert (sizeof (descr->member) == 1 \ + || sizeof (descr->member) == 4 \ + || sizeof (descr->member) == 8, \ + "size of per-thread data"); \ + if (sizeof (descr->member) == 1) \ + asm volatile ("movb %b0,%%gs:%P1(%2)" : \ + : "iq" (value), \ + "i" (offsetof (struct rseq_area, member)), \ + "r" (rseq_offset_sym)); \ + else if (sizeof (descr->member) == 4) \ + asm volatile ("movl %0,%%gs:%P1(%2)" : \ + : "ir" (value), \ + "i" (offsetof (struct rseq_area, member)), \ + "r" (rseq_offset_sym)); \ + else /* 8 */ \ + { \ + asm volatile ("movl %%eax,%%gs:%P1(%2)\n\t" \ + "movl %%edx,%%gs:4+%P1(%2)" : \ + : "A" ((uint64_t) cast_to_integer (value)), \ + "i" (offsetof (struct rseq_area, member)), \ + "r" (rseq_offset_sym)); \ + }}) diff --git a/sysdeps/nptl/tcb-access.h b/sysdeps/nptl/tcb-access.h index 600433766f..9532f30022 100644 --- a/sysdeps/nptl/tcb-access.h +++ b/sysdeps/nptl/tcb-access.h @@ -30,3 +30,8 @@ descr->member = (value) #define THREAD_SETMEM_NC(descr, member, idx, value) \ descr->member[idx] = (value) + +#define RSEQ_GETMEM_VOLATILE(descr, member) \ + THREAD_GETMEM_VOLATILE(descr, member) +#define RSEQ_SETMEM(descr, member, value) \ + THREAD_SETMEM(descr, member, value) diff --git a/sysdeps/x86_64/nptl/tcb-access.h b/sysdeps/x86_64/nptl/tcb-access.h index d35948f111..2edead755e 100644 --- a/sysdeps/x86_64/nptl/tcb-access.h +++ b/sysdeps/x86_64/nptl/tcb-access.h @@ -130,3 +130,64 @@ "i" (offsetof (struct pthread, member[0])), \ "r" (idx)); \ }}) + +#if IS_IN (rtld) +/* Use the hidden symbol in ld.so. */ +# define rseq_offset_sym _rseq_offset +#else +# define rseq_offset_sym __rseq_offset +#endif + +/* Read member of the RSEQ area directly. */ +# define RSEQ_GETMEM_VOLATILE(descr, member) \ + ({ __typeof (descr->member) __value; \ + _Static_assert (sizeof (__value) == 1 \ + || sizeof (__value) == 4 \ + || sizeof (__value) == 8, \ + "size of per-thread data"); \ + if (sizeof (__value) == 1) \ + asm volatile ("movb %%fs:%P2(%q3),%b0" \ + : "=q" (__value) \ + : "0" (0), "i" (offsetof (struct rseq_area, member)), \ + "r" (rseq_offset_sym)); \ + else if (sizeof (__value) == 4) \ + asm volatile ("movl %%fs:%P1(%q2),%0" \ + : "=r" (__value) \ + : "i" (offsetof (struct rseq_area, member)), \ + "r" (rseq_offset_sym)); \ + else /* 8 */ \ + { \ + asm volatile ("movq %%fs:%P1(%q2),%q0" \ + : "=r" (__value) \ + : "i" (offsetof (struct rseq_area, member)), \ + "r" (rseq_offset_sym)); \ + } \ + __value; }) + +/* Set member of the RSEQ area directly. */ +# define RSEQ_SETMEM(descr, member, value) \ + ({ \ + _Static_assert (sizeof (descr->member) == 1 \ + || sizeof (descr->member) == 4 \ + || sizeof (descr->member) == 8, \ + "size of per-thread data"); \ + if (sizeof (descr->member) == 1) \ + asm volatile ("movb %b0,%%fs:%P1(%q2)" : \ + : "iq" (value), \ + "i" (offsetof (struct rseq_area, member)), \ + "r" (rseq_offset_sym)); \ + else if (sizeof (descr->member) == 4) \ + asm volatile ("movl %0,%%fs:%P1(%q2)" : \ + : IMM_MODE (value), \ + "i" (offsetof (struct rseq_area, member)), \ + "r" (rseq_offset_sym)); \ + else /* 8 */ \ + { \ + /* Since movq takes a signed 32-bit immediate or a register source \ + operand, use "er" constraint for 32-bit signed integer constant \ + or register. */ \ + asm volatile ("movq %q0,%%fs:%P1(%q2)" : \ + : "er" ((uint64_t) cast_to_integer (value)), \ + "i" (offsetof (struct rseq_area, member)), \ + "r" (rseq_offset_sym)); \ + }}) From patchwork Fri Aug 2 19:02:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1968491 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=LybFlg2X; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFhb4Mktz1yZl for ; Sat, 3 Aug 2024 05:07:43 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D66C1385DDDC for ; Fri, 2 Aug 2024 19:07:41 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by sourceware.org (Postfix) with ESMTPS id A10C23858408 for ; Fri, 2 Aug 2024 19:03:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A10C23858408 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 A10C23858408 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=167.114.26.122 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625385; cv=none; b=aC/CqEgtHD3CL4tKdmQCf1eYfMUUl4iFEhTG64c876H57lOiPOPWcL16oocAuUtehGOhAcBmOMpYt/Zpywb11b0M0vmjLkaZtmZ6TzNZwRH6oaTEUHH4QyKS3riWIts6Px0XCYTnz9MTLlzDDD8IZh7JxfBvTY9HTGOiUDyeYJI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625385; c=relaxed/simple; bh=xM288mpiQcP0wg7wh7+faxmSCPwlA/OCfYU/ITcSKX4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=D0bddSMmFrjIW6trtWdaeIkv9oCvfpk1jaxAQz455OKzZivuLlLS+d8LdJWPczM7zju6ZIyiEZLCC30ZqjpTacYx1VFmlRIDWe8kpiKovx7v80YmAHG7u4fYg4e8THVH4Uq+7twvFQ7iKwFCvZ5G2Ban8bLn5bFCuXHGT0IBIv4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625381; bh=xM288mpiQcP0wg7wh7+faxmSCPwlA/OCfYU/ITcSKX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LybFlg2XJOOCJcRxw3qjuqpBycMvl0Ph1xVkWazcRS/1onVOtDuBxzG8p5cPQCM3u VMjn6ra4CvwUn0fzxulZYeDHuxIo4V667HTeKAD0+g0gNZ5O7dlzuIvpvfeDHSSQjm FJRH1ui2ZUUtbfojZbYeBCZcyfrCOYPVpTI1lGSZDtfaDQ8cQLubQ7Fi1GYtdPotsd ///S+3p9BGfCVDkFa7WgX12kXoFOdT2+XxTz2kTcTlWPLlAc7PkwL6XeUkDbjjpSqd aeAxwt8NzjEKO7UuHEAURX3AFtqNdT1R9/2rAIvQH4O6s/4sOfpITzPlDOfpEOaln0 v8odP9PL4QX7w== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFb91vSFz1Fl4; Fri, 2 Aug 2024 15:03:01 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 15/17] nptl: Move the rseq area to the 'extra TLS' block Date: Fri, 2 Aug 2024 15:02:28 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-15-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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~incoming=patchwork.ozlabs.org@sourceware.org Move the rseq area to the newly added 'extra TLS' block, this is the last step in adding support for the rseq extended ABI. The size of the rseq area is now dynamic and depends on the rseq features reported by the kernel through the elf auxiliary vector. This will allow applications to use rseq features past the 32 bytes of the original rseq ABI as they become available in future kernels. Signed-off-by: Michael Jeanson --- nptl/pthread_create.c | 2 +- sysdeps/nptl/dl-tls_init_tp.c | 20 +++--- sysdeps/unix/sysv/linux/Makefile | 10 +++ sysdeps/unix/sysv/linux/rseq-internal.h | 80 ++++++++++++++++------ sysdeps/unix/sysv/linux/sched_getcpu.c | 3 +- sysdeps/unix/sysv/linux/tst-rseq-disable-static.c | 1 + sysdeps/unix/sysv/linux/tst-rseq-disable.c | 60 ++++++++++++++--- sysdeps/unix/sysv/linux/tst-rseq-nptl-static.c | 1 + sysdeps/unix/sysv/linux/tst-rseq-static.c | 1 + sysdeps/unix/sysv/linux/tst-rseq.c | 81 ++++++++++++++++++----- sysdeps/unix/sysv/linux/tst-rseq.h | 7 +- 11 files changed, 209 insertions(+), 57 deletions(-) diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 1d3665d5ed..9b49ee7121 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -691,7 +691,7 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr, /* Inherit rseq registration state. Without seccomp filters, rseq registration will either always fail or always succeed. */ - if ((int) THREAD_GETMEM_VOLATILE (self, rseq_area.cpu_id) >= 0) + if ((int) RSEQ_GETMEM_VOLATILE (rseq_get_area(), cpu_id) >= 0) pd->flags |= ATTR_FLAG_DO_RSEQ; /* Initialize the field for the ID of the thread which is waiting diff --git a/sysdeps/nptl/dl-tls_init_tp.c b/sysdeps/nptl/dl-tls_init_tp.c index 7803e19fd1..2869a0647d 100644 --- a/sysdeps/nptl/dl-tls_init_tp.c +++ b/sysdeps/nptl/dl-tls_init_tp.c @@ -99,19 +99,19 @@ __tls_init_tp (void) } { + /* If the registration fails or is disabled by tunable, the public rseq + size will be '0' regardless of the feature size of the allocated rseq + area. An rseq area of at least 32 bytes is always allocated since + application code is allowed to test the status of the rseq registration + with 'rseq->cpu_id >= 0'. */ bool do_rseq = true; do_rseq = TUNABLE_GET (rseq, int, NULL); if (rseq_register_current_thread (pd, do_rseq)) - _rseq_size = RSEQ_AREA_SIZE_INITIAL_USED; - -#ifdef RSEQ_SIG - /* This should be a compile-time constant, but the current - infrastructure makes it difficult to determine its value. Not - all targets support __thread_pointer, so set __rseq_offset only - if the rseq registration may have happened because RSEQ_SIG is - defined. */ - _rseq_offset = (char *) &pd->rseq_area - (char *) __thread_pointer (); -#endif + { + /* On successful registration, expose the feature size in the public + '__rseq_size' symbol. */ + _rseq_size = GLRO (dl_rseq_feature_size); + } } /* Set initial thread's stack block from 0 up to __libc_stack_end. diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 59998c7af4..a6c142d363 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -263,6 +263,11 @@ tests-internal += \ tst-rseq-disable \ # tests-internal +tests-static += \ + tst-rseq-disable-static \ + tst-rseq-static \ + # tests-static + tests-time64 += \ tst-adjtimex-time64 \ tst-clock_adjtime-time64 \ @@ -396,6 +401,7 @@ $(objpfx)tst-mount-compile.out: ../sysdeps/unix/sysv/linux/tst-mount-compile.py $(objpfx)tst-mount-compile.out: $(sysdeps-linux-python-deps) tst-rseq-disable-ENV = GLIBC_TUNABLES=glibc.pthread.rseq=0 +tst-rseq-disable-static-ENV = GLIBC_TUNABLES=glibc.pthread.rseq=0 endif # $(subdir) == misc @@ -661,4 +667,8 @@ tests += \ tests-internal += \ tst-rseq-nptl \ # tests-internal + +tests-static += \ + tst-rseq-nptl-static \ + # tests-static endif diff --git a/sysdeps/unix/sysv/linux/rseq-internal.h b/sysdeps/unix/sysv/linux/rseq-internal.h index 2c68b8c70c..ec28d26de0 100644 --- a/sysdeps/unix/sysv/linux/rseq-internal.h +++ b/sysdeps/unix/sysv/linux/rseq-internal.h @@ -24,11 +24,26 @@ #include #include #include +#include +#include -/* 32 is the initially required value for the area size. The - actually used rseq size may be less (20 bytes initially). */ -#define RSEQ_AREA_SIZE_INITIAL 32 -#define RSEQ_AREA_SIZE_INITIAL_USED 20 +/* rseq area registered with the kernel. Use a custom definition here to + isolate from the system provided header which could lack some fields of the + Extended ABI. + + Access to fields of the Extended ABI beyond the 20 bytes of the original ABI + (after 'flags') must be gated by a check of the feature size. */ +struct rseq_area +{ + /* Original ABI. */ + uint32_t cpu_id_start; + uint32_t cpu_id; + uint64_t rseq_cs; + uint32_t flags; + /* Extended ABI. */ + uint32_t node_id; + uint32_t mm_cid; +}; /* Minimum size of the rseq area. */ #define RSEQ_AREA_MIN_SIZE 32 @@ -39,10 +54,28 @@ /* Minimum alignment of the rseq area. */ #define RSEQ_MIN_ALIGN 32 -/* The variables are in .data.relro but are not yet write-protected. */ +/* Size of the active features in the rseq area of the current registration, 0 + if registration failed. + In .data.relro but not yet write-protected. */ extern unsigned int _rseq_size attribute_hidden; + +/* Offset from the thread pointer to the rseq area, always set to allow + checking the registration status by reading the 'cpu_id' field. + In .data.relro but not yet write-protected. */ extern ptrdiff_t _rseq_offset attribute_hidden; +/* Returns a pointer to the current thread rseq area. */ +static inline struct rseq_area * +rseq_get_area(void) +{ +#if IS_IN (rtld) + /* Use the hidden symbol in ld.so. */ + return (struct rseq_area *) ((char *) __thread_pointer() + _rseq_offset); +#else + return (struct rseq_area *) ((char *) __thread_pointer() + __rseq_offset); +#endif +} + #ifdef RSEQ_SIG static inline bool rseq_register_current_thread (struct pthread *self, bool do_rseq) @@ -50,29 +83,38 @@ rseq_register_current_thread (struct pthread *self, bool do_rseq) if (do_rseq) { unsigned int size; -#if IS_IN (rtld) - /* Use the hidden symbol in ld.so. */ - size = _rseq_size; -#else - size = __rseq_size; -#endif - if (size < RSEQ_AREA_SIZE_INITIAL) - /* The initial implementation used only 20 bytes out of 32, - but still expected size 32. */ - size = RSEQ_AREA_SIZE_INITIAL; - int ret = INTERNAL_SYSCALL_CALL (rseq, &self->rseq_area, - size, 0, RSEQ_SIG); + + /* Get the feature size from the auxiliary vector, this will always be at + least 20 bytes. */ + size = GLRO (dl_rseq_feature_size); + + /* The feature size can be smaller than the minimum rseq area size of 32 + bytes that the syscall will accept, if this is the case, bump the size + to the minimum of 32 bytes. */ + if (size < RSEQ_AREA_MIN_SIZE) + size = RSEQ_AREA_MIN_SIZE; + + /* The kernel expects 'rseq_area->rseq_cs == NULL' on registration, zero + the whole rseq area. */ + memset(rseq_get_area(), 0, size); + + int ret = INTERNAL_SYSCALL_CALL (rseq, rseq_get_area(), size, 0, + RSEQ_SIG); if (!INTERNAL_SYSCALL_ERROR_P (ret)) return true; } - THREAD_SETMEM (self, rseq_area.cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED); + + /* If the registration failed or is disabled by tunable, we have to set 'cpu_id' to + RSEQ_CPU_ID_REGISTRATION_FAILED to allow userspace to properly test the + status of the registration. */ + RSEQ_SETMEM (rseq_get_area(), cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED); return false; } #else /* RSEQ_SIG */ static inline bool rseq_register_current_thread (struct pthread *self, bool do_rseq) { - THREAD_SETMEM (self, rseq_area.cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED); + RSEQ_SETMEM (rseq_get_area(), cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED); return false; } #endif /* RSEQ_SIG */ diff --git a/sysdeps/unix/sysv/linux/sched_getcpu.c b/sysdeps/unix/sysv/linux/sched_getcpu.c index 72a3360550..3cdf854316 100644 --- a/sysdeps/unix/sysv/linux/sched_getcpu.c +++ b/sysdeps/unix/sysv/linux/sched_getcpu.c @@ -19,6 +19,7 @@ #include #include #include +#include static int vsyscall_sched_getcpu (void) @@ -36,6 +37,6 @@ vsyscall_sched_getcpu (void) int sched_getcpu (void) { - int cpu_id = THREAD_GETMEM_VOLATILE (THREAD_SELF, rseq_area.cpu_id); + int cpu_id = RSEQ_GETMEM_VOLATILE (rseq_get_area(), cpu_id); return __glibc_likely (cpu_id >= 0) ? cpu_id : vsyscall_sched_getcpu (); } diff --git a/sysdeps/unix/sysv/linux/tst-rseq-disable-static.c b/sysdeps/unix/sysv/linux/tst-rseq-disable-static.c new file mode 100644 index 0000000000..2687d13d3d --- /dev/null +++ b/sysdeps/unix/sysv/linux/tst-rseq-disable-static.c @@ -0,0 +1 @@ +#include "tst-rseq-disable.c" diff --git a/sysdeps/unix/sysv/linux/tst-rseq-disable.c b/sysdeps/unix/sysv/linux/tst-rseq-disable.c index bbc655bec4..b1f4e894f1 100644 --- a/sysdeps/unix/sysv/linux/tst-rseq-disable.c +++ b/sysdeps/unix/sysv/linux/tst-rseq-disable.c @@ -26,32 +26,65 @@ #include #ifdef RSEQ_SIG +# include +# include "tst-rseq.h" + +static __thread struct rseq local_rseq = { + .cpu_id = RSEQ_CPU_ID_REGISTRATION_FAILED, +}; /* Check that rseq can be registered and has not been taken by glibc. */ static void check_rseq_disabled (void) { - struct pthread *pd = THREAD_SELF; + struct rseq *rseq_area = (struct rseq *) ((char *) __thread_pointer () + __rseq_offset); + +#if TLS_TCB_AT_TP + /* The rseq area block should come before the thread pointer and be at least 32 bytes. */ + TEST_VERIFY (__rseq_offset <= RSEQ_TEST_MIN_SIZE); +#elif TLS_DTV_AT_TP + /* The rseq area block should come after the thread pointer. */ + TEST_VERIFY (__rseq_offset >= 0); +#else +# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" +#endif + /* __rseq_flags is unused and should always be '0'. */ TEST_COMPARE (__rseq_flags, 0); - TEST_VERIFY ((char *) __thread_pointer () + __rseq_offset - == (char *) &pd->rseq_area); + + /* When rseq is not registered, __rseq_size should always be '0'. */ TEST_COMPARE (__rseq_size, 0); - TEST_COMPARE ((int) pd->rseq_area.cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED); - int ret = syscall (__NR_rseq, &pd->rseq_area, sizeof (pd->rseq_area), - 0, RSEQ_SIG); + /* When rseq is not registered, the 'cpu_id' field should be set to + RSEQ_CPU_ID_REGISTRATION_FAILED. */ + TEST_COMPARE ((int) rseq_area->cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED); + + /* Test a rseq registration which should succeed since the internal + registration is disabled. */ + int ret = syscall (__NR_rseq, &local_rseq, RSEQ_TEST_MIN_SIZE, 0, RSEQ_SIG); if (ret == 0) { - ret = syscall (__NR_rseq, &pd->rseq_area, sizeof (pd->rseq_area), + /* A successful registration should set the cpu id. */ + TEST_VERIFY (local_rseq.cpu_id >= 0); + + /* Test we can also unregister rseq. */ + ret = syscall (__NR_rseq, &local_rseq, RSEQ_TEST_MIN_SIZE, RSEQ_FLAG_UNREGISTER, RSEQ_SIG); TEST_COMPARE (ret, 0); - pd->rseq_area.cpu_id = RSEQ_CPU_ID_REGISTRATION_FAILED; } else { - TEST_VERIFY (errno != -EINVAL); - TEST_VERIFY (errno != -EBUSY); + /* Check if we failed with EINVAL which would mean an invalid rseq flags, + a mis-aligned rseq area address or an incorrect rseq size. */ + TEST_VERIFY (errno != EINVAL); + + /* Check if we failed with EBUSY which means an existing rseq + registration. */ + TEST_VERIFY (errno != EBUSY); + + /* Check if we failed with EFAULT which means an invalid rseq area + address. */ + TEST_VERIFY (errno != EFAULT); } } @@ -71,6 +104,13 @@ proc_func (void *ignored) static int do_test (void) { + printf ("info: __rseq_size: %u\n", __rseq_size); + printf ("info: __rseq_offset: %td\n", __rseq_offset); + printf ("info: __rseq_flags: %u\n", __rseq_flags); + printf ("info: getauxval (AT_RSEQ_FEATURE_SIZE): %ld\n", + getauxval (AT_RSEQ_FEATURE_SIZE)); + printf ("info: getauxval (AT_RSEQ_ALIGN): %ld\n", getauxval (AT_RSEQ_ALIGN)); + puts ("info: checking main thread"); check_rseq_disabled (); diff --git a/sysdeps/unix/sysv/linux/tst-rseq-nptl-static.c b/sysdeps/unix/sysv/linux/tst-rseq-nptl-static.c new file mode 100644 index 0000000000..6e2c923bb9 --- /dev/null +++ b/sysdeps/unix/sysv/linux/tst-rseq-nptl-static.c @@ -0,0 +1 @@ +#include "tst-rseq-nptl.c" diff --git a/sysdeps/unix/sysv/linux/tst-rseq-static.c b/sysdeps/unix/sysv/linux/tst-rseq-static.c new file mode 100644 index 0000000000..1d97f3bd3d --- /dev/null +++ b/sysdeps/unix/sysv/linux/tst-rseq-static.c @@ -0,0 +1 @@ +#include "tst-rseq.c" diff --git a/sysdeps/unix/sysv/linux/tst-rseq.c b/sysdeps/unix/sysv/linux/tst-rseq.c index 08a9533130..802672e840 100644 --- a/sysdeps/unix/sysv/linux/tst-rseq.c +++ b/sysdeps/unix/sysv/linux/tst-rseq.c @@ -19,6 +19,8 @@ not linked against libpthread. */ #include +#include +#include #include #include #include @@ -32,23 +34,66 @@ # include # include # include +# include # include "tst-rseq.h" static void do_rseq_main_test (void) { - struct pthread *pd = THREAD_SELF; + size_t rseq_align = MAX (getauxval (AT_RSEQ_ALIGN), RSEQ_TEST_MIN_ALIGN); + size_t rseq_feature_size = MAX (getauxval (AT_RSEQ_FEATURE_SIZE), RSEQ_TEST_MIN_FEATURE_SIZE); + size_t rseq_alloc_size = roundup (MAX (rseq_feature_size, RSEQ_TEST_MIN_SIZE), rseq_align); + struct rseq *global_rseq = __thread_pointer () + __rseq_offset; TEST_VERIFY_EXIT (rseq_thread_registered ()); + + /* __rseq_flags is unused and should always be '0'. */ TEST_COMPARE (__rseq_flags, 0); - TEST_VERIFY ((char *) __thread_pointer () + __rseq_offset - == (char *) &pd->rseq_area); - /* The current implementation only supports the initial size. */ - TEST_COMPARE (__rseq_size, 20); + + /* When rseq is registered, __rseq_size should report the feature size. */ + TEST_COMPARE (__rseq_size, rseq_feature_size); + + /* When rseq is registered, the 'cpu_id' field should be set to a valid cpu + * number. */ + TEST_VERIFY ((int32_t) global_rseq->cpu_id >= 0); + + /* The rseq area address must be aligned. */ + TEST_VERIFY (((unsigned long) global_rseq % rseq_align) == 0); + +#if TLS_TCB_AT_TP + /* The rseq area block should come before the thread pointer and be at least 32 bytes. */ + TEST_VERIFY (__rseq_offset <= RSEQ_TEST_MIN_SIZE); +#elif TLS_DTV_AT_TP + /* The rseq area block should come after the thread pointer. */ + TEST_VERIFY (__rseq_offset >= 0); +#else +# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" +#endif + + /* Test a rseq registration with the same arguments as the internal + registration which should fail with errno == EBUSY. */ + TEST_VERIFY (((unsigned long) global_rseq % rseq_align) == 0); + TEST_VERIFY (__rseq_size <= rseq_alloc_size); + int ret = syscall (__NR_rseq, global_rseq, rseq_alloc_size, 0, RSEQ_SIG); + TEST_VERIFY (ret != 0); + TEST_COMPARE (errno, EBUSY); +} + +static void * +thread_func (void *ignored) +{ + do_rseq_main_test (); + return NULL; } static void -do_rseq_test (void) +proc_func (void *ignored) +{ + do_rseq_main_test (); +} + +static int +do_test (void) { if (!rseq_available ()) { @@ -60,21 +105,27 @@ do_rseq_test (void) printf ("info: getauxval (AT_RSEQ_FEATURE_SIZE): %ld\n", getauxval (AT_RSEQ_FEATURE_SIZE)); printf ("info: getauxval (AT_RSEQ_ALIGN): %ld\n", getauxval (AT_RSEQ_ALIGN)); + + puts ("info: checking main thread"); + do_rseq_main_test (); + + puts ("info: checking main thread (2)"); do_rseq_main_test (); + + puts ("info: checking new thread"); + xpthread_join (xpthread_create (NULL, thread_func, NULL)); + + puts ("info: checking subprocess"); + support_isolate_in_subprocess (proc_func, NULL); + + return 0; } #else /* RSEQ_SIG */ -static void -do_rseq_test (void) -{ - FAIL_UNSUPPORTED ("glibc does not define RSEQ_SIG, skipping test"); -} -#endif /* RSEQ_SIG */ - static int do_test (void) { - do_rseq_test (); - return 0; + FAIL_UNSUPPORTED ("glibc does not define RSEQ_SIG, skipping test"); } +#endif /* RSEQ_SIG */ #include diff --git a/sysdeps/unix/sysv/linux/tst-rseq.h b/sysdeps/unix/sysv/linux/tst-rseq.h index dc603327d3..7a2e19b07f 100644 --- a/sysdeps/unix/sysv/linux/tst-rseq.h +++ b/sysdeps/unix/sysv/linux/tst-rseq.h @@ -23,11 +23,16 @@ #include #include #include +#include + +#define RSEQ_TEST_MIN_SIZE 32 +#define RSEQ_TEST_MIN_FEATURE_SIZE 20 +#define RSEQ_TEST_MIN_ALIGN 32 static inline bool rseq_thread_registered (void) { - return THREAD_GETMEM_VOLATILE (THREAD_SELF, rseq_area.cpu_id) >= 0; + return RSEQ_GETMEM_VOLATILE (rseq_get_area(), cpu_id) >= 0; } static inline int From patchwork Fri Aug 2 19:02:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1968490 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=jWK84zZz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFgn6qvxz1yZl for ; Sat, 3 Aug 2024 05:07:01 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 36155385DDE3 for ; Fri, 2 Aug 2024 19:07:00 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [IPv6:2607:5300:203:b2ee::31e5]) by sourceware.org (Postfix) with ESMTPS id 7A6BD3858D3C for ; Fri, 2 Aug 2024 19:03:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A6BD3858D3C 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 7A6BD3858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:5300:203:b2ee::31e5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625385; cv=none; b=CI8TG7Tvz3HGSSJ02Z9oR0duarHKgqFQL8M1R4ITJXL+I6vo357o8YX/lzDXePZYicXPv5MmikJCS5SDLdgKIVVHvXwPIISBDlzALE8svwO7lhHIUPKxwbQV+qrXuk7TTsXhuxxRhKMHHtT24Fadz33DkBhzc+2lHYrCyqPDhe0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625385; c=relaxed/simple; bh=DjBqEzzWXoZiEY07GyKMKFy+4DEzwA5wL5sw5FD24mw=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ntT3pwCL4VSn/JJnjLfbITXzSQn0GGhF2HcamqjXf0YRGhuQ9mZCIt8+PzfllUTnHo8KYVdp2bXjUoDBJW+egMTb4plS9cGYZVSp8s95pih/2zs24CCjdS4i0n2E9hEXB9BUcHlUEmj0xnhihbi7wwL9LnRA6v4FuMYtBnJ6nlI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625382; bh=DjBqEzzWXoZiEY07GyKMKFy+4DEzwA5wL5sw5FD24mw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jWK84zZz1EHRGPDa9g9PUowXcp+7z+e7PA9wxQ97P3uPUeVx0jLPLBz8DCt4FYMj0 SXo4BjcaAJWP5WvqWt0dxNYPMneK2835Zat6BalceSsJrl8zZwljHrG3nRhcYQNjcl LbXOVZ2+PYwGw2MX1C889fdL2SPI1leEHdob+Gf3B2YyRQaihDt5j4e2OiMAHX0XF0 V5lB3CJDJXf7nQhP6E1GQm3VmEBA2E4UUks0niHokGvBUaULOE2cLcAvSvfuNBpz9d HY/Vz0a+26B25ZngpgO0qFCNsaPIrQm35XdOWB8efXzRlCgPFOhzGLwlNvYYKI7GdO Et2QtGtYYMsQg== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFbB0sBbz1FQc; Fri, 2 Aug 2024 15:03:02 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 16/17] nptl: Remove the rseq area from 'struct pthread' Date: Fri, 2 Aug 2024 15:02:29 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-16-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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~incoming=patchwork.ozlabs.org@sourceware.org The rseq extensible ABI implementation moved the rseq area to the 'extra TLS' block, remove the unused 'rseq_area' member of 'struct pthread'. Signed-off-by: Michael Jeanson --- nptl/descr.h | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/nptl/descr.h b/nptl/descr.h index 8cef95810c..cdc3c82d9a 100644 --- a/nptl/descr.h +++ b/nptl/descr.h @@ -404,25 +404,11 @@ struct pthread /* Used on strsignal. */ struct tls_internal_t tls_state; - /* rseq area registered with the kernel. Use a custom definition - here to isolate from kernel struct rseq changes. The - implementation of sched_getcpu needs acccess to the cpu_id field; - the other fields are unused and not included here. */ - union - { - struct - { - uint32_t cpu_id_start; - uint32_t cpu_id; - }; - char pad[32]; /* Original rseq area size. */ - } rseq_area __attribute__ ((aligned (32))); - /* Amount of end padding, if any, in this structure. - This definition relies on rseq_area being last. */ + This definition relies on tls_state being last. */ #define PTHREAD_STRUCT_END_PADDING \ - (sizeof (struct pthread) - offsetof (struct pthread, rseq_area) \ - + sizeof ((struct pthread) {}.rseq_area)) + (sizeof (struct pthread) - offsetof (struct pthread, tls_state) \ + + sizeof ((struct pthread) {}.tls_state)) } __attribute ((aligned (TCB_ALIGNMENT))); static inline bool From patchwork Fri Aug 2 19:02:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1968489 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=tmD77Jvc; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFgf3yt7z1yZl for ; Sat, 3 Aug 2024 05:06:54 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D0DED386075E for ; Fri, 2 Aug 2024 19:06:52 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by sourceware.org (Postfix) with ESMTPS id 55501385842C for ; Fri, 2 Aug 2024 19:03:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 55501385842C 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 55501385842C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=167.114.26.122 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625386; cv=none; b=q3yac4nw4Gy87HBdqpBpCwXgj9ZVBOSPcvgDRIEbU2XhhOccK0Zn8s4uHuyeoDrvzyca1JAc8lmgVqMdZ7wg3dQsriSbA9w2HeCt1mklZYzGKqivM1pihv/1l3apxl08pABrrxUh4mSVNBsaVskN4UtDEruWPYQ5j3EDeMVoiXw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625386; c=relaxed/simple; bh=qPsYBnF32gRLZzsnFN7VpeHAfF6ekNMvuLkqY2e8DcU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=fjriOTlm3axWoRGZ2JieharRBW3p8wURL86Suxpwgr0LdRL8MW0oUwA8XWAiL2t4DMHIV/QnIxCN8xi2vYR+nNQszLKjUZOpUAdclaNWLbPIkUj7GIqbVpm5IJULH8mLj5ghEa9cgk6NxtYmCGi7wybNE7xv9EMCRVj+1X1+o5c= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625383; bh=qPsYBnF32gRLZzsnFN7VpeHAfF6ekNMvuLkqY2e8DcU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tmD77JvcLJtC2Zx7TfJdElhPoYhH6GroYIUqLuI1cV/zQARlJ196m47VCZy+PluwB 2IxU/EmhjPttn6aM1zkZSbeWXjtcwbRuDGBxYVKqQCVubvIhInEN8AJsPz5B0RnA/0 +qu/TXfVUiZH3mLLnE16rDnDhBHzG4OfOGuusx2yuZk5NP29kGu8RGkZcjJpYS+r6W /H2EE/WFhOancS7HbQSFHh4EzwWHYkz2aTMWuzGdeKtnOG1/tNfgIVV5PtuMqYpGcZ R/OJajuGxJgvjwaXr75mIdODIEqLq+/Rt6SDQZt7/RPg7k8qNb+4fXkM2hTIpI0CJ9 1zo/3XfmhS3tQ== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFbB6kXWz1FnQ; Fri, 2 Aug 2024 15:03:02 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 17/17] Linux: Update internal copy of '' Date: Fri, 2 Aug 2024 15:02:30 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-17-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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~incoming=patchwork.ozlabs.org@sourceware.org Sync the internal copy of '' with the latest Linux kernel 'include/uapi/linux/rseq.h'. Signed-off-by: Michael Jeanson --- sysdeps/unix/sysv/linux/sys/rseq.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sysdeps/unix/sysv/linux/sys/rseq.h b/sysdeps/unix/sysv/linux/sys/rseq.h index b8afab8945..7f0c27fc42 100644 --- a/sysdeps/unix/sysv/linux/sys/rseq.h +++ b/sysdeps/unix/sysv/linux/sys/rseq.h @@ -152,6 +152,17 @@ struct rseq Inhibit instruction sequence block restart on migration for this thread. */ uint32_t flags; + /* Restartable sequences node_id field. Updated by the kernel. Read by + user-space with single-copy atomicity semantics. This field should only + be read by the thread which registered this data structure. Aligned on + 32-bit. Contains the current NUMA node ID. */ + uint32_t node_id; + /* Restartable sequences mm_cid field. Updated by the kernel. Read by + user-space with single-copy atomicity semantics. This field should only + be read by the thread which registered this data structure. Aligned on + 32-bit. Contains the current thread's concurrency ID (allocated + uniquely within a memory map). */ + uint32_t mm_cid; } __attribute__ ((__aligned__ (32))); #endif /* __GLIBC_HAVE_KERNEL_RSEQ */