]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nptl: Add public rseq symbols and <sys/rseq.h>
authorFlorian Weimer <fweimer@redhat.com>
Thu, 9 Dec 2021 08:49:32 +0000 (09:49 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Thu, 9 Dec 2021 08:49:32 +0000 (09:49 +0100)
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 <mathieu.desnoyers@efficios.com>
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
38 files changed:
NEWS
manual/threads.texi
sysdeps/nptl/dl-tls_init_tp.c
sysdeps/unix/sysv/linux/Makefile
sysdeps/unix/sysv/linux/Versions
sysdeps/unix/sysv/linux/aarch64/ld.abilist
sysdeps/unix/sysv/linux/alpha/ld.abilist
sysdeps/unix/sysv/linux/arc/ld.abilist
sysdeps/unix/sysv/linux/arm/be/ld.abilist
sysdeps/unix/sysv/linux/arm/le/ld.abilist
sysdeps/unix/sysv/linux/csky/ld.abilist
sysdeps/unix/sysv/linux/hppa/ld.abilist
sysdeps/unix/sysv/linux/i386/ld.abilist
sysdeps/unix/sysv/linux/ia64/ld.abilist
sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist
sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist
sysdeps/unix/sysv/linux/microblaze/ld.abilist
sysdeps/unix/sysv/linux/mips/mips32/ld.abilist
sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist
sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist
sysdeps/unix/sysv/linux/nios2/ld.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist
sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist
sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist
sysdeps/unix/sysv/linux/rseq-internal.h
sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist
sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist
sysdeps/unix/sysv/linux/sh/be/ld.abilist
sysdeps/unix/sysv/linux/sh/le/ld.abilist
sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist
sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist
sysdeps/unix/sysv/linux/sys/rseq.h
sysdeps/unix/sysv/linux/tst-rseq-disable.c
sysdeps/unix/sysv/linux/tst-rseq.c
sysdeps/unix/sysv/linux/x86_64/64/ld.abilist
sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist

diff --git a/NEWS b/NEWS
index 1398cf2e87c34f0b611439d69ffcd6ee5c436122..8744a92532b4cefb43981ff85628650d9557c729 100644 (file)
--- 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
index 06b6b277a1228af14f8cd49471c2604cab5e3f03..ab44a92ca0f5a6a56d598f30cb61128e81161dc1 100644 (file)
@@ -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 which the thread
+pointer points, the value is negative.
+@end deftypevar
+
+@deftypevar {unsigned 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 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
index b39dfbff2c6678d58a0b11dee3862b3a17fe21a5..4a73927f805abf941c8f77926dac8f46e6a5ce26 100644 (file)
@@ -22,6 +22,7 @@
 #include <pthreadP.h>
 #include <tls.h>
 #include <rseq-internal.h>
+#include <thread_pointer.h>
 
 #define TUNABLE_NAMESPACE pthread
 #include <dl-tunables.h>
@@ -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,23 @@ __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);
+      }
+
+#ifdef RSEQ_SIG
+    /* This should be a compile-time constant, but the current
+       infrastructure makes it difficult to determine its value.  Not
+       all targets support __thread_pointer, so set __rseq_offset only
+       if thre rseq registration may have happened because RSEQ_SIG is
+       defined.  */
+    extern int offset __asm__ ("__rseq_offset");
+    offset = (char *) &pd->rseq_area - (char *) __thread_pointer ();
+#endif
   }
 
   /* Set initial thread's stack block from 0 up to __libc_stack_end.
index 62a796f214d744083ee6ab6972bcc81e782bdd51..61acc1987d4a60ffa396c955214e0f8d4599e315 100644 (file)
@@ -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 \
index 26452f3f17b5421d049642865bec0595bf6a9e96..3f8809a1581f27d042b2526d2250c5e0e2898770 100644 (file)
@@ -316,6 +316,11 @@ librt {
 }
 
 ld {
+  GLIBC_2.35 {
+    __rseq_flags;
+    __rseq_offset;
+    __rseq_size;
+  }
   GLIBC_PRIVATE {
     __nptl_change_stack_perm;
   }
index 80b2fe672541c6e946c6ac202960c3528b5e85c6..717a35f24210fcaad00adc3bca418393e8b0deb1 100644 (file)
@@ -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
index 98a03f611f98f3a49d0f5eca738741ad92d950e3..76911bd7f84dc5d5ad73c5f21036fe781722c4e4 100644 (file)
@@ -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
index 048f17c8486f3d546948e8298a4afa4fdce16822..71c67f9803b10eaaec3689818956f91c8ee9c8d7 100644 (file)
@@ -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
index cc8825c3bc68ad4aa08b1083acea3fa5f997a585..3859433b21671e4c095c2cce645534592ccc685e 100644 (file)
@@ -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
index cc8825c3bc68ad4aa08b1083acea3fa5f997a585..3859433b21671e4c095c2cce645534592ccc685e 100644 (file)
@@ -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
index 564ac09737d6d8d5afdb2aefae5dbd0c2aaffbf8..6bfc582b73563a40be695612f3abee6be75593f4 100644 (file)
@@ -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
index d155a59843df90918e3f6800efb86411f0f23b2e..efccd6a023675b15623539fd71288127dfb2fcda 100644 (file)
@@ -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
index 0478e220712a55e68dbf03aa2afb8878411e2aef..1eb94ae75fb2867c2aae1ed30e78f8a5d131fd8a 100644 (file)
@@ -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
index 33f91199bfa516fbad2b738d27eef634e7ed6d56..2cc68bcf7b3257138de20d45997b4fdef379d357 100644 (file)
@@ -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
index cc8825c3bc68ad4aa08b1083acea3fa5f997a585..3859433b21671e4c095c2cce645534592ccc685e 100644 (file)
@@ -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
index 3ba474c27f62fb1035c194097f0d0fbe3eea303e..e62b2742afd08c8dd114814d8e101de1ce14d3fc 100644 (file)
@@ -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
index a4933c3541119538383fd444b34cd4a35d5aab5b..5d63d74e8f7f8b5fd14551dae7b0dd0a1640b5d3 100644 (file)
@@ -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
index be09641a48962434b03f2aa45897ef74da3e8eb9..53ca22de2f0218236acce5ae3f4f718b45fbf071 100644 (file)
@@ -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
index be09641a48962434b03f2aa45897ef74da3e8eb9..53ca22de2f0218236acce5ae3f4f718b45fbf071 100644 (file)
@@ -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
index 1ea36e13f294a2495b388fdb1ae2e8599471bf09..d1cdd68333a78f51415dd3952e82e1598078abe7 100644 (file)
@@ -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
index 52178802dd82b59aec99573988172590de683455..bcbba1823eafa3cca0145ad4845060245fc32413 100644 (file)
@@ -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
index 4bbfba7a61c7a5ef05eeb10c331072768d101b17..0d033cb8bdf5b99c5bfea72f84a54bee94acfa4e 100644 (file)
@@ -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
index 283fb4510bea40ba233662c44b9c7d99514586cf..9c627b1ddfc76ab587f5f10bdb9e896556af62a7 100644 (file)
@@ -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
index b1f313c7cd33defc02660a9ab1a934b0c19fbf62..3a748c281708bbe2dec72a9646a5a1c9c43f920a 100644 (file)
@@ -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
index 94ca64c43db63b2a49a8aa4af3e97dc5b1629f49..4c67ea18d6569fa5ca0e53dbf64bc6d76723bf0b 100644 (file)
@@ -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
index 845f356c3c3fad54ddea4aae75b1f059c3d6d9c6..09596f09e21b0e9e731faac622df9557beccdf35 100644 (file)
@@ -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
index 15bc7ffd6eda632df007d6af893c4dc07cf8fe16..9e8f99fd51a063b15312a1492922a9687d89df55 100644 (file)
@@ -26,7 +26,7 @@
 #include <sys/rseq.h>
 
 #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 */
 
