aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2020-07-16 17:55:35 +0200
committerFlorian Weimer <fweimer@redhat.com>2020-07-16 17:55:35 +0200
commitefedd1ed3d211941fc66d14ba245be3552b2616a (patch)
tree67e2e7d222933fa2f442ff92019d4ba85eee23a2
parentda7d62b50396c8b6d67c1ba800a196e83e2ec469 (diff)
downloadglibc-efedd1ed3d211941fc66d14ba245be3552b2616a.tar.xz
glibc-efedd1ed3d211941fc66d14ba245be3552b2616a.zip
Linux: Remove rseq support
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. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
-rw-r--r--NEWS10
-rw-r--r--csu/libc-tls.c6
-rw-r--r--elf/dl-tls.c8
-rw-r--r--elf/libc_early_init.c5
-rw-r--r--manual/threads.texi64
-rw-r--r--nptl/pthread_create.c13
-rw-r--r--sysdeps/generic/rseq-internal.h26
-rw-r--r--sysdeps/unix/sysv/linux/Makefile15
-rw-r--r--sysdeps/unix/sysv/linux/Versions1
-rw-r--r--sysdeps/unix/sysv/linux/aarch64/bits/rseq.h43
-rw-r--r--sysdeps/unix/sysv/linux/aarch64/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/alpha/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/arc/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/arm/be/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/arm/bits/rseq.h83
-rw-r--r--sysdeps/unix/sysv/linux/arm/le/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/bits/rseq.h29
-rw-r--r--sysdeps/unix/sysv/linux/csky/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/hppa/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/i386/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/ia64/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/microblaze/be/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/microblaze/le/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/mips/bits/rseq.h62
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/nios2/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/bits/rseq.h37
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/rseq-internal.h73
-rw-r--r--sysdeps/unix/sysv/linux/rseq-sym.c26
-rw-r--r--sysdeps/unix/sysv/linux/s390/bits/rseq.h37
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/sched_getcpu.c22
-rw-r--r--sysdeps/unix/sysv/linux/sh/be/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/sh/le/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/sys/rseq.h203
-rw-r--r--sysdeps/unix/sysv/linux/tst-rseq-nptl.c256
-rw-r--r--sysdeps/unix/sysv/linux/tst-rseq.c64
-rw-r--r--sysdeps/unix/sysv/linux/tst-rseq.h59
-rw-r--r--sysdeps/unix/sysv/linux/x86/bits/rseq.h30
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/64/libc.abilist1
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist1
54 files changed, 6 insertions, 1197 deletions
diff --git a/NEWS b/NEWS
index 5051e804ea..1ef4a0a7a4 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.
-