From patchwork Mon Dec 6 13:53:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 48535 X-Patchwork-Delegate: szabolcs.nagy@arm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D298A3858422 for ; Mon, 6 Dec 2021 13:54:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D298A3858422 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1638798842; bh=YF5ov5NjUQhRfpnsCaM+dXKGj9tYyEs/dNclc8a0/XE=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=sx68f9M+r9RWnzt7t2dMZdcRBZDF57/Rx+o9OjLuytHf2wgKk9pAc2bbRxjsh2nND zPDDS/0Ffw5iwK27j157sgLm0r4bT/PD1bKAvYRVhMLb55F80goBv+NLkaJlFOGyEg aXpkq5zuDRN8Ekybp6iRJkVAHJqOJkGOvZm7YIJA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 05A1E3858D28 for ; Mon, 6 Dec 2021 13:53:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 05A1E3858D28 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-523-7STSgw8kPaGVAj8LikMuvA-1; Mon, 06 Dec 2021 08:53:34 -0500 X-MC-Unique: 7STSgw8kPaGVAj8LikMuvA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3795D1015DA0 for ; Mon, 6 Dec 2021 13:53:33 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.193.123]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC5FC5D740 for ; Mon, 6 Dec 2021 13:53:31 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 5/5] nptl: Add public rseq symbols and In-Reply-To: References: Date: Mon, 06 Dec 2021 14:53:29 +0100 Message-ID: <87y24xon52.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" The relationship between the thread pointer and the rseq area is made explicit. The constant offset can be used by JIT compilers to optimize rseq access (e.g., for really fast sched_getcpu). Extensibility is provided through __rseq_size and __rseq_flags. (In the future, the kernel could request a different rseq size via the auxiliary vector.) Co-Authored-By: Mathieu Desnoyers Tested on aarch64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, s390x-linux-gnu, x86_64-linux-gnu. Built with build-many-glibcs.py (except for a late fix to actually install the public headers). --- NEWS | 11 +++ manual/threads.texi | 81 ++++++++++++++++++++++ sysdeps/nptl/dl-tls_init_tp.c | 18 ++++- sysdeps/unix/sysv/linux/Makefile | 3 +- sysdeps/unix/sysv/linux/Versions | 5 ++ sysdeps/unix/sysv/linux/aarch64/ld.abilist | 3 + sysdeps/unix/sysv/linux/alpha/ld.abilist | 3 + sysdeps/unix/sysv/linux/arc/ld.abilist | 3 + sysdeps/unix/sysv/linux/arm/be/ld.abilist | 3 + sysdeps/unix/sysv/linux/arm/le/ld.abilist | 3 + sysdeps/unix/sysv/linux/csky/ld.abilist | 3 + sysdeps/unix/sysv/linux/hppa/ld.abilist | 3 + sysdeps/unix/sysv/linux/i386/ld.abilist | 3 + sysdeps/unix/sysv/linux/ia64/ld.abilist | 3 + sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist | 3 + sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist | 3 + sysdeps/unix/sysv/linux/microblaze/ld.abilist | 3 + sysdeps/unix/sysv/linux/mips/mips32/ld.abilist | 3 + sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist | 3 + sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist | 3 + sysdeps/unix/sysv/linux/nios2/ld.abilist | 3 + .../unix/sysv/linux/powerpc/powerpc32/ld.abilist | 3 + .../sysv/linux/powerpc/powerpc64/be/ld.abilist | 3 + .../sysv/linux/powerpc/powerpc64/le/ld.abilist | 3 + sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist | 3 + sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist | 3 + sysdeps/unix/sysv/linux/rseq-internal.h | 8 ++- sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist | 3 + sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist | 3 + sysdeps/unix/sysv/linux/sh/be/ld.abilist | 3 + sysdeps/unix/sysv/linux/sh/le/ld.abilist | 3 + sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist | 3 + sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist | 3 + sysdeps/unix/sysv/linux/sys/rseq.h | 10 +++ sysdeps/unix/sysv/linux/tst-rseq-disable.c | 6 ++ sysdeps/unix/sysv/linux/tst-rseq.c | 8 +++ sysdeps/unix/sysv/linux/x86_64/64/ld.abilist | 3 + sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist | 3 + 38 files changed, 232 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 1398cf2e87..8744a92532 100644 --- a/NEWS +++ b/NEWS @@ -68,6 +68,17 @@ Major new features: to be used by compilers for optimizing usage of 'memcmp' when its return value is only used for its boolean status. +* Support for automatically registering threads with the Linux rseq + system call has been added. This system call is implemented starting + from Linux 4.18. The Restartable Sequences ABI accelerates user-space + operations on per-cpu data. It allows user-space to perform updates + on per-cpu data without requiring heavy-weight atomic operations. + Automatically registering threads allows all libraries, including + libc, to make immediate use of the rseq support by using the + documented ABI, via the __rseq_flags, __rseq_offset, and __rseq_size + variables. The GNU C Library manual has details on integration of + Restartable Sequences. + Deprecated and removed features, and other changes affecting compatibility: * The r_version update in the debugger interface makes the glibc binary diff --git a/manual/threads.texi b/manual/threads.texi index 06b6b277a1..7b6170cbd0 100644 --- a/manual/threads.texi +++ b/manual/threads.texi @@ -629,6 +629,8 @@ the standard. * Waiting with Explicit Clocks:: Functions for waiting with an explicit clock specification. * Single-Threaded:: Detecting single-threaded execution. +* Restartable Sequences:: Linux-specific restartable sequences + integration. @end menu @node Default Thread Attributes @@ -958,6 +960,85 @@ application-created thread because future versions of @theglibc{} may create background threads after the first thread has been created, and the application has no way of knowning that these threads are present. +@node Restartable Sequences +@subsubsection Restartable Sequences + +This section describes restartable sequences integration for +@theglibc{}. This functionality is only available on Linux. + +@deftp {Data Type} {struct rseq} +@standards{Linux, sys/rseq.h} +The type of the restartable sequences area. Future versions +of Linux may add additional fields to the end of this structure. + + +Users need to obtain the address of the restartable sequences area using +the thread pointer and the @code{__rseq_offset} variable, described +below. + +One use of the restartable sequences area is to read the current CPU +number from its @code{cpu_id} field, as an inline version of +@code{sched_getcpu}. @Theglibc{} sets the @code{cpu_id} field to +@code{RSEQ_CPU_ID_REGISTRATION_FAILED} if registration failed or was +explicitly disabled. + +Furthermore, users can store the address of a @code{struct rseq_cs} +object into the @code{rseq_cs} field of @code{struct rseq}, thus +informing the kernel that the thread enters a restartable sequence +critical section. This pointer and the code areas it itself points to +must not be left pointing to memory areas which are freed or re-used. +Several approaches can guarantee this. If the application or library +can guarantee that the memory used to hold the @code{struct rseq_cs} and +the code areas it refers to are never freed or re-used, no special +action must be taken. Else, before that memory is re-used of freed, the +application is responsible for setting the @code{rseq_cs} field to +@code{NULL} in each thread's restartable sequence area to guarantee that +it does not leak dangling references. Because the application does not +typically have knowledge of libraries' use of restartable sequences, it +is recommended that libraries using restartable sequences which may end +up freeing or re-using their memory set the @code{rseq_cs} field to +@code{NULL} before returning from library functions which use +restartable sequences. + +The manual for the @code{rseq} system call can be found +at @uref{https://git.kernel.org/pub/scm/libs/librseq/librseq.git/tree/doc/man/rseq.2}. +@end deftp + +@deftypevar {int} __rseq_offset +@standards{Linux, sys/rseq.h} +This variable contains the offset between the thread pointer (as defined +by @code{__builtin_thread_pointer} or the thread pointer register for +the architecture) and the restartable sequences area. This value is the +same for all threads in the process. If the restartable sequences area +is located at a lower address than the location to whic the thread +pointer points, the value is negative. +@end deftypevar + +@deftypevar {int} __rseq_size +@standards{Linux, sys/rseq.h} +This variable is either zero (if restartable sequence registration +failed or has been disabled) or the size of the restartable sequence +registration. This can be less can be different from the size of +@code{struct rseq} if the kernel has extended the size of the +registration. If registration is successful, @code{__rseq_size} is at +least 32 (the initial size of @code{struct rseq}. +@end deftypevar + +@deftypevar {unsigned int} __rseq_flags +@standards{Linux, sys/rseq.h} +The flags used during restartable sequence registration with the kernel. +Currently zero. +@end deftypevar + +@deftypevr Macro int RSEQ_SIG +@standards{Linux, sys/rseq.h} +Each supported architecture provides a @code{RSEQ_SIG} macro in +@file{sys/rseq.h} which contains a signature. That signature is +expected to be present in the code before each restartable sequences +abort handler. Failure to provide the expected signature may terminate +the process with a segmentation fault. +@end deftypevr + @c FIXME these are undocumented: @c pthread_atfork @c pthread_attr_destroy diff --git a/sysdeps/nptl/dl-tls_init_tp.c b/sysdeps/nptl/dl-tls_init_tp.c index b39dfbff2c..82aa7083c1 100644 --- a/sysdeps/nptl/dl-tls_init_tp.c +++ b/sysdeps/nptl/dl-tls_init_tp.c @@ -22,6 +22,7 @@ #include #include #include +#include #define TUNABLE_NAMESPACE pthread #include @@ -43,6 +44,10 @@ rtld_mutex_dummy (pthread_mutex_t *lock) } #endif +const unsigned int __rseq_flags; +const unsigned int __rseq_size attribute_relro; +const int __rseq_offset attribute_relro; + void __tls_pre_init_tp (void) { @@ -100,7 +105,18 @@ __tls_init_tp (void) #if HAVE_TUNABLES do_rseq = TUNABLE_GET (rseq, int, NULL); #endif - rseq_register_current_thread (pd, do_rseq); + if (rseq_register_current_thread (pd, do_rseq)) + { + /* We need a writable view of the variables. They are in + .data.relro and are not yet write-protected. */ + extern unsigned int size __asm__ ("__rseq_size"); + size = sizeof (pd->rseq_area); + } + + /* This should be a compile-time constant, but the current + infrastructure makes it difficult to determine its value. */ + extern int offset __asm__ ("__rseq_offset"); + offset = (char *) &pd->rseq_area - (char *) __thread_pointer (); } /* 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 62a796f214..61acc1987d 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -112,7 +112,8 @@ sysdep_headers += sys/mount.h sys/acct.h \ bits/types/struct_semid64_ds_helper.h \ bits/types/struct_shmid64_ds.h \ bits/types/struct_shmid64_ds_helper.h \ - bits/pthread_stack_min.h bits/pthread_stack_min-dynamic.h + bits/pthread_stack_min.h bits/pthread_stack_min-dynamic.h \ + sys/rseq.h bits/rseq.h tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \ tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \ diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index 26452f3f17..3f8809a158 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -316,6 +316,11 @@ librt { } ld { + GLIBC_2.35 { + __rseq_flags; + __rseq_offset; + __rseq_size; + } GLIBC_PRIVATE { __nptl_change_stack_perm; } diff --git a/sysdeps/unix/sysv/linux/aarch64/ld.abilist b/sysdeps/unix/sysv/linux/aarch64/ld.abilist index 80b2fe6725..717a35f242 100644 --- a/sysdeps/unix/sysv/linux/aarch64/ld.abilist +++ b/sysdeps/unix/sysv/linux/aarch64/ld.abilist @@ -3,3 +3,6 @@ GLIBC_2.17 __stack_chk_guard D 0x8 GLIBC_2.17 __tls_get_addr F GLIBC_2.17 _dl_mcount F GLIBC_2.17 _r_debug D 0x28 +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 diff --git a/sysdeps/unix/sysv/linux/alpha/ld.abilist b/sysdeps/unix/sysv/linux/alpha/ld.abilist index 98a03f611f..76911bd7f8 100644 --- a/sysdeps/unix/sysv/linux/alpha/ld.abilist +++ b/sysdeps/unix/sysv/linux/alpha/ld.abilist @@ -2,4 +2,7 @@ GLIBC_2.0 _r_debug D 0x28 GLIBC_2.1 __libc_stack_end D 0x8 GLIBC_2.1 _dl_mcount F GLIBC_2.3 __tls_get_addr F +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 GLIBC_2.4 __stack_chk_guard D 0x8 diff --git a/sysdeps/unix/sysv/linux/arc/ld.abilist b/sysdeps/unix/sysv/linux/arc/ld.abilist index 048f17c848..71c67f9803 100644 --- a/sysdeps/unix/sysv/linux/arc/ld.abilist +++ b/sysdeps/unix/sysv/linux/arc/ld.abilist @@ -3,3 +3,6 @@ GLIBC_2.32 __stack_chk_guard D 0x4 GLIBC_2.32 __tls_get_addr F GLIBC_2.32 _dl_mcount F GLIBC_2.32 _r_debug D 0x14 +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 diff --git a/sysdeps/unix/sysv/linux/arm/be/ld.abilist b/sysdeps/unix/sysv/linux/arm/be/ld.abilist index cc8825c3bc..3859433b21 100644 --- a/sysdeps/unix/sysv/linux/arm/be/ld.abilist +++ b/sysdeps/unix/sysv/linux/arm/be/ld.abilist @@ -1,3 +1,6 @@ +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 GLIBC_2.4 __libc_stack_end D 0x4 GLIBC_2.4 __stack_chk_guard D 0x4 GLIBC_2.4 __tls_get_addr F diff --git a/sysdeps/unix/sysv/linux/arm/le/ld.abilist b/sysdeps/unix/sysv/linux/arm/le/ld.abilist index cc8825c3bc..3859433b21 100644 --- a/sysdeps/unix/sysv/linux/arm/le/ld.abilist +++ b/sysdeps/unix/sysv/linux/arm/le/ld.abilist @@ -1,3 +1,6 @@ +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 GLIBC_2.4 __libc_stack_end D 0x4 GLIBC_2.4 __stack_chk_guard D 0x4 GLIBC_2.4 __tls_get_addr F diff --git a/sysdeps/unix/sysv/linux/csky/ld.abilist b/sysdeps/unix/sysv/linux/csky/ld.abilist index 564ac09737..6bfc582b73 100644 --- a/sysdeps/unix/sysv/linux/csky/ld.abilist +++ b/sysdeps/unix/sysv/linux/csky/ld.abilist @@ -3,3 +3,6 @@ GLIBC_2.29 __stack_chk_guard D 0x4 GLIBC_2.29 __tls_get_addr F GLIBC_2.29 _dl_mcount F GLIBC_2.29 _r_debug D 0x14 +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 diff --git a/sysdeps/unix/sysv/linux/hppa/ld.abilist b/sysdeps/unix/sysv/linux/hppa/ld.abilist index d155a59843..efccd6a023 100644 --- a/sysdeps/unix/sysv/linux/hppa/ld.abilist +++ b/sysdeps/unix/sysv/linux/hppa/ld.abilist @@ -2,4 +2,7 @@ GLIBC_2.2 __libc_stack_end D 0x4 GLIBC_2.2 _dl_mcount F GLIBC_2.2 _r_debug D 0x14 GLIBC_2.3 __tls_get_addr F +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 GLIBC_2.4 __stack_chk_guard D 0x4 diff --git a/sysdeps/unix/sysv/linux/i386/ld.abilist b/sysdeps/unix/sysv/linux/i386/ld.abilist index 0478e22071..1eb94ae75f 100644 --- a/sysdeps/unix/sysv/linux/i386/ld.abilist +++ b/sysdeps/unix/sysv/linux/i386/ld.abilist @@ -3,3 +3,6 @@ GLIBC_2.1 __libc_stack_end D 0x4 GLIBC_2.1 _dl_mcount F GLIBC_2.3 ___tls_get_addr F GLIBC_2.3 __tls_get_addr F +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 diff --git a/sysdeps/unix/sysv/linux/ia64/ld.abilist b/sysdeps/unix/sysv/linux/ia64/ld.abilist index 33f91199bf..2cc68bcf7b 100644 --- a/sysdeps/unix/sysv/linux/ia64/ld.abilist +++ b/sysdeps/unix/sysv/linux/ia64/ld.abilist @@ -2,3 +2,6 @@ GLIBC_2.2 __libc_stack_end D 0x8 GLIBC_2.2 _dl_mcount F GLIBC_2.2 _r_debug D 0x28 GLIBC_2.3 __tls_get_addr F +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist index cc8825c3bc..3859433b21 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist @@ -1,3 +1,6 @@ +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 GLIBC_2.4 __libc_stack_end D 0x4 GLIBC_2.4 __stack_chk_guard D 0x4 GLIBC_2.4 __tls_get_addr F diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist index 3ba474c27f..e62b2742af 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist @@ -2,4 +2,7 @@ GLIBC_2.0 _r_debug D 0x14 GLIBC_2.1 __libc_stack_end D 0x4 GLIBC_2.1 _dl_mcount F GLIBC_2.3 __tls_get_addr F +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 GLIBC_2.4 __stack_chk_guard D 0x4 diff --git a/sysdeps/unix/sysv/linux/microblaze/ld.abilist b/sysdeps/unix/sysv/linux/microblaze/ld.abilist index a4933c3541..5d63d74e8f 100644 --- a/sysdeps/unix/sysv/linux/microblaze/ld.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/ld.abilist @@ -3,3 +3,6 @@ GLIBC_2.18 __stack_chk_guard D 0x4 GLIBC_2.18 __tls_get_addr F GLIBC_2.18 _dl_mcount F GLIBC_2.18 _r_debug D 0x14 +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 diff --git a/sysdeps/unix/sysv/linux/mips/mips32/ld.abilist b/sysdeps/unix/sysv/linux/mips/mips32/ld.abilist index be09641a48..53ca22de2f 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/ld.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/ld.abilist @@ -2,4 +2,7 @@ GLIBC_2.0 _r_debug D 0x14 GLIBC_2.2 __libc_stack_end D 0x4 GLIBC_2.2 _dl_mcount F GLIBC_2.3 __tls_get_addr F +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 GLIBC_2.4 __stack_chk_guard D 0x4 diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist index be09641a48..53ca22de2f 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist @@ -2,4 +2,7 @@ GLIBC_2.0 _r_debug D 0x14 GLIBC_2.2 __libc_stack_end D 0x4 GLIBC_2.2 _dl_mcount F GLIBC_2.3 __tls_get_addr F +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 GLIBC_2.4 __stack_chk_guard D 0x4 diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist index 1ea36e13f2..d1cdd68333 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist @@ -2,4 +2,7 @@ GLIBC_2.0 _r_debug D 0x28 GLIBC_2.2 __libc_stack_end D 0x8 GLIBC_2.2 _dl_mcount F GLIBC_2.3 __tls_get_addr F +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 GLIBC_2.4 __stack_chk_guard D 0x8 diff --git a/sysdeps/unix/sysv/linux/nios2/ld.abilist b/sysdeps/unix/sysv/linux/nios2/ld.abilist index 52178802dd..bcbba1823e 100644 --- a/sysdeps/unix/sysv/linux/nios2/ld.abilist +++ b/sysdeps/unix/sysv/linux/nios2/ld.abilist @@ -3,3 +3,6 @@ GLIBC_2.21 __stack_chk_guard D 0x4 GLIBC_2.21 __tls_get_addr F GLIBC_2.21 _dl_mcount F GLIBC_2.21 _r_debug D 0x14 +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist index 4bbfba7a61..0d033cb8bd 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist @@ -4,3 +4,6 @@ GLIBC_2.1 _dl_mcount F GLIBC_2.22 __tls_get_addr_opt F GLIBC_2.23 __parse_hwcap_and_convert_at_platform F GLIBC_2.3 __tls_get_addr F +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist index 283fb4510b..9c627b1ddf 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist @@ -4,3 +4,6 @@ GLIBC_2.3 __libc_stack_end D 0x8 GLIBC_2.3 __tls_get_addr F GLIBC_2.3 _dl_mcount F GLIBC_2.3 _r_debug D 0x28 +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist index b1f313c7cd..3a748c2817 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist @@ -4,3 +4,6 @@ GLIBC_2.17 _dl_mcount F GLIBC_2.17 _r_debug D 0x28 GLIBC_2.22 __tls_get_addr_opt F GLIBC_2.23 __parse_hwcap_and_convert_at_platform F +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist index 94ca64c43d..4c67ea18d6 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist @@ -3,3 +3,6 @@ GLIBC_2.33 __stack_chk_guard D 0x4 GLIBC_2.33 __tls_get_addr F GLIBC_2.33 _dl_mcount F GLIBC_2.33 _r_debug D 0x14 +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist index 845f356c3c..09596f09e2 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist @@ -3,3 +3,6 @@ GLIBC_2.27 __stack_chk_guard D 0x8 GLIBC_2.27 __tls_get_addr F GLIBC_2.27 _dl_mcount F GLIBC_2.27 _r_debug D 0x28 +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 diff --git a/sysdeps/unix/sysv/linux/rseq-internal.h b/sysdeps/unix/sysv/linux/rseq-internal.h index 15bc7ffd6e..9e8f99fd51 100644 --- a/sysdeps/unix/sysv/linux/rseq-internal.h +++ b/sysdeps/unix/sysv/linux/rseq-internal.h @@ -26,7 +26,7 @@ #include #ifdef RSEQ_SIG -static inline void +static inline bool rseq_register_current_thread (struct pthread *self, bool do_rseq) { if (do_rseq) @@ -35,15 +35,17 @@ rseq_register_current_thread (struct pthread *self, bool do_rseq) sizeof (self->rseq_area), 0, RSEQ_SIG); if (!INTERNAL_SYSCALL_ERROR_P (ret)) - return; + return true; } THREAD_SETMEM (self, rseq_area.cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED); + return false; } #else /* RSEQ_SIG */ -static inline void +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); + return false; } #endif /* RSEQ_SIG */ diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist index b56f005beb..2c47004bae 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist @@ -2,3 +2,6 @@ GLIBC_2.0 _r_debug D 0x14 GLIBC_2.1 __libc_stack_end D 0x4 GLIBC_2.1 _dl_mcount F GLIBC_2.3 __tls_get_offset F +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist index 6f788a086d..385a73a257 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist @@ -2,3 +2,6 @@ GLIBC_2.2 __libc_stack_end D 0x8 GLIBC_2.2 _dl_mcount F GLIBC_2.2 _r_debug D 0x28 GLIBC_2.3 __tls_get_offset F +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 diff --git a/sysdeps/unix/sysv/linux/sh/be/ld.abilist b/sysdeps/unix/sysv/linux/sh/be/ld.abilist index d155a59843..efccd6a023 100644 --- a/sysdeps/unix/sysv/linux/sh/be/ld.abilist +++ b/sysdeps/unix/sysv/linux/sh/be/ld.abilist @@ -2,4 +2,7 @@ GLIBC_2.2 __libc_stack_end D 0x4 GLIBC_2.2 _dl_mcount F GLIBC_2.2 _r_debug D 0x14 GLIBC_2.3 __tls_get_addr F +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 GLIBC_2.4 __stack_chk_guard D 0x4 diff --git a/sysdeps/unix/sysv/linux/sh/le/ld.abilist b/sysdeps/unix/sysv/linux/sh/le/ld.abilist index d155a59843..efccd6a023 100644 --- a/sysdeps/unix/sysv/linux/sh/le/ld.abilist +++ b/sysdeps/unix/sysv/linux/sh/le/ld.abilist @@ -2,4 +2,7 @@ GLIBC_2.2 __libc_stack_end D 0x4 GLIBC_2.2 _dl_mcount F GLIBC_2.2 _r_debug D 0x14 GLIBC_2.3 __tls_get_addr F +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 GLIBC_2.4 __stack_chk_guard D 0x4 diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist index 0c6610e3c2..8fb5ff3ef3 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist @@ -2,3 +2,6 @@ GLIBC_2.0 _r_debug D 0x14 GLIBC_2.1 __libc_stack_end D 0x4 GLIBC_2.1 _dl_mcount F GLIBC_2.3 __tls_get_addr F +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist index 33f91199bf..2cc68bcf7b 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist @@ -2,3 +2,6 @@ GLIBC_2.2 __libc_stack_end D 0x8 GLIBC_2.2 _dl_mcount F GLIBC_2.2 _r_debug D 0x28 GLIBC_2.3 __tls_get_addr F +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 diff --git a/sysdeps/unix/sysv/linux/sys/rseq.h b/sysdeps/unix/sysv/linux/sys/rseq.h index c8edff50d4..1215b5d086 100644 --- a/sysdeps/unix/sysv/linux/sys/rseq.h +++ b/sysdeps/unix/sysv/linux/sys/rseq.h @@ -171,4 +171,14 @@ struct rseq #endif /* __GLIBC_HAVE_KERNEL_RSEQ */ +/* Offset from the thread pointer to the rseq area. */ +extern const int __rseq_offset; + +/* Size of the registered rseq area. 0 if the registration was + unsuccessful. */ +extern const unsigned int __rseq_size; + +/* Flags used during rseq registration. */ +extern const unsigned int __rseq_flags; + #endif /* sys/rseq.h */ diff --git a/sysdeps/unix/sysv/linux/tst-rseq-disable.c b/sysdeps/unix/sysv/linux/tst-rseq-disable.c index 000e351872..6d73f77e96 100644 --- a/sysdeps/unix/sysv/linux/tst-rseq-disable.c +++ b/sysdeps/unix/sysv/linux/tst-rseq-disable.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #ifdef RSEQ_SIG @@ -30,6 +31,11 @@ static void check_rseq_disabled (void) { struct pthread *pd = THREAD_SELF; + + TEST_COMPARE (__rseq_flags, 0); + TEST_VERIFY ((char *) __thread_pointer () + __rseq_offset + == (char *) &pd->rseq_area); + 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), diff --git a/sysdeps/unix/sysv/linux/tst-rseq.c b/sysdeps/unix/sysv/linux/tst-rseq.c index 926376b6a5..572c11166f 100644 --- a/sysdeps/unix/sysv/linux/tst-rseq.c +++ b/sysdeps/unix/sysv/linux/tst-rseq.c @@ -29,12 +29,20 @@ # include # include # include +# include +# include # include "tst-rseq.h" static void do_rseq_main_test (void) { + struct pthread *pd = THREAD_SELF; + TEST_VERIFY_EXIT (rseq_thread_registered ()); + TEST_COMPARE (__rseq_flags, 0); + TEST_VERIFY ((char *) __thread_pointer () + __rseq_offset + == (char *) &pd->rseq_area); + TEST_COMPARE (__rseq_size, sizeof (pd->rseq_area)); } static void diff --git a/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist b/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist index d3cdf7611e..49a8f31c93 100644 --- a/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist @@ -2,3 +2,6 @@ GLIBC_2.2.5 __libc_stack_end D 0x8 GLIBC_2.2.5 _dl_mcount F GLIBC_2.2.5 _r_debug D 0x28 GLIBC_2.3 __tls_get_addr F +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4 diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist index c70bccf782..ce68cc6304 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist @@ -2,3 +2,6 @@ GLIBC_2.16 __libc_stack_end D 0x4 GLIBC_2.16 __tls_get_addr F GLIBC_2.16 _dl_mcount F GLIBC_2.16 _r_debug D 0x14 +GLIBC_2.35 __rseq_flags D 0x4 +GLIBC_2.35 __rseq_offset D 0x4 +GLIBC_2.35 __rseq_size D 0x4