index b56f005bebd3baf158797bd40843fba3193e8c43..2c47004baedebb5f52039a9ca1e2f55aa8f15345 100644 (file)
@@ -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
index 6f788a086d68aaa500197acbdbc3f08e0e03561b..385a73a2575884b17dd107b360392a746fdd70df 100644 (file)
@@ -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
index d155a59843df90918e3f6800efb86411f0f23b2e..efccd6a023675b15623539fd71288127dfb2fcda 100644 (file)
@@ -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
index d155a59843df90918e3f6800efb86411f0f23b2e..efccd6a023675b15623539fd71288127dfb2fcda 100644 (file)
@@ -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
index 0c6610e3c2f00cf3d5a8af0a6890487e477e6427..8fb5ff3ef33379dbf1d891da05def7a83905fb65 100644 (file)
@@ -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
index 33f91199bfa516fbad2b738d27eef634e7ed6d56..2cc68bcf7b3257138de20d45997b4fdef379d357 100644 (file)
@@ -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
index c8edff50d40e29b6a4ab4905dcedadfc66fdc5de..1215b5d086b8852b5692b422fdb2006cf52b5c43 100644 (file)
@@ -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 */
index 000e351872fc2f76c4096ca48ed698aa79096b27..6d73f77e9621da42fe61ecf8ef910f218f07b9a3 100644 (file)
@@ -21,6 +21,7 @@
 #include <support/namespace.h>
 #include <support/xthread.h>
 #include <sysdep.h>
+#include <thread_pointer.h>
 #include <unistd.h>
 
 #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),
index 926376b6a5446eceb8dc80e324396b500978cc21..572c11166f8b6533fc3dc14035fb7ecc6f16019e 100644 (file)
 # include <stdlib.h>
 # include <string.h>
 # include <syscall.h>
+# include <thread_pointer.h>
+# include <tls.h>
 # 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
index d3cdf7611eb9cab33080cdb9711460af7f443848..49a8f31c933e546b6e682187431f184765e5fabb 100644 (file)
@@ -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
index c70bccf78245a552f32e5cf0dfd0c876b6acb328..ce68cc6304f3a46e511afc87cabb593754817fd0 100644 (file)
@@ -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