[PATCH] Linux: Remove rseq support
Mathieu Desnoyers
mathieu.desnoyers@efficios.com
Thu Jul 16 14:48:54 GMT 2020
----- On Jul 15, 2020, at 11:11 AM, Florian Weimer fweimer@redhat.com wrote:
> The kernel ABI is not finalized, and there are now various proposals
> to change the size of struct rseq, which would make the glibc ABI
> dependent on the version of the kernels used for building glibc.
> This is of course not acceptable.
>
> This reverts commit 48699da1c468543ade14777819bd1b4d652709de ("elf:
> Support at least 32-byte alignment in static dlopen"), commit
> 8f4632deb3545b2949cec5454afc3cb21a0024ea ("Linux: rseq registration
> tests"), commit 6e29cb3f61ff5432c78a1c84b0d9b123a350ab36 ("Linux: Use
> rseq in sched_getcpu if available"), and commit
> 0c76fc3c2b346dc5401dc055d97d4279632b0fb3 ("Linux: Perform rseq
> registration at C startup and thread creation"), resolving the conflicts
> introduced by the ARC port and the TLS static surplus changes.
>
> Tested on x86_64-linux-gnu and built with build-many-glibcs.py.
I agree with this revert, let's take time to discuss and document the
extensible rseq ABI scheme before we freeze it in the glibc ABI.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
>
> ---
> NEWS | 10 -
> csu/libc-tls.c | 6 -
> elf/dl-tls.c | 8 +-
> elf/libc_early_init.c | 5 -
> manual/threads.texi | 64 ------
> nptl/pthread_create.c | 13 --
> sysdeps/generic/rseq-internal.h | 26 ---
> sysdeps/unix/sysv/linux/Makefile | 15 +-
> sysdeps/unix/sysv/linux/Versions | 1 -
> sysdeps/unix/sysv/linux/aarch64/bits/rseq.h | 43 ----
> sysdeps/unix/sysv/linux/aarch64/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/alpha/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/arc/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/arm/be/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/arm/bits/rseq.h | 83 -------
> sysdeps/unix/sysv/linux/arm/le/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/bits/rseq.h | 29 ---
> sysdeps/unix/sysv/linux/csky/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/hppa/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/i386/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/ia64/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/microblaze/be/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/microblaze/le/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/mips/bits/rseq.h | 62 -----
> .../unix/sysv/linux/mips/mips32/fpu/libc.abilist | 1 -
> .../unix/sysv/linux/mips/mips32/nofpu/libc.abilist | 1 -
> .../unix/sysv/linux/mips/mips64/n32/libc.abilist | 1 -
> .../unix/sysv/linux/mips/mips64/n64/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/nios2/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/powerpc/bits/rseq.h | 37 ---
> .../sysv/linux/powerpc/powerpc32/fpu/libc.abilist | 1 -
> .../linux/powerpc/powerpc32/nofpu/libc.abilist | 1 -
> .../sysv/linux/powerpc/powerpc64/be/libc.abilist | 1 -
> .../sysv/linux/powerpc/powerpc64/le/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/rseq-internal.h | 73 ------
> sysdeps/unix/sysv/linux/rseq-sym.c | 26 ---
> sysdeps/unix/sysv/linux/s390/bits/rseq.h | 37 ---
> sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/sched_getcpu.c | 22 +-
> sysdeps/unix/sysv/linux/sh/be/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/sh/le/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/sys/rseq.h | 203 ----------------
> sysdeps/unix/sysv/linux/tst-rseq-nptl.c | 256 ---------------------
> sysdeps/unix/sysv/linux/tst-rseq.c | 64 ------
> sysdeps/unix/sysv/linux/tst-rseq.h | 59 -----
> sysdeps/unix/sysv/linux/x86/bits/rseq.h | 30 ---
> sysdeps/unix/sysv/linux/x86_64/64/libc.abilist | 1 -
> sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist | 1 -
> 54 files changed, 6 insertions(+), 1197 deletions(-)
>
> diff --git a/NEWS b/NEWS
> index 81b014a7ee..ee6fb30067 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -42,16 +42,6 @@ Major new features:
> pthread_attr_getsigmask_np have been added. They allow applications
> to specify the signal mask of a thread created with pthread_create.
>
> -* 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.
> - The GNU C Library manual has details on integration of Restartable
> - Sequences.
> -
> * The GNU C Library now provides the header file <sys/single_threaded.h>
> which declares the variable __libc_single_threaded. Applications are
> encouraged to use this variable for single-thread optimizations,
> diff --git a/csu/libc-tls.c b/csu/libc-tls.c
> index 3f1655f264..06e76bd395 100644
> --- a/csu/libc-tls.c
> +++ b/csu/libc-tls.c
> @@ -112,12 +112,6 @@ __libc_setup_tls (void)
> size_t tcb_offset;
> const ElfW(Phdr) *phdr;
>
> - /* libc.so with rseq has TLS with 32-byte alignment. Static dlopen
> - requires at least 32-byte alignment as well, otherwise loading
> - libc.so will always fail. */
> - if (max_align < 32)
> - max_align = 32;
> -
> struct link_map *main_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
>
> /* Look through the TLS segment if there is any. */
> diff --git a/elf/dl-tls.c b/elf/dl-tls.c
> index 772e70d0f6..9a17427047 100644
> --- a/elf/dl-tls.c
> +++ b/elf/dl-tls.c
> @@ -55,7 +55,7 @@
> but come on top when computing the number of namespaces. */
>
> /* Size of initial-exec TLS in libc.so. */
> -#define LIBC_IE_TLS 192
> +#define LIBC_IE_TLS 160
> /* Size of initial-exec TLS in libraries other than libc.so.
> This should be large enough to cover runtime libraries of the
> compiler such as libgomp and libraries in libc other than libc.so. */
> @@ -190,12 +190,6 @@ void
> _dl_determine_tlsoffset (void)
> {
> size_t max_align = TLS_TCB_ALIGN;
> - /* libc.so with rseq has TLS with 32-byte alignment. Since TLS is
> - initialized before audit modules are loaded and slotinfo
> - information is available, this is not taken into account below in
> - the audit case. */
> - max_align = MAX (max_align, 32U);
> -
> size_t freetop = 0;
> size_t freebottom = 0;
>
> diff --git a/elf/libc_early_init.c b/elf/libc_early_init.c
> index 86da66d5e0..725ab2f811 100644
> --- a/elf/libc_early_init.c
> +++ b/elf/libc_early_init.c
> @@ -18,7 +18,6 @@
>
> #include <ctype.h>
> #include <libc-early-init.h>
> -#include <rseq-internal.h>
> #include <sys/single_threaded.h>
>
> void
> @@ -27,10 +26,6 @@ __libc_early_init (_Bool initial)
> /* Initialize ctype data. */
> __ctype_init ();
>
> - /* Register rseq ABI to the kernel for the main program's libc. */
> - if (initial)
> - rseq_register_current_thread ();
> -
> /* Only the outer namespace is marked as single-threaded. */
> __libc_single_threaded = initial;
> }
> diff --git a/manual/threads.texi b/manual/threads.texi
> index 49f249ec48..4ab0622443 100644
> --- a/manual/threads.texi
> +++ b/manual/threads.texi
> @@ -629,8 +629,6 @@ 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,68 +956,6 @@ 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.
> -
> -@deftypevar {struct rseq} __rseq_abi
> -@standards{Linux, sys/rseq.h}
> -@Theglibc{} implements a @code{__rseq_abi} TLS symbol to interact with
> -the Restartable Sequences system call. The layout of this structure is
> -defined by the @file{sys/rseq.h} header. Registration of each thread's
> -@code{__rseq_abi} is performed by @theglibc{} at library initialization
> -and thread creation. The manual for the rseq system call can be found
> -at
> @uref{https://git.kernel.org/pub/scm/libs/librseq/librseq.git/tree/doc/man/rseq.2}.
> -
> -The main executable and shared libraries may either have an undefined
> -@code{__rseq_abi} TLS symbol, or define their own, with the same
> -declaration as the one present in @file{sys/rseq.h}. The dynamic linker
> -will ensure that only one of those available symbols will be used at
> -runtime across the process.
> -
> -If the main executable or shared libraries observe an uninitialized
> -@code{__rseq_abi.cpu_id} field (value @code{RSEQ_CPU_ID_UNINITIALIZED}),
> -they may perform rseq registration to the kernel: this means either
> -glibc was prevented from doing the registration, or an older glibc
> -version, which does not include rseq support, is in use. When the main
> -executable or a library thus takes ownership of the registration, the
> -memory used to hold the @code{__rseq_abi} TLS variable must stay
> -allocated, and is not re-used, until the very end of the thread lifetime
> -or until an explicit rseq unregistration for that thread is performed.
> -It is not recommended to @code{dlclose} libraries owning the
> -@code{__rseq_abi} TLS variable.
> -
> -Users of the @code{__rseq_abi} TLS symbol can store the address of a
> -@code{struct rseq_cs} to the @code{__rseq_abi.rseq_cs} TLS variable,
> -thus informing the kernel that it 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_abi.rseq_cs} TLS
> -variable to @code{NULL} in each thread's TLS 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_abi.rseq_cs}
> -TLS variable to @code{NULL} before returning from library functions
> -which use Restartable Sequences.
> -
> -@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/nptl/pthread_create.c b/nptl/pthread_create.c
> index e05013e317..2cba3da38c 100644
> --- a/nptl/pthread_create.c
> +++ b/nptl/pthread_create.c
> @@ -33,7 +33,6 @@
> #include <default-sched.h>
> #include <futex-internal.h>
> #include <tls-setup.h>
> -#include <rseq-internal.h>
> #include "libioP.h"
> #include <sys/single_threaded.h>
>
> @@ -386,9 +385,6 @@ START_THREAD_DEFN
> /* Initialize pointers to locale data. */
> __ctype_init ();
>
> - /* Register rseq TLS to the kernel. */
> - rseq_register_current_thread ();
> -
> #ifndef __ASSUME_SET_ROBUST_LIST
> if (__set_robust_list_avail >= 0)
> #endif
> @@ -585,15 +581,6 @@ START_THREAD_DEFN
> process is really dead since 'clone' got passed the CLONE_CHILD_CLEARTID
> flag. The 'tid' field in the TCB will be set to zero.
>
> - rseq TLS is still registered at this point. Rely on implicit
> - unregistration performed by the kernel on thread teardown. This is not a
> - problem because the rseq TLS lives on the stack, and the stack outlives
> - the thread. If TCB allocation is ever changed, additional steps may be
> - required, such as performing explicit rseq unregistration before
> - reclaiming the rseq TLS area memory. It is NOT sufficient to block
> - signals because the kernel may write to the rseq area even without
> - signals.
> -
> The exit code is zero since in case all threads exit by calling
> 'pthread_exit' the exit status must be 0 (zero). */
> __exit_thread ();
> diff --git a/sysdeps/generic/rseq-internal.h b/sysdeps/generic/rseq-internal.h
> deleted file mode 100644
> index 16f197397f..0000000000
> --- a/sysdeps/generic/rseq-internal.h
> +++ /dev/null
> @@ -1,26 +0,0 @@
> -/* Restartable Sequences internal API. Stub version.
> - Copyright (C) 2020 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
> - <https://www.gnu.org/licenses/>. */
> -
> -#ifndef RSEQ_INTERNAL_H
> -#define RSEQ_INTERNAL_H
> -
> -static inline void
> -rseq_register_current_thread (void)
> -{
> -}
> -
> -#endif /* rseq-internal.h */
> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
> index 1932ccf7df..9b2a253032 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -41,7 +41,7 @@ update-syscall-lists: arch-syscall.h
> endif
>
> ifeq ($(subdir),csu)
> -sysdep_routines += errno-loc rseq-sym
> +sysdep_routines += errno-loc
> endif
>
> ifeq ($(subdir),assert)
> @@ -94,19 +94,14 @@ sysdep_headers += sys/mount.h sys/acct.h \
> bits/types/struct_semid_ds.h \
> bits/types/struct_msqid_ds.h \
> bits/types/struct_shmid_ds.h \
> - bits/ipc-perm.h \
> - sys/rseq.h bits/rseq.h
> + bits/ipc-perm.h
>
> tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
> tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
> test-errno-linux tst-memfd_create tst-mlock2 tst-pkey \
> tst-rlimit-infinity tst-ofdlocks tst-gettid tst-gettid-kill \
> tst-tgkill
> -
> -# tst-rseq is an internal test because it requires a definition of __NR_rseq
> -# from the internal system call list.
> -tests-internal += tst-ofdlocks-compat tst-sigcontext-get_pc \
> - tst-rseq
> +tests-internal += tst-ofdlocks-compat tst-sigcontext-get_pc
>
> CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables
>
> @@ -307,8 +302,4 @@ endif
>
> ifeq ($(subdir),nptl)
> tests += tst-align-clone tst-getpid1
> -
> -# tst-rseq-nptl is an internal test because it requires a definition of
> -# __NR_rseq from the internal system call list.
> -tests-internal += tst-rseq-nptl
> endif
> diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
> index f72741b7e5..c35f783e2a 100644
> --- a/sysdeps/unix/sysv/linux/Versions
> +++ b/sysdeps/unix/sysv/linux/Versions
> @@ -168,7 +168,6 @@ libc {
> getdents64; gettid; tgkill;
> }
> GLIBC_2.32 {
> - __rseq_abi;
> }
> GLIBC_PRIVATE {
> # functions used in other libraries
> diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/rseq.h
> b/sysdeps/unix/sysv/linux/aarch64/bits/rseq.h
> deleted file mode 100644
> index b6f6e536f4..0000000000
> --- a/sysdeps/unix/sysv/linux/aarch64/bits/rseq.h
> +++ /dev/null
> @@ -1,43 +0,0 @@
> -/* Restartable Sequences Linux aarch64 architecture header.
> - Copyright (C) 2020 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
> - <https://www.gnu.org/licenses/>. */
> -
> -#ifndef _SYS_RSEQ_H
> -# error "Never use <bits/rseq.h> directly; include <sys/rseq.h> 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.
> -
> - aarch64 -mbig-endian generates mixed endianness code vs data:
> - little-endian code and big-endian data. Ensure the RSEQ_SIG signature
> - matches code endianness. */
> -
> -#define RSEQ_SIG_CODE 0xd428bc00 /* BRK #0x45E0. */
> -
> -#ifdef __AARCH64EB__
> -# define RSEQ_SIG_DATA 0x00bc28d4 /* BRK #0x45E0. */
> -#else
> -# define RSEQ_SIG_DATA RSEQ_SIG_CODE
> -#endif
> -
> -#define RSEQ_SIG RSEQ_SIG_DATA
> diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> index 008a6c8e52..6cd61988b4 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> @@ -2150,7 +2150,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist
> b/sysdeps/unix/sysv/linux/alpha/libc.abilist
> index 2cfc5733ed..8edb5deea1 100644
> --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
> @@ -2232,7 +2232,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist
> b/sysdeps/unix/sysv/linux/arc/libc.abilist
> index 0d1ce97229..df13f49e15 100644
> --- a/sysdeps/unix/sysv/linux/arc/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arc/libc.abilist
> @@ -345,7 +345,6 @@ GLIBC_2.32 __res_nclose F
> GLIBC_2.32 __res_ninit F
> GLIBC_2.32 __res_randomid F
> GLIBC_2.32 __res_state F
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 __sbrk F
> GLIBC_2.32 __sched_cpualloc F
> GLIBC_2.32 __sched_cpucount F
> diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> index 0e1677b5a0..7f4a146d22 100644
> --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> @@ -134,7 +134,6 @@ GLIBC_2.31 msgctl F
> GLIBC_2.31 semctl F
> GLIBC_2.31 shmctl F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/arm/bits/rseq.h
> b/sysdeps/unix/sysv/linux/arm/bits/rseq.h
> deleted file mode 100644
> index 2bf780efcd..0000000000
> --- a/sysdeps/unix/sysv/linux/arm/bits/rseq.h
> +++ /dev/null
> @@ -1,83 +0,0 @@
> -/* Restartable Sequences Linux arm architecture header.
> - Copyright (C) 2020 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
> - <https://www.gnu.org/licenses/>. */
> -
> -#ifndef _SYS_RSEQ_H
> -# error "Never use <bits/rseq.h> directly; include <sys/rseq.h> 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.
> -
> - - ARM little endian
> -
> - RSEQ_SIG uses the udf A32 instruction with an uncommon immediate operand
> - value 0x5de3. This traps if user-space reaches this instruction by mistake,
> - and the uncommon operand ensures the kernel does not move the instruction
> - pointer to attacker-controlled code on rseq abort.
> -
> - The instruction pattern in the A32 instruction set is:
> -
> - e7f5def3 udf #24035 ; 0x5de3
> -
> - This translates to the following instruction pattern in the T16 instruction
> - set:
> -
> - little endian:
> - def3 udf #243 ; 0xf3
> - e7f5 b.n <7f5>
> -
> - - ARMv6+ big endian (BE8):
> -
> - ARMv6+ -mbig-endian generates mixed endianness code vs data: little-endian
> - code and big-endian data. The data value of the signature needs to have its
> - byte order reversed to generate the trap instruction:
> -
> - Data: 0xf3def5e7
> -
> - Translates to this A32 instruction pattern:
> -
> - e7f5def3 udf #24035 ; 0x5de3
> -
> - Translates to this T16 instruction pattern:
> -
> - def3 udf #243 ; 0xf3
> - e7f5 b.n <7f5>
> -
> - - Prior to ARMv6 big endian (BE32):
> -
> - Prior to ARMv6, -mbig-endian generates big-endian code and data
> - (which match), so the endianness of the data representation of the
> - signature should not be reversed. However, the choice between BE32
> - and BE8 is done by the linker, so we cannot know whether code and
> - data endianness will be mixed before the linker is invoked. So rather
> - than try to play tricks with the linker, the rseq signature is simply
> - data (not a trap instruction) prior to ARMv6 on big endian. This is
> - why the signature is expressed as data (.word) rather than as
> - instruction (.inst) in assembler. */
> -
> -#ifdef __ARMEB__
> -# define RSEQ_SIG 0xf3def5e7 /* udf #24035 ; 0x5de3 (ARMv6+) */
> -#else
> -# define RSEQ_SIG 0xe7f5def3 /* udf #24035 ; 0x5de3 */
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> index e544ed75a4..a83cc81958 100644
> --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> @@ -131,7 +131,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/bits/rseq.h
> b/sysdeps/unix/sysv/linux/bits/rseq.h
> deleted file mode 100644
> index 014c08fe0f..0000000000
> --- a/sysdeps/unix/sysv/linux/bits/rseq.h
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -/* Restartable Sequences architecture header. Stub version.
> - Copyright (C) 2020 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
> - <https://www.gnu.org/licenses/>. */
> -
> -#ifndef _SYS_RSEQ_H
> -# error "Never use <bits/rseq.h> directly; include <sys/rseq.h> 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. */
> diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist
> b/sysdeps/unix/sysv/linux/csky/libc.abilist
> index 6bb8042657..32887b1c58 100644
> --- a/sysdeps/unix/sysv/linux/csky/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
> @@ -2094,7 +2094,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist
> b/sysdeps/unix/sysv/linux/hppa/libc.abilist
> index e0f8f29c40..baf425072b 100644
> --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
> @@ -2053,7 +2053,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist
> b/sysdeps/unix/sysv/linux/i386/libc.abilist
> index 155dd51e0d..8b0242a9b1 100644
> --- a/sysdeps/unix/sysv/linux/i386/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
> @@ -2219,7 +2219,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist
> b/sysdeps/unix/sysv/linux/ia64/libc.abilist
> index 8cc12aa326..b6ba86dbe9 100644
> --- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
> @@ -2085,7 +2085,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> index e02a61591c..e1f7e19de9 100644
> --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> @@ -135,7 +135,6 @@ GLIBC_2.31 msgctl F
> GLIBC_2.31 semctl F
> GLIBC_2.31 shmctl F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> index 8e90d9744a..2d726097ca 100644
> --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> @@ -2165,7 +2165,6 @@ GLIBC_2.31 msgctl F
> GLIBC_2.31 semctl F
> GLIBC_2.31 shmctl F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> index 76e402cbf5..7c78649e03 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> @@ -2145,7 +2145,6 @@ GLIBC_2.31 msgctl F
> GLIBC_2.31 semctl F
> GLIBC_2.31 shmctl F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> index 8528547aa2..da2194b498 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> @@ -2142,7 +2142,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/mips/bits/rseq.h
> b/sysdeps/unix/sysv/linux/mips/bits/rseq.h
> deleted file mode 100644
> index fa945fc7c1..0000000000
> --- a/sysdeps/unix/sysv/linux/mips/bits/rseq.h
> +++ /dev/null
> @@ -1,62 +0,0 @@
> -/* Restartable Sequences Linux mips architecture header.
> - Copyright (C) 2020 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
> - <https://www.gnu.org/licenses/>. */
> -
> -#ifndef _SYS_RSEQ_H
> -# error "Never use <bits/rseq.h> directly; include <sys/rseq.h> 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.
> -
> - RSEQ_SIG uses the break instruction. The instruction pattern is:
> -
> - On MIPS:
> - 0350000d break 0x350
> -
> - On nanoMIPS:
> - 00100350 break 0x350
> -
> - On microMIPS:
> - 0000d407 break 0x350
> -
> - For nanoMIPS32 and microMIPS, the instruction stream is encoded as
> - 16-bit halfwords, so the signature halfwords need to be swapped
> - accordingly for little-endian. */
> -
> -#if defined (__nanomips__)
> -# ifdef __MIPSEL__
> -# define RSEQ_SIG 0x03500010
> -# else
> -# define RSEQ_SIG 0x00100350
> -# endif
> -#elif defined (__mips_micromips)
> -# ifdef __MIPSEL__
> -# define RSEQ_SIG 0xd4070000
> -# else
> -# define RSEQ_SIG 0x0000d407
> -# endif
> -#elif defined (__mips__)
> -# define RSEQ_SIG 0x0350000d
> -#else
> -/* Unknown MIPS architecture. */
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> index 2b838c0c8e..9fa655b3a5 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> @@ -2136,7 +2136,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> index 9cde04785c..3f6da71769 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> @@ -2134,7 +2134,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> index be180e71cf..de990933cf 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> @@ -2142,7 +2142,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> index 8569cfb6cb..754491f209 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> @@ -2136,7 +2136,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist
> b/sysdeps/unix/sysv/linux/nios2/libc.abilist
> index bce6c79b9b..36a875115c 100644
> --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
> @@ -2183,7 +2183,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/rseq.h
> b/sysdeps/unix/sysv/linux/powerpc/bits/rseq.h
> deleted file mode 100644
> index 0dc608ebd5..0000000000
> --- a/sysdeps/unix/sysv/linux/powerpc/bits/rseq.h
> +++ /dev/null
> @@ -1,37 +0,0 @@
> -/* Restartable Sequences Linux powerpc architecture header.
> - Copyright (C) 2020 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
> - <https://www.gnu.org/licenses/>. */
> -
> -#ifndef _SYS_RSEQ_H
> -# error "Never use <bits/rseq.h> directly; include <sys/rseq.h> 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.
> -
> - RSEQ_SIG uses the following trap instruction:
> -
> - powerpc-be: 0f e5 00 0b twui r5,11
> - powerpc64-le: 0b 00 e5 0f twui r5,11
> - powerpc64-be: 0f e5 00 0b twui r5,11 */
> -
> -#define RSEQ_SIG 0x0fe5000b
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> index 1d0158a08e..6de9bed51d 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> @@ -2192,7 +2192,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> index f65772cf8a..5c8c58974c 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> @@ -2225,7 +2225,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> index cfe526b916..92114806ac 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> @@ -2055,7 +2055,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> index cbe0cf3d7e..b01fdcfae1 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> @@ -2292,7 +2292,6 @@ GLIBC_2.32 __qecvtieee128_r F
> GLIBC_2.32 __qfcvtieee128 F
> GLIBC_2.32 __qfcvtieee128_r F
> GLIBC_2.32 __qgcvtieee128 F
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 __scanfieee128 F
> GLIBC_2.32 __snprintf_chkieee128 F
> GLIBC_2.32 __snprintfieee128 F
> diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> index b361308505..45cbeb1d98 100644
> --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> @@ -2112,7 +2112,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/rseq-internal.h
> b/sysdeps/unix/sysv/linux/rseq-internal.h
> deleted file mode 100644
> index 8f6772ca1d..0000000000
> --- a/sysdeps/unix/sysv/linux/rseq-internal.h
> +++ /dev/null
> @@ -1,73 +0,0 @@
> -/* Restartable Sequences internal API. Linux implementation.
> - Copyright (C) 2020 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
> - <https://www.gnu.org/licenses/>. */
> -
> -#ifndef RSEQ_INTERNAL_H
> -#define RSEQ_INTERNAL_H
> -
> -#include <sysdep.h>
> -#include <errno.h>
> -#include <kernel-features.h>
> -#include <stdio.h>
> -#include <sys/rseq.h>
> -
> -#ifdef RSEQ_SIG
> -static inline void
> -rseq_register_current_thread (void)
> -{
> - int ret;
> -
> - if (__rseq_abi.cpu_id != RSEQ_CPU_ID_UNINITIALIZED)
> - __libc_fatal ("glibc fatal error: "
> - "rseq already initialized for this thread\n");
> - ret = INTERNAL_SYSCALL_CALL (rseq, &__rseq_abi, sizeof (struct rseq),
> - 0, RSEQ_SIG);
> - if (INTERNAL_SYSCALL_ERROR_P (ret))
> - {
> - const char *msg = NULL;
> -
> - switch (INTERNAL_SYSCALL_ERRNO (ret))
> - {
> - case ENOSYS: /* rseq system call not implemented. */
> - case EPERM: /* rseq system call filtered by seccomp. */
> - case EACCES: /* rseq system call filtered by seccomp. */
> - __rseq_abi.cpu_id = RSEQ_CPU_ID_REGISTRATION_FAILED;
> - break;
> - case EBUSY:
> - msg = "glibc fatal error: rseq already registered for this thread\n";
> - break;
> - case EFAULT:
> - msg = "glibc fatal error: rseq parameter is an invalid address\n";
> - break;
> - case EINVAL:
> - msg = "glibc fatal error: rseq parameters are invalid\n";
> - break;
> - default:
> - msg = "glibc fatal error: unexpected rseq errno\n";
> - break;
> - }
> - if (msg != NULL)
> - __libc_fatal (msg);
> - }
> -}
> -#else /* RSEQ_SIG */
> -static inline void
> -rseq_register_current_thread (void)
> -{
> -}
> -#endif /* RSEQ_SIG */
> -
> -#endif /* rseq-internal.h */
> diff --git a/sysdeps/unix/sysv/linux/rseq-sym.c
> b/sysdeps/unix/sysv/linux/rseq-sym.c
> deleted file mode 100644
> index 090093408f..0000000000
> --- a/sysdeps/unix/sysv/linux/rseq-sym.c
> +++ /dev/null
> @@ -1,26 +0,0 @@
> -/* Restartable Sequences exported symbols. Linux Implementation.
> - Copyright (C) 2020 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
> - <https://www.gnu.org/licenses/>. */
> -
> -#include <sys/syscall.h>
> -#include <stdint.h>
> -#include <kernel-features.h>
> -#include <sys/rseq.h>
> -
> -__thread struct rseq __rseq_abi =
> - {
> - .cpu_id = RSEQ_CPU_ID_UNINITIALIZED,
> - };
> diff --git a/sysdeps/unix/sysv/linux/s390/bits/rseq.h
> b/sysdeps/unix/sysv/linux/s390/bits/rseq.h
> deleted file mode 100644
> index 3d6fd0cfb9..0000000000
> --- a/sysdeps/unix/sysv/linux/s390/bits/rseq.h
> +++ /dev/null
> @@ -1,37 +0,0 @@
> -/* Restartable Sequences Linux s390 architecture header.
> - Copyright (C) 2020 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
> - <https://www.gnu.org/licenses/>. */
> -
> -#ifndef _SYS_RSEQ_H
> -# error "Never use <bits/rseq.h> directly; include <sys/rseq.h> 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.
> -
> - RSEQ_SIG uses the trap4 instruction. As Linux does not make use of the
> - access-register mode nor the linkage stack this instruction will always
> - cause a special-operation exception (the trap-enabled bit in the DUCT
> - is and will stay 0). The instruction pattern is
> - b2 ff 0f ff trap4 4095(%r0) */
> -
> -#define RSEQ_SIG 0xB2FF0FFF
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> index 37e313a1b0..d0752dba6c 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> @@ -2190,7 +2190,6 @@ GLIBC_2.31 msgctl F
> GLIBC_2.31 semctl F
> GLIBC_2.31 shmctl F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> index 5ff64d8a0a..af5f14d1c6 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> @@ -2091,7 +2091,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/sched_getcpu.c
> b/sysdeps/unix/sysv/linux/sched_getcpu.c
> index c0f992e056..c019cfb3cf 100644
> --- a/sysdeps/unix/sysv/linux/sched_getcpu.c
> +++ b/sysdeps/unix/sysv/linux/sched_getcpu.c
> @@ -18,12 +18,10 @@
> #include <errno.h>
> #include <sched.h>
> #include <sysdep.h>
> -#include <atomic.h>
> #include <sysdep-vdso.h>
> -#include <sys/rseq.h>
>
> -static int
> -vsyscall_sched_getcpu (void)
> +int
> +sched_getcpu (void)
> {
> unsigned int cpu;
> int r = -1;
> @@ -34,19 +32,3 @@ vsyscall_sched_getcpu (void)
> #endif
> return r == -1 ? r : cpu;
> }
> -
> -#ifdef RSEQ_SIG
> -int
> -sched_getcpu (void)
> -{
> - int cpu_id = atomic_load_relaxed (&__rseq_abi.cpu_id);
> -
> - return cpu_id >= 0 ? cpu_id : vsyscall_sched_getcpu ();
> -}
> -#else /* RSEQ_SIG */
> -int
> -sched_getcpu (void)
> -{
> - return vsyscall_sched_getcpu ();
> -}
> -#endif /* RSEQ_SIG */
> diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> index 7e65b3e317..038ce27174 100644
> --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> @@ -2060,7 +2060,6 @@ GLIBC_2.31 msgctl F
> GLIBC_2.31 semctl F
> GLIBC_2.31 shmctl F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> index 6a3eeed921..182970a708 100644
> --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> @@ -2057,7 +2057,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> index 196f7f2543..a2521c3ee3 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> @@ -2181,7 +2181,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> index 2ca03d7062..d8188903f9 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> @@ -2108,7 +2108,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/sys/rseq.h
> b/sysdeps/unix/sysv/linux/sys/rseq.h
> deleted file mode 100644
> index 55090f9e30..0000000000
> --- a/sysdeps/unix/sysv/linux/sys/rseq.h
> +++ /dev/null
> @@ -1,203 +0,0 @@
> -/* Restartable Sequences exported symbols. Linux header.
> - Copyright (C) 2020 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
> - <https://www.gnu.org/licenses/>. */
> -
> -#ifndef _SYS_RSEQ_H
> -#define _SYS_RSEQ_H 1
> -
> -/* Architecture-specific rseq signature. */
> -#include <bits/rseq.h>
> -
> -#include <stdint.h>
> -#include <sys/cdefs.h>
> -
> -#ifdef __has_include
> -# if __has_include ("linux/rseq.h")
> -# define __GLIBC_HAVE_KERNEL_RSEQ
> -# endif
> -#else
> -# include <linux/version.h>
> -# if LINUX_VERSION_CODE >= KERNEL_VERSION (4, 18, 0)
> -# define __GLIBC_HAVE_KERNEL_RSEQ
> -# endif
> -#endif
> -
> -/* Rely on GNU extensions for older standards and tls model. */
> -#ifdef __GNUC__
> -# define __rseq_tls_model_ie __attribute__ ((__tls_model__ ("initial-exec")))
> -#else
> -/* Specifying the TLS model on the declaration is optional. */
> -# define __rseq_tls_model_ie /* Nothing. */
> -#endif
> -
> -#ifdef __cplusplus
> -# if __cplusplus >= 201103L
> -# define __rseq_tls_storage_class thread_local
> -# endif
> -#elif (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) >= 201112L
> -# define __rseq_tls_storage_class _Thread_local
> -#endif
> -
> -/* Fall back to __thread for TLS storage class. */
> -#ifndef __rseq_tls_storage_class
> -# define __rseq_tls_storage_class __thread
> -#endif
> -
> -#ifdef __GLIBC_HAVE_KERNEL_RSEQ
> -/* We use the structures declarations from the kernel headers. */
> -# include <linux/rseq.h>
> -#else /* __GLIBC_HAVE_KERNEL_RSEQ */
> -/* We use a copy of the include/uapi/linux/rseq.h kernel header. */
> -
> -# include <asm/byteorder.h>
> -
> -enum rseq_cpu_id_state
> - {
> - RSEQ_CPU_ID_UNINITIALIZED = -1,
> - RSEQ_CPU_ID_REGISTRATION_FAILED = -2,
> - };
> -
> -enum rseq_flags
> - {
> - RSEQ_FLAG_UNREGISTER = (1 << 0),
> - };
> -
> -enum rseq_cs_flags_bit
> - {
> - RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT_BIT = 0,
> - RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL_BIT = 1,
> - RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE_BIT = 2,
> - };
> -
> -enum rseq_cs_flags
> - {
> - RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT =
> - (1U << RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT_BIT),
> - RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL =
> - (1U << RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL_BIT),
> - RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE =
> - (1U << RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE_BIT),
> - };
> -
> -/* struct rseq_cs is aligned on 32 bytes to ensure it is always
> - contained within a single cache-line. It is usually declared as
> - link-time constant data. */
> -struct rseq_cs
> - {
> - /* Version of this structure. */
> - uint32_t version;
> - /* enum rseq_cs_flags. */
> - uint32_t flags;
> - uint64_t start_ip;
> - /* Offset from start_ip. */
> - uint64_t post_commit_offset;
> - uint64_t abort_ip;
> - } __attribute__ ((__aligned__ (32)));
> -
> -/* struct rseq is aligned on 32 bytes to ensure it is always
> - contained within a single cache-line.
> -
> - A single struct rseq per thread is allowed. */
> -struct rseq
> - {
> - /* Restartable sequences cpu_id_start 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. Always
> - contains a value in the range of possible CPUs, although the
> - value may not be the actual current CPU (e.g. if rseq is not
> - initialized). This CPU number value should always be compared
> - against the value of the cpu_id field before performing a rseq
> - commit or returning a value read from a data structure indexed
> - using the cpu_id_start value. */
> - uint32_t cpu_id_start;
> - /* Restartable sequences cpu_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. Values
> - RSEQ_CPU_ID_UNINITIALIZED and RSEQ_CPU_ID_REGISTRATION_FAILED
> - have a special semantic: the former means "rseq uninitialized",
> - and latter means "rseq initialization failed". This value is
> - meant to be read within rseq critical sections and compared
> - with the cpu_id_start value previously read, before performing
> - the commit instruction, or read and compared with the
> - cpu_id_start value before returning a value loaded from a data
> - structure indexed using the cpu_id_start value. */
> - uint32_t cpu_id;
> - /* Restartable sequences rseq_cs field.
> -
> - Contains NULL when no critical section is active for the current
> - thread, or holds a pointer to the currently active struct rseq_cs.
> -
> - Updated by user-space, which sets the address of the currently
> - active rseq_cs at the beginning of assembly instruction sequence
> - block, and set to NULL by the kernel when it restarts an assembly
> - instruction sequence block, as well as when the kernel detects that
> - it is preempting or delivering a signal outside of the range
> - targeted by the rseq_cs. Also needs to be set to NULL by user-space
> - before reclaiming memory that contains the targeted struct rseq_cs.
> -
> - Read and set by the kernel. Set by user-space with single-copy
> - atomicity semantics. This field should only be updated by the
> - thread which registered this data structure. Aligned on 64-bit. */
> - union
> - {
> - uint64_t ptr64;
> -# ifdef __LP64__
> - uint64_t ptr;
> -# else /* __LP64__ */
> - struct
> - {
> -# if (defined (__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || defined
> (__BIG_ENDIAN)
> - uint32_t padding; /* Initialized to zero. */
> - uint32_t ptr32;
> -# else /* LITTLE */
> - uint32_t ptr32;
> - uint32_t padding; /* Initialized to zero. */
> -# endif /* ENDIAN */
> - } ptr;
> -# endif /* __LP64__ */
> - } rseq_cs;
> -
> - /* Restartable sequences flags field.
> -
> - This field should only be updated by the thread which
> - registered this data structure. Read by the kernel.
> - Mainly used for single-stepping through rseq critical sections
> - with debuggers.
> -
> - - RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT
> - Inhibit instruction sequence block restart on preemption
> - for this thread.
> - - RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL
> - Inhibit instruction sequence block restart on signal
> - delivery for this thread.
> - - RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE
> - Inhibit instruction sequence block restart on migration for
> - this thread. */
> - uint32_t flags;
> - } __attribute__ ((__aligned__ (32)));
> -
> -#endif /* __GLIBC_HAVE_KERNEL_RSEQ */
> -
> -/* Allocations of struct rseq and struct rseq_cs on the heap need to
> - be aligned on 32 bytes. Therefore, use of malloc is discouraged
> - because it does not guarantee alignment. posix_memalign should be
> - used instead. */
> -
> -extern __rseq_tls_storage_class struct rseq __rseq_abi __rseq_tls_model_ie;
> -
> -#endif /* sys/rseq.h */
> diff --git a/sysdeps/unix/sysv/linux/tst-rseq-nptl.c
> b/sysdeps/unix/sysv/linux/tst-rseq-nptl.c
> deleted file mode 100644
> index 5e788dcfa9..0000000000
> --- a/sysdeps/unix/sysv/linux/tst-rseq-nptl.c
> +++ /dev/null
> @@ -1,256 +0,0 @@
> -/* Restartable Sequences NPTL test.
> - Copyright (C) 2020 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
> - <https://www.gnu.org/licenses/>. */
> -
> -/* These tests validate that rseq is registered from various execution
> - contexts (main thread, destructor, other threads, other threads created
> - from destructor, forked process (without exec), pthread_atfork handlers,
> - pthread setspecific destructors, signal handlers, atexit handlers).
> -
> - See the Linux kernel selftests for extensive rseq stress-tests. */
> -
> -#include <stdio.h>
> -#include <support/check.h>
> -#include <support/xthread.h>
> -#include <sys/rseq.h>
> -#include <unistd.h>
> -
> -#ifdef RSEQ_SIG
> -# include <array_length.h>
> -# include <errno.h>
> -# include <error.h>
> -# include <pthread.h>
> -# include <signal.h>
> -# include <stdlib.h>
> -# include <string.h>
> -# include <support/namespace.h>
> -# include <support/xsignal.h>
> -# include <syscall.h>
> -# include <sys/types.h>
> -# include <sys/wait.h>
> -# include "tst-rseq.h"
> -
> -static pthread_key_t rseq_test_key;
> -
> -static void
> -atfork_prepare (void)
> -{
> - if (!rseq_thread_registered ())
> - {
> - printf ("error: rseq not registered in pthread atfork prepare\n");
> - support_record_failure ();
> - }
> -}
> -
> -static void
> -atfork_parent (void)
> -{
> - if (!rseq_thread_registered ())
> - {
> - printf ("error: rseq not registered in pthread atfork parent\n");
> - support_record_failure ();
> - }
> -}
> -
> -static void
> -atfork_child (void)
> -{
> - if (!rseq_thread_registered ())
> - {
> - printf ("error: rseq not registered in pthread atfork child\n");
> - support_record_failure ();
> - }
> -}
> -
> -static void
> -rseq_key_destructor (void *arg)
> -{
> - /* Cannot use deferred failure reporting after main returns. */
> - if (!rseq_thread_registered ())
> - FAIL_EXIT1 ("rseq not registered in pthread key destructor");
> -}
> -
> -static void
> -atexit_handler (void)
> -{
> - /* Cannot use deferred failure reporting after main returns. */
> - if (!rseq_thread_registered ())
> - FAIL_EXIT1 ("rseq not registered in atexit handler");
> -}
> -
> -static void
> -do_rseq_main_test (void)
> -{
> - TEST_COMPARE (atexit (atexit_handler), 0);
> - rseq_test_key = xpthread_key_create (rseq_key_destructor);
> - TEST_COMPARE (pthread_atfork (atfork_prepare, atfork_parent, atfork_child),
> 0);
> - xraise (SIGUSR1);
> - TEST_COMPARE (pthread_setspecific (rseq_test_key, (void *) 1l), 0);
> - TEST_VERIFY_EXIT (rseq_thread_registered ());
> -}
> -
> -static void
> -cancel_routine (void *arg)
> -{
> - if (!rseq_thread_registered ())
> - {
> - printf ("error: rseq not registered in cancel routine\n");
> - support_record_failure ();
> - }
> -}
> -
> -static pthread_barrier_t cancel_thread_barrier;
> -static pthread_cond_t cancel_thread_cond = PTHREAD_COND_INITIALIZER;
> -static pthread_mutex_t cancel_thread_mutex = PTHREAD_MUTEX_INITIALIZER;
> -
> -static void
> -test_cancel_thread (void)
> -{
> - pthread_cleanup_push (cancel_routine, NULL);
> - (void) xpthread_barrier_wait (&cancel_thread_barrier);
> - /* Wait forever until cancellation. */
> - xpthread_cond_wait (&cancel_thread_cond, &cancel_thread_mutex);
> - pthread_cleanup_pop (0);
> -}
> -
> -static void *
> -thread_function (void * arg)
> -{
> - int i = (int) (intptr_t) arg;
> -
> - xraise (SIGUSR1);
> - if (i == 0)
> - test_cancel_thread ();
> - TEST_COMPARE (pthread_setspecific (rseq_test_key, (void *) 1l), 0);
> - return rseq_thread_registered () ? NULL : (void *) 1l;
> -}
> -
> -static void
> -sighandler (int sig)
> -{
> - if (!rseq_thread_registered ())
> - {
> - printf ("error: rseq not registered in signal handler\n");
> - support_record_failure ();
> - }
> -}
> -
> -static void
> -setup_signals (void)
> -{
> - struct sigaction sa;
> -
> - sigemptyset (&sa.sa_mask);
> - sigaddset (&sa.sa_mask, SIGUSR1);
> - sa.sa_flags = 0;
> - sa.sa_handler = sighandler;
> - xsigaction (SIGUSR1, &sa, NULL);
> -}
> -
> -static int
> -do_rseq_threads_test (int nr_threads)
> -{
> - pthread_t th[nr_threads];
> - int i;
> - int result = 0;
> -
> - xpthread_barrier_init (&cancel_thread_barrier, NULL, 2);
> -
> - for (i = 0; i < nr_threads; ++i)
> - th[i] = xpthread_create (NULL, thread_function,
> - (void *) (intptr_t) i);
> -
> - (void) xpthread_barrier_wait (&cancel_thread_barrier);
> -
> - xpthread_cancel (th[0]);
> -
> - for (i = 0; i < nr_threads; ++i)
> - {
> - void *v;
> -
> - v = xpthread_join (th[i]);
> - if (i != 0 && v != NULL)
> - {
> - printf ("error: join %d successful, but child failed\n", i);
> - result = 1;
> - }
> - else if (i == 0 && v == NULL)
> - {
> - printf ("error: join %d successful, child did not fail as
> expected\n", i);
> - result = 1;
> - }
> - }
> -
> - xpthread_barrier_destroy (&cancel_thread_barrier);
> -
> - return result;
> -}
> -
> -static void
> -subprocess_callback (void *closure)
> -{
> - do_rseq_main_test ();
> -}
> -
> -static void
> -do_rseq_fork_test (void)
> -{
> - support_isolate_in_subprocess (subprocess_callback, NULL);
> -}
> -
> -static int
> -do_rseq_test (void)
> -{
> - int t[] = { 1, 2, 6, 5, 4, 3, 50 };
> - int i, result = 0;
> -
> - if (!rseq_available ())
> - FAIL_UNSUPPORTED ("kernel does not support rseq, skipping test");
> - setup_signals ();
> - xraise (SIGUSR1);
> - do_rseq_main_test ();
> - for (i = 0; i < array_length (t); i++)
> - if (do_rseq_threads_test (t[i]))
> - result = 1;
> - do_rseq_fork_test ();
> - return result;
> -}
> -
> -static void __attribute__ ((destructor))
> -do_rseq_destructor_test (void)
> -{
> - /* Cannot use deferred failure reporting after main returns. */
> - if (do_rseq_test ())
> - FAIL_EXIT1 ("rseq not registered within destructor");
> - xpthread_key_delete (rseq_test_key);
> -}
> -
> -#else /* RSEQ_SIG */
> -static int
> -do_rseq_test (void)
> -{
> - FAIL_UNSUPPORTED ("glibc does not define RSEQ_SIG, skipping test");
> - return 0;
> -}
> -#endif /* RSEQ_SIG */
> -
> -static int
> -do_test (void)
> -{
> - return do_rseq_test ();
> -}
> -
> -#include <support/test-driver.c>
> diff --git a/sysdeps/unix/sysv/linux/tst-rseq.c
> b/sysdeps/unix/sysv/linux/tst-rseq.c
> deleted file mode 100644
> index aa902fb26a..0000000000
> --- a/sysdeps/unix/sysv/linux/tst-rseq.c
> +++ /dev/null
> @@ -1,64 +0,0 @@
> -/* Restartable Sequences single-threaded tests.
> - Copyright (C) 2020 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
> - <https://www.gnu.org/licenses/>. */
> -
> -/* These tests validate that rseq is registered from main in an executable
> - not linked against libpthread. */
> -
> -#include <support/check.h>
> -#include <stdio.h>
> -#include <sys/rseq.h>
> -#include <unistd.h>
> -
> -#ifdef RSEQ_SIG
> -# include <errno.h>
> -# include <error.h>
> -# include <stdlib.h>
> -# include <string.h>
> -# include <syscall.h>
> -# include "tst-rseq.h"
> -
> -static void
> -do_rseq_main_test (void)
> -{
> - TEST_VERIFY_EXIT (rseq_thread_registered ());
> -}
> -
> -static void
> -do_rseq_test (void)
> -{
> - if (!rseq_available ())
> - {
> - FAIL_UNSUPPORTED ("kernel does not support rseq, skipping test");
> - }
> - do_rseq_main_test ();
> -}
> -#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;
> -}
> -
> -#include <support/test-driver.c>
> diff --git a/sysdeps/unix/sysv/linux/tst-rseq.h
> b/sysdeps/unix/sysv/linux/tst-rseq.h
> deleted file mode 100644
> index c2cb211f56..0000000000
> --- a/sysdeps/unix/sysv/linux/tst-rseq.h
> +++ /dev/null
> @@ -1,59 +0,0 @@
> -/* Restartable Sequences tests header.
> - Copyright (C) 2020 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
> - <https://www.gnu.org/licenses/>. */
> -
> -#include <errno.h>
> -#include <error.h>
> -#include <stdbool.h>
> -#include <stdint.h>
> -#include <support/check.h>
> -#include <syscall.h>
> -#include <sys/rseq.h>
> -
> -static inline bool
> -rseq_thread_registered (void)
> -{
> - int32_t v;
> -
> - __atomic_load (&__rseq_abi.cpu_id, &v, __ATOMIC_RELAXED);
> - return v >= 0;
> -}
> -
> -static inline int
> -sys_rseq (struct rseq *rseq_abi, uint32_t rseq_len, int flags, uint32_t sig)
> -{
> - return syscall (__NR_rseq, rseq_abi, rseq_len, flags, sig);
> -}
> -
> -static inline bool
> -rseq_available (void)
> -{
> - int rc;
> -
> - rc = sys_rseq (NULL, 0, 0, 0);
> - if (rc != -1)
> - FAIL_EXIT1 ("Unexpected rseq return value %d", rc);
> - switch (errno)
> - {
> - case ENOSYS:
> - return false;
> - case EINVAL:
> - /* rseq is implemented, but detected an invalid rseq_len parameter. */
> - return true;
> - default:
> - FAIL_EXIT1 ("Unexpected rseq error %s", strerror (errno));
> - }
> -}
> diff --git a/sysdeps/unix/sysv/linux/x86/bits/rseq.h
> b/sysdeps/unix/sysv/linux/x86/bits/rseq.h
> deleted file mode 100644
> index f801d5d0a1..0000000000
> --- a/sysdeps/unix/sysv/linux/x86/bits/rseq.h
> +++ /dev/null
> @@ -1,30 +0,0 @@
> -/* Restartable Sequences Linux x86 architecture header.
> - Copyright (C) 2020 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
> - <https://www.gnu.org/licenses/>. */
> -
> -#ifndef _SYS_RSEQ_H
> -# error "Never use <bits/rseq.h> directly; include <sys/rseq.h> instead."
> -#endif
> -
> -/* RSEQ_SIG is a signature required before each abort handler code.
> -
> - RSEQ_SIG is used with the following reserved undefined instructions, which
> - trap in user-space:
> -
> - x86-32: 0f b9 3d 53 30 05 53 ud1 0x53053053,%edi
> - x86-64: 0f b9 3d 53 30 05 53 ud1 0x53053053(%rip),%edi */
> -
> -#define RSEQ_SIG 0x53053053
> diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> index 86a481be42..1a96103c68 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> @@ -2066,7 +2066,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
> diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> index 056de03ae3..35745a75b6 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> @@ -2163,7 +2163,6 @@ GLIBC_2.30 gettid F
> GLIBC_2.30 tgkill F
> GLIBC_2.30 twalk_r F
> GLIBC_2.32 __libc_single_threaded D 0x1
> -GLIBC_2.32 __rseq_abi T 0x20
> GLIBC_2.32 pthread_attr_getsigmask_np F
> GLIBC_2.32 pthread_attr_setaffinity_np F
> GLIBC_2.32 pthread_attr_setsigmask_np F
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
More information about the Libc-alpha
mailing list