glibc: add supposrt for rseq
add rseq support Signed-off-by: qinyu <qinyu16@huawei.com> (cherry picked from commit db74864101252bb75250782ca32e47d1b1545c1f)
This commit is contained in:
parent
eae9e26939
commit
9042da8301
14
glibc.spec
14
glibc.spec
@ -66,7 +66,7 @@
|
||||
##############################################################################
|
||||
Name: glibc
|
||||
Version: 2.34
|
||||
Release: 60
|
||||
Release: 61
|
||||
Summary: The GNU libc libraries
|
||||
License: %{all_license}
|
||||
URL: http://www.gnu.org/software/glibc/
|
||||
@ -189,6 +189,15 @@ Patch102: socket-Do-not-use-AF_NETLINK-in-__opensock.patch
|
||||
Patch103: tst-socket-timestamp-compat.c-Check-__TIMESIZE-BZ-28.patch
|
||||
Patch104: linux-Fix-missing-__convert_scm_timestamps-BZ-28860.patch
|
||||
Patch105: linux-fix-accuracy-of-get_nprocs-and-get_nprocs_conf.patch
|
||||
Patch106: rseq-nptl-Add-thread_pointer.h-for-defining-__thread_poin.patch
|
||||
Patch107: rseq-nptl-Introduce-tcb-access.h-for-THREAD_-accessors.patch
|
||||
Patch108: rseq-nptl-Introduce-THREAD_GETMEM_VOLATILE.patch
|
||||
Patch109: rseq-nptl-Add-rseq-registration.patch
|
||||
Patch110: rseq-Linux-Use-rseq-to-accelerate-sched_getcpu.patch
|
||||
Patch111: rseq-nptl-Add-glibc.pthread.rseq-tunable-to-control-rseq-.patch
|
||||
Patch112: rseq-nptl-Add-public-rseq-symbols-and-sys-rseq.h.patch
|
||||
Patch113: rseq-nptl-rseq-failure-after-registration-on-main-thread-.patch
|
||||
Patch114: rseq-Linux-Use-ptrdiff_t-for-__rseq_offset.patch
|
||||
|
||||
Patch9000: turn-default-value-of-x86_rep_stosb_threshold_form_2K_to_1M.patch
|
||||
Patch9001: delete-no-hard-link-to-avoid-all_language-package-to.patch
|
||||
@ -1222,6 +1231,9 @@ fi
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Fri Feb 25 2022 qinyu<qinyu16@huawei.com> - 2.34-61
|
||||
- add rseq support
|
||||
|
||||
* Thu Feb 24 2022 Yang Yanchao<yangyanchao6@huawei.com> - 2.34-60
|
||||
- Only in the CI environment, the build is interrupted due to test case failure.
|
||||
|
||||
|
||||
197
rseq-Linux-Use-ptrdiff_t-for-__rseq_offset.patch
Normal file
197
rseq-Linux-Use-ptrdiff_t-for-__rseq_offset.patch
Normal file
@ -0,0 +1,197 @@
|
||||
From 6cb5cc084432eba1f2215ec7c9816b748c32182a Mon Sep 17 00:00:00 2001
|
||||
From: Florian Weimer <fweimer@redhat.com>
|
||||
Date: Wed, 2 Feb 2022 22:37:20 +0100
|
||||
Subject: [PATCH 9/9] Linux: Use ptrdiff_t for __rseq_offset
|
||||
|
||||
This matches the data size initial-exec relocations use on most
|
||||
targets.
|
||||
|
||||
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
|
||||
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
|
||||
---
|
||||
manual/threads.texi | 2 +-
|
||||
sysdeps/nptl/dl-tls_init_tp.c | 4 ++--
|
||||
sysdeps/unix/sysv/linux/aarch64/ld.abilist | 2 +-
|
||||
sysdeps/unix/sysv/linux/alpha/ld.abilist | 2 +-
|
||||
sysdeps/unix/sysv/linux/ia64/ld.abilist | 2 +-
|
||||
sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist | 2 +-
|
||||
sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist | 2 +-
|
||||
sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist | 2 +-
|
||||
sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist | 2 +-
|
||||
sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist | 2 +-
|
||||
sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist | 2 +-
|
||||
sysdeps/unix/sysv/linux/sys/rseq.h | 3 ++-
|
||||
sysdeps/unix/sysv/linux/x86_64/64/ld.abilist | 2 +-
|
||||
13 files changed, 15 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/manual/threads.texi b/manual/threads.texi
|
||||
index ab44a92c..4b9fc946 100644
|
||||
--- a/manual/threads.texi
|
||||
+++ b/manual/threads.texi
|
||||
@@ -1004,7 +1004,7 @@ 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
|
||||
+@deftypevar {ptrdiff_t} __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
|
||||
diff --git a/sysdeps/nptl/dl-tls_init_tp.c b/sysdeps/nptl/dl-tls_init_tp.c
|
||||
index 4a73927f..86e87c7d 100644
|
||||
--- a/sysdeps/nptl/dl-tls_init_tp.c
|
||||
+++ b/sysdeps/nptl/dl-tls_init_tp.c
|
||||
@@ -46,7 +46,7 @@ rtld_mutex_dummy (pthread_mutex_t *lock)
|
||||
|
||||
const unsigned int __rseq_flags;
|
||||
const unsigned int __rseq_size attribute_relro;
|
||||
-const int __rseq_offset attribute_relro;
|
||||
+const ptrdiff_t __rseq_offset attribute_relro;
|
||||
|
||||
void
|
||||
__tls_pre_init_tp (void)
|
||||
@@ -119,7 +119,7 @@ __tls_init_tp (void)
|
||||
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");
|
||||
+ extern ptrdiff_t offset __asm__ ("__rseq_offset");
|
||||
offset = (char *) &pd->rseq_area - (char *) __thread_pointer ();
|
||||
#endif
|
||||
}
|
||||
diff --git a/sysdeps/unix/sysv/linux/aarch64/ld.abilist b/sysdeps/unix/sysv/linux/aarch64/ld.abilist
|
||||
index bf4d4f9b..5151c078 100644
|
||||
--- a/sysdeps/unix/sysv/linux/aarch64/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/aarch64/ld.abilist
|
||||
@@ -5,5 +5,5 @@ GLIBC_2.17 _dl_mcount F
|
||||
GLIBC_2.17 _r_debug D 0x28
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
GLIBC_2.35 __rseq_flags D 0x4
|
||||
-GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x8
|
||||
GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/alpha/ld.abilist b/sysdeps/unix/sysv/linux/alpha/ld.abilist
|
||||
index a23325a5..3e296c54 100644
|
||||
--- a/sysdeps/unix/sysv/linux/alpha/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/alpha/ld.abilist
|
||||
@@ -4,6 +4,6 @@ GLIBC_2.1 _dl_mcount F
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
GLIBC_2.35 __rseq_flags D 0x4
|
||||
-GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x8
|
||||
GLIBC_2.35 __rseq_size D 0x4
|
||||
GLIBC_2.4 __stack_chk_guard D 0x8
|
||||
diff --git a/sysdeps/unix/sysv/linux/ia64/ld.abilist b/sysdeps/unix/sysv/linux/ia64/ld.abilist
|
||||
index 8ccb5be9..5471b24d 100644
|
||||
--- a/sysdeps/unix/sysv/linux/ia64/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/ia64/ld.abilist
|
||||
@@ -4,5 +4,5 @@ GLIBC_2.2 _r_debug D 0x28
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
GLIBC_2.35 __rseq_flags D 0x4
|
||||
-GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x8
|
||||
GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist
|
||||
index 37a47ebc..f26e594a 100644
|
||||
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist
|
||||
@@ -4,6 +4,6 @@ GLIBC_2.2 _dl_mcount F
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
GLIBC_2.35 __rseq_flags D 0x4
|
||||
-GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x8
|
||||
GLIBC_2.35 __rseq_size D 0x4
|
||||
GLIBC_2.4 __stack_chk_guard D 0x8
|
||||
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist
|
||||
index da24dc7f..21f472e6 100644
|
||||
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist
|
||||
@@ -6,5 +6,5 @@ GLIBC_2.3 _dl_mcount F
|
||||
GLIBC_2.3 _r_debug D 0x28
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
GLIBC_2.35 __rseq_flags D 0x4
|
||||
-GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x8
|
||||
GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist
|
||||
index b9ae89ae..9c9c4045 100644
|
||||
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist
|
||||
@@ -6,5 +6,5 @@ GLIBC_2.22 __tls_get_addr_opt F
|
||||
GLIBC_2.23 __parse_hwcap_and_convert_at_platform F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
GLIBC_2.35 __rseq_flags D 0x4
|
||||
-GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x8
|
||||
GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist
|
||||
index 48431c91..a7758a0e 100644
|
||||
--- a/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist
|
||||
@@ -5,5 +5,5 @@ GLIBC_2.27 _dl_mcount F
|
||||
GLIBC_2.27 _r_debug D 0x28
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
GLIBC_2.35 __rseq_flags D 0x4
|
||||
-GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x8
|
||||
GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist
|
||||
index 117d1430..78d07160 100644
|
||||
--- a/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist
|
||||
@@ -4,5 +4,5 @@ GLIBC_2.2 _r_debug D 0x28
|
||||
GLIBC_2.3 __tls_get_offset F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
GLIBC_2.35 __rseq_flags D 0x4
|
||||
-GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x8
|
||||
GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist
|
||||
index 8ccb5be9..5471b24d 100644
|
||||
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist
|
||||
@@ -4,5 +4,5 @@ GLIBC_2.2 _r_debug D 0x28
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
GLIBC_2.35 __rseq_flags D 0x4
|
||||
-GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x8
|
||||
GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/sys/rseq.h b/sysdeps/unix/sysv/linux/sys/rseq.h
|
||||
index 1215b5d0..791ed831 100644
|
||||
--- a/sysdeps/unix/sysv/linux/sys/rseq.h
|
||||
+++ b/sysdeps/unix/sysv/linux/sys/rseq.h
|
||||
@@ -21,6 +21,7 @@
|
||||
/* Architecture-specific rseq signature. */
|
||||
#include <bits/rseq.h>
|
||||
|
||||
+#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <bits/endian.h>
|
||||
@@ -172,7 +173,7 @@ struct rseq
|
||||
#endif /* __GLIBC_HAVE_KERNEL_RSEQ */
|
||||
|
||||
/* Offset from the thread pointer to the rseq area. */
|
||||
-extern const int __rseq_offset;
|
||||
+extern const ptrdiff_t __rseq_offset;
|
||||
|
||||
/* Size of the registered rseq area. 0 if the registration was
|
||||
unsuccessful. */
|
||||
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist b/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist
|
||||
index ae622bdf..5a8bd322 100644
|
||||
--- a/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist
|
||||
@@ -4,5 +4,5 @@ GLIBC_2.2.5 _r_debug D 0x28
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
GLIBC_2.35 __rseq_flags D 0x4
|
||||
-GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x8
|
||||
GLIBC_2.35 __rseq_size D 0x4
|
||||
--
|
||||
2.23.0
|
||||
|
||||
48
rseq-Linux-Use-rseq-to-accelerate-sched_getcpu.patch
Normal file
48
rseq-Linux-Use-rseq-to-accelerate-sched_getcpu.patch
Normal file
@ -0,0 +1,48 @@
|
||||
From 00bae0eb5212a1ec4e8b4b90294937903628e7ce Mon Sep 17 00:00:00 2001
|
||||
From: Florian Weimer <fweimer@redhat.com>
|
||||
Date: Thu, 9 Dec 2021 09:49:32 +0100
|
||||
Subject: [PATCH 5/9] Linux: Use rseq to accelerate sched_getcpu
|
||||
|
||||
Co-Authored-By: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
|
||||
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
---
|
||||
sysdeps/unix/sysv/linux/sched_getcpu.c | 19 +++++++++++++++++--
|
||||
1 file changed, 17 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/sysdeps/unix/sysv/linux/sched_getcpu.c b/sysdeps/unix/sysv/linux/sched_getcpu.c
|
||||
index c41e986f..6f78edae 100644
|
||||
--- a/sysdeps/unix/sysv/linux/sched_getcpu.c
|
||||
+++ b/sysdeps/unix/sysv/linux/sched_getcpu.c
|
||||
@@ -20,8 +20,8 @@
|
||||
#include <sysdep.h>
|
||||
#include <sysdep-vdso.h>
|
||||
|
||||
-int
|
||||
-sched_getcpu (void)
|
||||
+static int
|
||||
+vsyscall_sched_getcpu (void)
|
||||
{
|
||||
unsigned int cpu;
|
||||
int r = -1;
|
||||
@@ -32,3 +32,18 @@ sched_getcpu (void)
|
||||
#endif
|
||||
return r == -1 ? r : cpu;
|
||||
}
|
||||
+
|
||||
+#ifdef RSEQ_SIG
|
||||
+int
|
||||
+sched_getcpu (void)
|
||||
+{
|
||||
+ int cpu_id = THREAD_GETMEM_VOLATILE (THREAD_SELF, rseq_area.cpu_id);
|
||||
+ return __glibc_likely (cpu_id >= 0) ? cpu_id : vsyscall_sched_getcpu ();
|
||||
+}
|
||||
+#else /* RSEQ_SIG */
|
||||
+int
|
||||
+sched_getcpu (void)
|
||||
+{
|
||||
+ return vsyscall_sched_getcpu ();
|
||||
+}
|
||||
+#endif /* RSEQ_SIG */
|
||||
--
|
||||
2.23.0
|
||||
|
||||
292
rseq-nptl-Add-glibc.pthread.rseq-tunable-to-control-rseq-.patch
Normal file
292
rseq-nptl-Add-glibc.pthread.rseq-tunable-to-control-rseq-.patch
Normal file
@ -0,0 +1,292 @@
|
||||
From ff1e1631665651ceb8b4b226ec725140c7420e8c Mon Sep 17 00:00:00 2001
|
||||
From: Florian Weimer <fweimer@redhat.com>
|
||||
Date: Thu, 9 Dec 2021 09:49:32 +0100
|
||||
Subject: [PATCH 6/9] nptl: Add glibc.pthread.rseq tunable to control rseq
|
||||
registration
|
||||
|
||||
This tunable allows applications to register the rseq area instead
|
||||
of glibc.
|
||||
|
||||
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
||||
---
|
||||
manual/tunables.texi | 10 +++
|
||||
nptl/pthread_create.c | 10 ++-
|
||||
sysdeps/nptl/dl-tls_init_tp.c | 11 ++-
|
||||
sysdeps/nptl/dl-tunables.list | 6 ++
|
||||
sysdeps/nptl/internaltypes.h | 1 +
|
||||
sysdeps/unix/sysv/linux/Makefile | 8 ++
|
||||
sysdeps/unix/sysv/linux/rseq-internal.h | 19 +++--
|
||||
sysdeps/unix/sysv/linux/tst-rseq-disable.c | 89 ++++++++++++++++++++++
|
||||
8 files changed, 145 insertions(+), 9 deletions(-)
|
||||
create mode 100644 sysdeps/unix/sysv/linux/tst-rseq-disable.c
|
||||
|
||||
diff --git a/manual/tunables.texi b/manual/tunables.texi
|
||||
index 658547c6..1f5c4102 100644
|
||||
--- a/manual/tunables.texi
|
||||
+++ b/manual/tunables.texi
|
||||
@@ -413,6 +413,16 @@ The value is measured in bytes. The default is @samp{41943040}
|
||||
(fourty mibibytes).
|
||||
@end deftp
|
||||
|
||||
+@deftp Tunable glibc.pthread.rseq
|
||||
+The @code{glibc.pthread.rseq} tunable can be set to @samp{0}, to disable
|
||||
+restartable sequences support in @theglibc{}. This enables applications
|
||||
+to perform direct restartable sequence registration with the kernel.
|
||||
+The default is @samp{1}, which means that @theglibc{} performs
|
||||
+registration on behalf of the application.
|
||||
+
|
||||
+Restartable sequences are a Linux-specific extension.
|
||||
+@end deftp
|
||||
+
|
||||
@node Hardware Capability Tunables
|
||||
@section Hardware Capability Tunables
|
||||
@cindex hardware capability tunables
|
||||
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
|
||||
index d2b40924..f405fa35 100644
|
||||
--- a/nptl/pthread_create.c
|
||||
+++ b/nptl/pthread_create.c
|
||||
@@ -369,7 +369,10 @@ start_thread (void *arg)
|
||||
__ctype_init ();
|
||||
|
||||
/* Register rseq TLS to the kernel. */
|
||||
- rseq_register_current_thread (pd);
|
||||
+ {
|
||||
+ bool do_rseq = THREAD_GETMEM (pd, flags) & ATTR_FLAG_DO_RSEQ;
|
||||
+ rseq_register_current_thread (pd, do_rseq);
|
||||
+ }
|
||||
|
||||
#ifndef __ASSUME_SET_ROBUST_LIST
|
||||
if (__nptl_set_robust_list_avail)
|
||||
@@ -678,6 +681,11 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
|
||||
pd->flags = ((iattr->flags & ~(ATTR_FLAG_SCHED_SET | ATTR_FLAG_POLICY_SET))
|
||||
| (self->flags & (ATTR_FLAG_SCHED_SET | ATTR_FLAG_POLICY_SET)));
|
||||
|
||||
+ /* Inherit rseq registration state. Without seccomp filters, rseq
|
||||
+ registration will either always fail or always succeed. */
|
||||
+ if ((int) THREAD_GETMEM_VOLATILE (self, rseq_area.cpu_id) >= 0)
|
||||
+ pd->flags |= ATTR_FLAG_DO_RSEQ;
|
||||
+
|
||||
/* Initialize the field for the ID of the thread which is waiting
|
||||
for us. This is a self-reference in case the thread is created
|
||||
detached. */
|
||||
diff --git a/sysdeps/nptl/dl-tls_init_tp.c b/sysdeps/nptl/dl-tls_init_tp.c
|
||||
index fedb876f..b39dfbff 100644
|
||||
--- a/sysdeps/nptl/dl-tls_init_tp.c
|
||||
+++ b/sysdeps/nptl/dl-tls_init_tp.c
|
||||
@@ -23,6 +23,9 @@
|
||||
#include <tls.h>
|
||||
#include <rseq-internal.h>
|
||||
|
||||
+#define TUNABLE_NAMESPACE pthread
|
||||
+#include <dl-tunables.h>
|
||||
+
|
||||
#ifndef __ASSUME_SET_ROBUST_LIST
|
||||
bool __nptl_set_robust_list_avail;
|
||||
rtld_hidden_data_def (__nptl_set_robust_list_avail)
|
||||
@@ -92,7 +95,13 @@ __tls_init_tp (void)
|
||||
}
|
||||
}
|
||||
|
||||
- rseq_register_current_thread (pd);
|
||||
+ {
|
||||
+ bool do_rseq = true;
|
||||
+#if HAVE_TUNABLES
|
||||
+ do_rseq = TUNABLE_GET (rseq, int, NULL);
|
||||
+#endif
|
||||
+ rseq_register_current_thread (pd, do_rseq);
|
||||
+ }
|
||||
|
||||
/* Set initial thread's stack block from 0 up to __libc_stack_end.
|
||||
It will be bigger than it actually is, but for unwind.c/pt-longjmp.c
|
||||
diff --git a/sysdeps/nptl/dl-tunables.list b/sysdeps/nptl/dl-tunables.list
|
||||
index ac5d0532..d24f4be0 100644
|
||||
--- a/sysdeps/nptl/dl-tunables.list
|
||||
+++ b/sysdeps/nptl/dl-tunables.list
|
||||
@@ -27,5 +27,11 @@ glibc {
|
||||
type: SIZE_T
|
||||
default: 41943040
|
||||
}
|
||||
+ rseq {
|
||||
+ type: INT_32
|
||||
+ minval: 0
|
||||
+ maxval: 1
|
||||
+ default: 1
|
||||
+ }
|
||||
}
|
||||
}
|
||||
diff --git a/sysdeps/nptl/internaltypes.h b/sysdeps/nptl/internaltypes.h
|
||||
index 50a2ad19..8205c6d1 100644
|
||||
--- a/sysdeps/nptl/internaltypes.h
|
||||
+++ b/sysdeps/nptl/internaltypes.h
|
||||
@@ -49,6 +49,7 @@ struct pthread_attr
|
||||
#define ATTR_FLAG_OLDATTR 0x0010
|
||||
#define ATTR_FLAG_SCHED_SET 0x0020
|
||||
#define ATTR_FLAG_POLICY_SET 0x0040
|
||||
+#define ATTR_FLAG_DO_RSEQ 0x0080
|
||||
|
||||
/* Used to allocate a pthread_attr_t object which is also accessed
|
||||
internally. */
|
||||
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
|
||||
index f103a964..0657f400 100644
|
||||
--- a/sysdeps/unix/sysv/linux/Makefile
|
||||
+++ b/sysdeps/unix/sysv/linux/Makefile
|
||||
@@ -135,6 +135,12 @@ tests-internal += \
|
||||
tst-sigcontext-get_pc \
|
||||
# tests-internal
|
||||
|
||||
+ifneq (no,$(have-tunables))
|
||||
+tests-internal += \
|
||||
+ tst-rseq-disable \
|
||||
+ # tests-internal $(have-tunables)
|
||||
+endif
|
||||
+
|
||||
tests-time64 += \
|
||||
tst-adjtimex-time64 \
|
||||
tst-clock_adjtime-time64 \
|
||||
@@ -226,6 +232,8 @@ $(objpfx)tst-mman-consts.out: ../sysdeps/unix/sysv/linux/tst-mman-consts.py
|
||||
< /dev/null > $@ 2>&1; $(evaluate-test)
|
||||
$(objpfx)tst-mman-consts.out: $(sysdeps-linux-python-deps)
|
||||
|
||||
+tst-rseq-disable-ENV = GLIBC_TUNABLES=glibc.pthread.rseq=0
|
||||
+
|
||||
endif # $(subdir) == misc
|
||||
|
||||
ifeq ($(subdir),time)
|
||||
diff --git a/sysdeps/unix/sysv/linux/rseq-internal.h b/sysdeps/unix/sysv/linux/rseq-internal.h
|
||||
index 909f5478..15bc7ffd 100644
|
||||
--- a/sysdeps/unix/sysv/linux/rseq-internal.h
|
||||
+++ b/sysdeps/unix/sysv/linux/rseq-internal.h
|
||||
@@ -21,22 +21,27 @@
|
||||
#include <sysdep.h>
|
||||
#include <errno.h>
|
||||
#include <kernel-features.h>
|
||||
+#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/rseq.h>
|
||||
|
||||
#ifdef RSEQ_SIG
|
||||
static inline void
|
||||
-rseq_register_current_thread (struct pthread *self)
|
||||
+rseq_register_current_thread (struct pthread *self, bool do_rseq)
|
||||
{
|
||||
- int ret = INTERNAL_SYSCALL_CALL (rseq,
|
||||
- &self->rseq_area, sizeof (self->rseq_area),
|
||||
- 0, RSEQ_SIG);
|
||||
- if (INTERNAL_SYSCALL_ERROR_P (ret))
|
||||
- THREAD_SETMEM (self, rseq_area.cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED);
|
||||
+ if (do_rseq)
|
||||
+ {
|
||||
+ int ret = INTERNAL_SYSCALL_CALL (rseq, &self->rseq_area,
|
||||
+ sizeof (self->rseq_area),
|
||||
+ 0, RSEQ_SIG);
|
||||
+ if (!INTERNAL_SYSCALL_ERROR_P (ret))
|
||||
+ return;
|
||||
+ }
|
||||
+ THREAD_SETMEM (self, rseq_area.cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED);
|
||||
}
|
||||
#else /* RSEQ_SIG */
|
||||
static inline void
|
||||
-rseq_register_current_thread (struct pthread *self)
|
||||
+rseq_register_current_thread (struct pthread *self, bool do_rseq)
|
||||
{
|
||||
THREAD_SETMEM (self, rseq_area.cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED);
|
||||
}
|
||||
diff --git a/sysdeps/unix/sysv/linux/tst-rseq-disable.c b/sysdeps/unix/sysv/linux/tst-rseq-disable.c
|
||||
new file mode 100644
|
||||
index 00000000..000e3518
|
||||
--- /dev/null
|
||||
+++ b/sysdeps/unix/sysv/linux/tst-rseq-disable.c
|
||||
@@ -0,0 +1,89 @@
|
||||
+/* Test disabling of rseq registration via tunable.
|
||||
+ Copyright (C) 2021 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 <stdio.h>
|
||||
+#include <support/check.h>
|
||||
+#include <support/namespace.h>
|
||||
+#include <support/xthread.h>
|
||||
+#include <sysdep.h>
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+#ifdef RSEQ_SIG
|
||||
+
|
||||
+/* Check that rseq can be registered and has not been taken by glibc. */
|
||||
+static void
|
||||
+check_rseq_disabled (void)
|
||||
+{
|
||||
+ struct pthread *pd = THREAD_SELF;
|
||||
+ TEST_COMPARE ((int) pd->rseq_area.cpu_id, RSEQ_CPU_ID_REGISTRATION_FAILED);
|
||||
+
|
||||
+ int ret = syscall (__NR_rseq, &pd->rseq_area, sizeof (pd->rseq_area),
|
||||
+ 0, RSEQ_SIG);
|
||||
+ if (ret == 0)
|
||||
+ {
|
||||
+ ret = syscall (__NR_rseq, &pd->rseq_area, sizeof (pd->rseq_area),
|
||||
+ RSEQ_FLAG_UNREGISTER, RSEQ_SIG);
|
||||
+ TEST_COMPARE (ret, 0);
|
||||
+ pd->rseq_area.cpu_id = RSEQ_CPU_ID_REGISTRATION_FAILED;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ TEST_VERIFY (errno != -EINVAL);
|
||||
+ TEST_VERIFY (errno != -EBUSY);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void *
|
||||
+thread_func (void *ignored)
|
||||
+{
|
||||
+ check_rseq_disabled ();
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+proc_func (void *ignored)
|
||||
+{
|
||||
+ check_rseq_disabled ();
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+do_test (void)
|
||||
+{
|
||||
+ puts ("info: checking main thread");
|
||||
+ check_rseq_disabled ();
|
||||
+
|
||||
+ puts ("info: checking main thread (2)");
|
||||
+ check_rseq_disabled ();
|
||||
+
|
||||
+ puts ("info: checking new thread");
|
||||
+ xpthread_join (xpthread_create (NULL, thread_func, NULL));
|
||||
+
|
||||
+ puts ("info: checking subprocess");
|
||||
+ support_isolate_in_subprocess (proc_func, NULL);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+#else /* !RSEQ_SIG */
|
||||
+static int
|
||||
+do_test (void)
|
||||
+{
|
||||
+ FAIL_UNSUPPORTED ("glibc does not define RSEQ_SIG, skipping test");
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+#include <support/test-driver.c>
|
||||
--
|
||||
2.23.0
|
||||
|
||||
692
rseq-nptl-Add-public-rseq-symbols-and-sys-rseq.h.patch
Normal file
692
rseq-nptl-Add-public-rseq-symbols-and-sys-rseq.h.patch
Normal file
@ -0,0 +1,692 @@
|
||||
From e3291e074ff67a8cc2630ab6175976f875d61a14 Mon Sep 17 00:00:00 2001
|
||||
From: Florian Weimer <fweimer@redhat.com>
|
||||
Date: Thu, 17 Feb 2022 14:56:12 +0800
|
||||
Subject: [PATCH 7/9] nptl: Add public rseq symbols and <sys/rseq.h>
|
||||
|
||||
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>
|
||||
-----
|
||||
conflicts:
|
||||
context conflicts
|
||||
---
|
||||
NEWS | 11 +++
|
||||
manual/threads.texi | 81 +++++++++++++++++++
|
||||
sysdeps/nptl/dl-tls_init_tp.c | 23 +++++-
|
||||
sysdeps/unix/sysv/linux/Makefile | 3 +-
|
||||
sysdeps/unix/sysv/linux/Versions | 5 ++
|
||||
sysdeps/unix/sysv/linux/aarch64/ld.abilist | 3 +
|
||||
sysdeps/unix/sysv/linux/alpha/ld.abilist | 3 +
|
||||
sysdeps/unix/sysv/linux/arc/ld.abilist | 3 +
|
||||
sysdeps/unix/sysv/linux/arm/be/ld.abilist | 3 +
|
||||
sysdeps/unix/sysv/linux/arm/le/ld.abilist | 3 +
|
||||
sysdeps/unix/sysv/linux/csky/ld.abilist | 3 +
|
||||
sysdeps/unix/sysv/linux/hppa/ld.abilist | 3 +
|
||||
sysdeps/unix/sysv/linux/i386/ld.abilist | 3 +
|
||||
sysdeps/unix/sysv/linux/ia64/ld.abilist | 3 +
|
||||
.../unix/sysv/linux/m68k/coldfire/ld.abilist | 3 +
|
||||
.../unix/sysv/linux/m68k/m680x0/ld.abilist | 3 +
|
||||
sysdeps/unix/sysv/linux/microblaze/ld.abilist | 3 +
|
||||
.../unix/sysv/linux/mips/mips32/ld.abilist | 3 +
|
||||
.../sysv/linux/mips/mips64/n32/ld.abilist | 3 +
|
||||
.../sysv/linux/mips/mips64/n64/ld.abilist | 3 +
|
||||
sysdeps/unix/sysv/linux/nios2/ld.abilist | 3 +
|
||||
.../sysv/linux/powerpc/powerpc32/ld.abilist | 3 +
|
||||
.../linux/powerpc/powerpc64/be/ld.abilist | 3 +
|
||||
.../linux/powerpc/powerpc64/le/ld.abilist | 3 +
|
||||
sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist | 3 +
|
||||
sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist | 3 +
|
||||
sysdeps/unix/sysv/linux/rseq-internal.h | 8 +-
|
||||
.../unix/sysv/linux/s390/s390-32/ld.abilist | 3 +
|
||||
.../unix/sysv/linux/s390/s390-64/ld.abilist | 3 +
|
||||
sysdeps/unix/sysv/linux/sh/be/ld.abilist | 3 +
|
||||
sysdeps/unix/sysv/linux/sh/le/ld.abilist | 3 +
|
||||
.../unix/sysv/linux/sparc/sparc32/ld.abilist | 3 +
|
||||
.../unix/sysv/linux/sparc/sparc64/ld.abilist | 3 +
|
||||
sysdeps/unix/sysv/linux/sys/rseq.h | 10 +++
|
||||
sysdeps/unix/sysv/linux/tst-rseq-disable.c | 6 ++
|
||||
sysdeps/unix/sysv/linux/tst-rseq.c | 8 ++
|
||||
sysdeps/unix/sysv/linux/x86_64/64/ld.abilist | 3 +
|
||||
sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist | 3 +
|
||||
38 files changed, 237 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/NEWS b/NEWS
|
||||
index ffae154a..1b0ee549 100644
|
||||
--- a/NEWS
|
||||
+++ b/NEWS
|
||||
@@ -129,6 +129,17 @@ Major new features:
|
||||
than or equal to a given integer. This function is a GNU extension,
|
||||
although Solaris also provides a similar function.
|
||||
|
||||
+* 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 function pthread_mutex_consistent_np has been deprecated; programs
|
||||
diff --git a/manual/threads.texi b/manual/threads.texi
|
||||
index 06b6b277..ab44a92c 100644
|
||||
--- a/manual/threads.texi
|
||||
+++ b/manual/threads.texi
|
||||
@@ -629,6 +629,8 @@ the standard.
|
||||
* Waiting with Explicit Clocks:: Functions for waiting with an
|
||||
explicit clock specification.
|
||||
* Single-Threaded:: Detecting single-threaded execution.
|
||||
+* Restartable Sequences:: Linux-specific restartable sequences
|
||||
+ integration.
|
||||
@end menu
|
||||
|
||||
@node Default Thread Attributes
|
||||
@@ -958,6 +960,85 @@ application-created thread because future versions of @theglibc{} may
|
||||
create background threads after the first thread has been created, and
|
||||
the application has no way of knowning that these threads are present.
|
||||
|
||||
+@node Restartable Sequences
|
||||
+@subsubsection Restartable Sequences
|
||||
+
|
||||
+This section describes restartable sequences integration for
|
||||
+@theglibc{}. This functionality is only available on Linux.
|
||||
+
|
||||
+@deftp {Data Type} {struct rseq}
|
||||
+@standards{Linux, sys/rseq.h}
|
||||
+The type of the restartable sequences area. Future versions
|
||||
+of Linux may add additional fields to the end of this structure.
|
||||
+
|
||||
+
|
||||
+Users need to obtain the address of the restartable sequences area using
|
||||
+the thread pointer and the @code{__rseq_offset} variable, described
|
||||
+below.
|
||||
+
|
||||
+One use of the restartable sequences area is to read the current CPU
|
||||
+number from its @code{cpu_id} field, as an inline version of
|
||||
+@code{sched_getcpu}. @Theglibc{} sets the @code{cpu_id} field to
|
||||
+@code{RSEQ_CPU_ID_REGISTRATION_FAILED} if registration failed or was
|
||||
+explicitly disabled.
|
||||
+
|
||||
+Furthermore, users can store the address of a @code{struct rseq_cs}
|
||||
+object into the @code{rseq_cs} field of @code{struct rseq}, thus
|
||||
+informing the kernel that the thread enters a restartable sequence
|
||||
+critical section. This pointer and the code areas it itself points to
|
||||
+must not be left pointing to memory areas which are freed or re-used.
|
||||
+Several approaches can guarantee this. If the application or library
|
||||
+can guarantee that the memory used to hold the @code{struct rseq_cs} and
|
||||
+the code areas it refers to are never freed or re-used, no special
|
||||
+action must be taken. Else, before that memory is re-used of freed, the
|
||||
+application is responsible for setting the @code{rseq_cs} field to
|
||||
+@code{NULL} in each thread's restartable sequence area to guarantee that
|
||||
+it does not leak dangling references. Because the application does not
|
||||
+typically have knowledge of libraries' use of restartable sequences, it
|
||||
+is recommended that libraries using restartable sequences which may end
|
||||
+up freeing or re-using their memory set the @code{rseq_cs} field to
|
||||
+@code{NULL} before returning from library functions which use
|
||||
+restartable sequences.
|
||||
+
|
||||
+The manual for the @code{rseq} system call can be found
|
||||
+at @uref{https://git.kernel.org/pub/scm/libs/librseq/librseq.git/tree/doc/man/rseq.2}.
|
||||
+@end deftp
|
||||
+
|
||||
+@deftypevar {int} __rseq_offset
|
||||
+@standards{Linux, sys/rseq.h}
|
||||
+This variable contains the offset between the thread pointer (as defined
|
||||
+by @code{__builtin_thread_pointer} or the thread pointer register for
|
||||
+the architecture) and the restartable sequences area. This value is the
|
||||
+same for all threads in the process. If the restartable sequences area
|
||||
+is located at a lower address than the location to 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
|
||||
diff --git a/sysdeps/nptl/dl-tls_init_tp.c b/sysdeps/nptl/dl-tls_init_tp.c
|
||||
index b39dfbff..4a73927f 100644
|
||||
--- a/sysdeps/nptl/dl-tls_init_tp.c
|
||||
+++ b/sysdeps/nptl/dl-tls_init_tp.c
|
||||
@@ -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.
|
||||
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
|
||||
index 0657f400..856a9d58 100644
|
||||
--- a/sysdeps/unix/sysv/linux/Makefile
|
||||
+++ b/sysdeps/unix/sysv/linux/Makefile
|
||||
@@ -110,7 +110,8 @@ sysdep_headers += sys/mount.h sys/acct.h \
|
||||
bits/types/struct_semid64_ds_helper.h \
|
||||
bits/types/struct_shmid64_ds.h \
|
||||
bits/types/struct_shmid64_ds_helper.h \
|
||||
- bits/pthread_stack_min.h bits/pthread_stack_min-dynamic.h
|
||||
+ bits/pthread_stack_min.h bits/pthread_stack_min-dynamic.h \
|
||||
+ sys/rseq.h bits/rseq.h
|
||||
|
||||
tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
|
||||
tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \
|
||||
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
|
||||
index 26452f3f..3f8809a1 100644
|
||||
--- a/sysdeps/unix/sysv/linux/Versions
|
||||
+++ b/sysdeps/unix/sysv/linux/Versions
|
||||
@@ -316,6 +316,11 @@ librt {
|
||||
}
|
||||
|
||||
ld {
|
||||
+ GLIBC_2.35 {
|
||||
+ __rseq_flags;
|
||||
+ __rseq_offset;
|
||||
+ __rseq_size;
|
||||
+ }
|
||||
GLIBC_PRIVATE {
|
||||
__nptl_change_stack_perm;
|
||||
}
|
||||
diff --git a/sysdeps/unix/sysv/linux/aarch64/ld.abilist b/sysdeps/unix/sysv/linux/aarch64/ld.abilist
|
||||
index b7196a80..bf4d4f9b 100644
|
||||
--- a/sysdeps/unix/sysv/linux/aarch64/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/aarch64/ld.abilist
|
||||
@@ -4,3 +4,6 @@ GLIBC_2.17 __tls_get_addr F
|
||||
GLIBC_2.17 _dl_mcount F
|
||||
GLIBC_2.17 _r_debug D 0x28
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/alpha/ld.abilist b/sysdeps/unix/sysv/linux/alpha/ld.abilist
|
||||
index 13f7fc74..a23325a5 100644
|
||||
--- a/sysdeps/unix/sysv/linux/alpha/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/alpha/ld.abilist
|
||||
@@ -3,4 +3,7 @@ GLIBC_2.1 __libc_stack_end D 0x8
|
||||
GLIBC_2.1 _dl_mcount F
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
GLIBC_2.4 __stack_chk_guard D 0x8
|
||||
diff --git a/sysdeps/unix/sysv/linux/arc/ld.abilist b/sysdeps/unix/sysv/linux/arc/ld.abilist
|
||||
index 7284383a..55f0c2ab 100644
|
||||
--- a/sysdeps/unix/sysv/linux/arc/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/arc/ld.abilist
|
||||
@@ -4,3 +4,6 @@ GLIBC_2.32 __tls_get_addr F
|
||||
GLIBC_2.32 _dl_mcount F
|
||||
GLIBC_2.32 _r_debug D 0x14
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/arm/be/ld.abilist b/sysdeps/unix/sysv/linux/arm/be/ld.abilist
|
||||
index 7987bbae..f1da2c63 100644
|
||||
--- a/sysdeps/unix/sysv/linux/arm/be/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/arm/be/ld.abilist
|
||||
@@ -1,4 +1,7 @@
|
||||
GLIBC_2.34 __rtld_version_placeholder 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 __libc_stack_end D 0x4
|
||||
GLIBC_2.4 __stack_chk_guard D 0x4
|
||||
GLIBC_2.4 __tls_get_addr F
|
||||
diff --git a/sysdeps/unix/sysv/linux/arm/le/ld.abilist b/sysdeps/unix/sysv/linux/arm/le/ld.abilist
|
||||
index 7987bbae..f1da2c63 100644
|
||||
--- a/sysdeps/unix/sysv/linux/arm/le/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/arm/le/ld.abilist
|
||||
@@ -1,4 +1,7 @@
|
||||
GLIBC_2.34 __rtld_version_placeholder 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 __libc_stack_end D 0x4
|
||||
GLIBC_2.4 __stack_chk_guard D 0x4
|
||||
GLIBC_2.4 __tls_get_addr F
|
||||
diff --git a/sysdeps/unix/sysv/linux/csky/ld.abilist b/sysdeps/unix/sysv/linux/csky/ld.abilist
|
||||
index 4939b206..7f482276 100644
|
||||
--- a/sysdeps/unix/sysv/linux/csky/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/csky/ld.abilist
|
||||
@@ -4,3 +4,6 @@ GLIBC_2.29 __tls_get_addr F
|
||||
GLIBC_2.29 _dl_mcount F
|
||||
GLIBC_2.29 _r_debug D 0x14
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/hppa/ld.abilist b/sysdeps/unix/sysv/linux/hppa/ld.abilist
|
||||
index 7cc9ebd7..7f5527fb 100644
|
||||
--- a/sysdeps/unix/sysv/linux/hppa/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/hppa/ld.abilist
|
||||
@@ -3,4 +3,7 @@ GLIBC_2.2 _dl_mcount F
|
||||
GLIBC_2.2 _r_debug D 0x14
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
GLIBC_2.4 __stack_chk_guard D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/i386/ld.abilist b/sysdeps/unix/sysv/linux/i386/ld.abilist
|
||||
index e8d187b1..9c4a45d8 100644
|
||||
--- a/sysdeps/unix/sysv/linux/i386/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/i386/ld.abilist
|
||||
@@ -4,3 +4,6 @@ GLIBC_2.1 _dl_mcount F
|
||||
GLIBC_2.3 ___tls_get_addr F
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/ia64/ld.abilist b/sysdeps/unix/sysv/linux/ia64/ld.abilist
|
||||
index be512265..8ccb5be9 100644
|
||||
--- a/sysdeps/unix/sysv/linux/ia64/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/ia64/ld.abilist
|
||||
@@ -3,3 +3,6 @@ GLIBC_2.2 _dl_mcount F
|
||||
GLIBC_2.2 _r_debug D 0x28
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist
|
||||
index 7987bbae..f1da2c63 100644
|
||||
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist
|
||||
@@ -1,4 +1,7 @@
|
||||
GLIBC_2.34 __rtld_version_placeholder 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 __libc_stack_end D 0x4
|
||||
GLIBC_2.4 __stack_chk_guard D 0x4
|
||||
GLIBC_2.4 __tls_get_addr F
|
||||
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist
|
||||
index 4f2854ed..dadbf852 100644
|
||||
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist
|
||||
@@ -3,4 +3,7 @@ GLIBC_2.1 __libc_stack_end D 0x4
|
||||
GLIBC_2.1 _dl_mcount F
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
GLIBC_2.4 __stack_chk_guard D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/microblaze/ld.abilist b/sysdeps/unix/sysv/linux/microblaze/ld.abilist
|
||||
index 9f0fdeca..89a0b7e4 100644
|
||||
--- a/sysdeps/unix/sysv/linux/microblaze/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/microblaze/ld.abilist
|
||||
@@ -4,3 +4,6 @@ GLIBC_2.18 __tls_get_addr F
|
||||
GLIBC_2.18 _dl_mcount F
|
||||
GLIBC_2.18 _r_debug D 0x14
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/ld.abilist b/sysdeps/unix/sysv/linux/mips/mips32/ld.abilist
|
||||
index f750067d..e304d1bb 100644
|
||||
--- a/sysdeps/unix/sysv/linux/mips/mips32/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/mips/mips32/ld.abilist
|
||||
@@ -3,4 +3,7 @@ GLIBC_2.2 __libc_stack_end D 0x4
|
||||
GLIBC_2.2 _dl_mcount F
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
GLIBC_2.4 __stack_chk_guard D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist
|
||||
index f750067d..e304d1bb 100644
|
||||
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist
|
||||
@@ -3,4 +3,7 @@ GLIBC_2.2 __libc_stack_end D 0x4
|
||||
GLIBC_2.2 _dl_mcount F
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
GLIBC_2.4 __stack_chk_guard D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist
|
||||
index 2fba6a9b..37a47ebc 100644
|
||||
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist
|
||||
@@ -3,4 +3,7 @@ GLIBC_2.2 __libc_stack_end D 0x8
|
||||
GLIBC_2.2 _dl_mcount F
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
GLIBC_2.4 __stack_chk_guard D 0x8
|
||||
diff --git a/sysdeps/unix/sysv/linux/nios2/ld.abilist b/sysdeps/unix/sysv/linux/nios2/ld.abilist
|
||||
index 57dfad5a..811ae9da 100644
|
||||
--- a/sysdeps/unix/sysv/linux/nios2/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/nios2/ld.abilist
|
||||
@@ -4,3 +4,6 @@ GLIBC_2.21 __tls_get_addr F
|
||||
GLIBC_2.21 _dl_mcount F
|
||||
GLIBC_2.21 _r_debug D 0x14
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist
|
||||
index e8966073..5a68aeb9 100644
|
||||
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist
|
||||
@@ -5,3 +5,6 @@ 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.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist
|
||||
index ce0bc639..da24dc7f 100644
|
||||
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist
|
||||
@@ -5,3 +5,6 @@ GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.3 _dl_mcount F
|
||||
GLIBC_2.3 _r_debug D 0x28
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist
|
||||
index 65b22674..b9ae89ae 100644
|
||||
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist
|
||||
@@ -5,3 +5,6 @@ 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.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist
|
||||
index 5ad4c81d..06836887 100644
|
||||
--- a/sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist
|
||||
@@ -4,3 +4,6 @@ GLIBC_2.33 __tls_get_addr F
|
||||
GLIBC_2.33 _dl_mcount F
|
||||
GLIBC_2.33 _r_debug D 0x14
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist
|
||||
index 479efdea..48431c91 100644
|
||||
--- a/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist
|
||||
@@ -4,3 +4,6 @@ GLIBC_2.27 __tls_get_addr F
|
||||
GLIBC_2.27 _dl_mcount F
|
||||
GLIBC_2.27 _r_debug D 0x28
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/rseq-internal.h b/sysdeps/unix/sysv/linux/rseq-internal.h
|
||||
index 15bc7ffd..9e8f99fd 100644
|
||||
--- a/sysdeps/unix/sysv/linux/rseq-internal.h
|
||||
+++ b/sysdeps/unix/sysv/linux/rseq-internal.h
|
||||
@@ -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 */
|
||||
|
||||
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist
|
||||
index d5ecb636..c1528839 100644
|
||||
--- a/sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist
|
||||
@@ -3,3 +3,6 @@ GLIBC_2.1 __libc_stack_end D 0x4
|
||||
GLIBC_2.1 _dl_mcount F
|
||||
GLIBC_2.3 __tls_get_offset F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist
|
||||
index 62a5e1d9..117d1430 100644
|
||||
--- a/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist
|
||||
@@ -3,3 +3,6 @@ GLIBC_2.2 _dl_mcount F
|
||||
GLIBC_2.2 _r_debug D 0x28
|
||||
GLIBC_2.3 __tls_get_offset F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/sh/be/ld.abilist b/sysdeps/unix/sysv/linux/sh/be/ld.abilist
|
||||
index 7cc9ebd7..7f5527fb 100644
|
||||
--- a/sysdeps/unix/sysv/linux/sh/be/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/sh/be/ld.abilist
|
||||
@@ -3,4 +3,7 @@ GLIBC_2.2 _dl_mcount F
|
||||
GLIBC_2.2 _r_debug D 0x14
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
GLIBC_2.4 __stack_chk_guard D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/sh/le/ld.abilist b/sysdeps/unix/sysv/linux/sh/le/ld.abilist
|
||||
index 7cc9ebd7..7f5527fb 100644
|
||||
--- a/sysdeps/unix/sysv/linux/sh/le/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/sh/le/ld.abilist
|
||||
@@ -3,4 +3,7 @@ GLIBC_2.2 _dl_mcount F
|
||||
GLIBC_2.2 _r_debug D 0x14
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
GLIBC_2.4 __stack_chk_guard D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist
|
||||
index 2e605434..3aac73f3 100644
|
||||
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist
|
||||
@@ -3,3 +3,6 @@ GLIBC_2.1 __libc_stack_end D 0x4
|
||||
GLIBC_2.1 _dl_mcount F
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist
|
||||
index be512265..8ccb5be9 100644
|
||||
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist
|
||||
@@ -3,3 +3,6 @@ GLIBC_2.2 _dl_mcount F
|
||||
GLIBC_2.2 _r_debug D 0x28
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/sys/rseq.h b/sysdeps/unix/sysv/linux/sys/rseq.h
|
||||
index c8edff50..1215b5d0 100644
|
||||
--- a/sysdeps/unix/sysv/linux/sys/rseq.h
|
||||
+++ b/sysdeps/unix/sysv/linux/sys/rseq.h
|
||||
@@ -171,4 +171,14 @@ struct rseq
|
||||
|
||||
#endif /* __GLIBC_HAVE_KERNEL_RSEQ */
|
||||
|
||||
+/* Offset from the thread pointer to the rseq area. */
|
||||
+extern const int __rseq_offset;
|
||||
+
|
||||
+/* Size of the registered rseq area. 0 if the registration was
|
||||
+ unsuccessful. */
|
||||
+extern const unsigned int __rseq_size;
|
||||
+
|
||||
+/* Flags used during rseq registration. */
|
||||
+extern const unsigned int __rseq_flags;
|
||||
+
|
||||
#endif /* sys/rseq.h */
|
||||
diff --git a/sysdeps/unix/sysv/linux/tst-rseq-disable.c b/sysdeps/unix/sysv/linux/tst-rseq-disable.c
|
||||
index 000e3518..6d73f77e 100644
|
||||
--- a/sysdeps/unix/sysv/linux/tst-rseq-disable.c
|
||||
+++ b/sysdeps/unix/sysv/linux/tst-rseq-disable.c
|
||||
@@ -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),
|
||||
diff --git a/sysdeps/unix/sysv/linux/tst-rseq.c b/sysdeps/unix/sysv/linux/tst-rseq.c
|
||||
index 926376b6..572c1116 100644
|
||||
--- a/sysdeps/unix/sysv/linux/tst-rseq.c
|
||||
+++ b/sysdeps/unix/sysv/linux/tst-rseq.c
|
||||
@@ -29,12 +29,20 @@
|
||||
# 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
|
||||
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist b/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist
|
||||
index afddaec5..ae622bdf 100644
|
||||
--- a/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist
|
||||
@@ -3,3 +3,6 @@ GLIBC_2.2.5 _dl_mcount F
|
||||
GLIBC_2.2.5 _r_debug D 0x28
|
||||
GLIBC_2.3 __tls_get_addr F
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist
|
||||
index defc488d..e17496d1 100644
|
||||
--- a/sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist
|
||||
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist
|
||||
@@ -3,3 +3,6 @@ GLIBC_2.16 __tls_get_addr F
|
||||
GLIBC_2.16 _dl_mcount F
|
||||
GLIBC_2.16 _r_debug D 0x14
|
||||
GLIBC_2.34 __rtld_version_placeholder F
|
||||
+GLIBC_2.35 __rseq_flags D 0x4
|
||||
+GLIBC_2.35 __rseq_offset D 0x4
|
||||
+GLIBC_2.35 __rseq_size D 0x4
|
||||
--
|
||||
2.23.0
|
||||
|
||||
1165
rseq-nptl-Add-rseq-registration.patch
Normal file
1165
rseq-nptl-Add-rseq-registration.patch
Normal file
File diff suppressed because it is too large
Load Diff
141
rseq-nptl-Add-thread_pointer.h-for-defining-__thread_poin.patch
Normal file
141
rseq-nptl-Add-thread_pointer.h-for-defining-__thread_poin.patch
Normal file
@ -0,0 +1,141 @@
|
||||
From c773e8d7fb0c7a97290bd889ba984411a1952e9e Mon Sep 17 00:00:00 2001
|
||||
From: Florian Weimer <fweimer@redhat.com>
|
||||
Date: Thu, 9 Dec 2021 09:49:32 +0100
|
||||
Subject: [PATCH 1/9] nptl: Add <thread_pointer.h> for defining
|
||||
__thread_pointer
|
||||
|
||||
<tls.h> already contains a definition that is quite similar,
|
||||
but it is not consistent across architectures.
|
||||
|
||||
Only architectures for which rseq support is added are covered.
|
||||
|
||||
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
---
|
||||
sysdeps/nptl/thread_pointer.h | 28 ++++++++++++++++++++
|
||||
sysdeps/powerpc/nptl/thread_pointer.h | 33 +++++++++++++++++++++++
|
||||
sysdeps/x86/nptl/thread_pointer.h | 38 +++++++++++++++++++++++++++
|
||||
3 files changed, 99 insertions(+)
|
||||
create mode 100644 sysdeps/nptl/thread_pointer.h
|
||||
create mode 100644 sysdeps/powerpc/nptl/thread_pointer.h
|
||||
create mode 100644 sysdeps/x86/nptl/thread_pointer.h
|
||||
|
||||
diff --git a/sysdeps/nptl/thread_pointer.h b/sysdeps/nptl/thread_pointer.h
|
||||
new file mode 100644
|
||||
index 00000000..92f2f309
|
||||
--- /dev/null
|
||||
+++ b/sysdeps/nptl/thread_pointer.h
|
||||
@@ -0,0 +1,28 @@
|
||||
+/* __thread_pointer definition. Generic version.
|
||||
+ Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
+ This file is part of the GNU C Library.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library. If not, see
|
||||
+ <https://www.gnu.org/licenses/>. */
|
||||
+
|
||||
+#ifndef _SYS_THREAD_POINTER_H
|
||||
+#define _SYS_THREAD_POINTER_H
|
||||
+
|
||||
+static inline void *
|
||||
+__thread_pointer (void)
|
||||
+{
|
||||
+ return __builtin_thread_pointer ();
|
||||
+}
|
||||
+
|
||||
+#endif /* _SYS_THREAD_POINTER_H */
|
||||
diff --git a/sysdeps/powerpc/nptl/thread_pointer.h b/sysdeps/powerpc/nptl/thread_pointer.h
|
||||
new file mode 100644
|
||||
index 00000000..8fd5ba67
|
||||
--- /dev/null
|
||||
+++ b/sysdeps/powerpc/nptl/thread_pointer.h
|
||||
@@ -0,0 +1,33 @@
|
||||
+/* __thread_pointer definition. powerpc version.
|
||||
+ Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
+ This file is part of the GNU C Library.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library. If not, see
|
||||
+ <https://www.gnu.org/licenses/>. */
|
||||
+
|
||||
+#ifndef _SYS_THREAD_POINTER_H
|
||||
+#define _SYS_THREAD_POINTER_H
|
||||
+
|
||||
+static inline void *
|
||||
+__thread_pointer (void)
|
||||
+{
|
||||
+#ifdef __powerpc64__
|
||||
+ register void *__result asm ("r13");
|
||||
+#else
|
||||
+ register void *__result asm ("r2");
|
||||
+#endif
|
||||
+ return __result;
|
||||
+}
|
||||
+
|
||||
+#endif /* _SYS_THREAD_POINTER_H */
|
||||
diff --git a/sysdeps/x86/nptl/thread_pointer.h b/sysdeps/x86/nptl/thread_pointer.h
|
||||
new file mode 100644
|
||||
index 00000000..6b71b6f7
|
||||
--- /dev/null
|
||||
+++ b/sysdeps/x86/nptl/thread_pointer.h
|
||||
@@ -0,0 +1,38 @@
|
||||
+/* __thread_pointer definition. x86 version.
|
||||
+ Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
+ This file is part of the GNU C Library.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library. If not, see
|
||||
+ <https://www.gnu.org/licenses/>. */
|
||||
+
|
||||
+#ifndef _SYS_THREAD_POINTER_H
|
||||
+#define _SYS_THREAD_POINTER_H
|
||||
+
|
||||
+static inline void *
|
||||
+__thread_pointer (void)
|
||||
+{
|
||||
+#if __GNUC_PREREQ (11, 1)
|
||||
+ return __builtin_thread_pointer ();
|
||||
+#else
|
||||
+ void *__result;
|
||||
+# ifdef __x86_64__
|
||||
+ __asm__ ("mov %%fs:0, %0" : "=r" (__result));
|
||||
+# else
|
||||
+ __asm__ ("mov %%gs:0, %0" : "=r" (__result));
|
||||
+# endif
|
||||
+ return __result;
|
||||
+#endif /* !GCC 11 */
|
||||
+}
|
||||
+
|
||||
+#endif /* _SYS_THREAD_POINTER_H */
|
||||
--
|
||||
2.23.0
|
||||
|
||||
56
rseq-nptl-Introduce-THREAD_GETMEM_VOLATILE.patch
Normal file
56
rseq-nptl-Introduce-THREAD_GETMEM_VOLATILE.patch
Normal file
@ -0,0 +1,56 @@
|
||||
From 6a8628eca8c8b22ccfd1422f2eb27bb665cfd660 Mon Sep 17 00:00:00 2001
|
||||
From: Florian Weimer <fweimer@redhat.com>
|
||||
Date: Thu, 9 Dec 2021 09:49:32 +0100
|
||||
Subject: [PATCH 3/9] nptl: Introduce THREAD_GETMEM_VOLATILE
|
||||
|
||||
This will be needed for rseq TCB access.
|
||||
|
||||
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
---
|
||||
sysdeps/i386/nptl/tcb-access.h | 2 ++
|
||||
sysdeps/nptl/tcb-access.h | 2 ++
|
||||
sysdeps/x86_64/nptl/tcb-access.h | 2 ++
|
||||
3 files changed, 6 insertions(+)
|
||||
|
||||
diff --git a/sysdeps/i386/nptl/tcb-access.h b/sysdeps/i386/nptl/tcb-access.h
|
||||
index 6c6d561e..5ddd8322 100644
|
||||
--- a/sysdeps/i386/nptl/tcb-access.h
|
||||
+++ b/sysdeps/i386/nptl/tcb-access.h
|
||||
@@ -41,6 +41,8 @@
|
||||
} \
|
||||
__value; })
|
||||
|
||||
+/* THREAD_GETMEM already forces a read. */
|
||||
+#define THREAD_GETMEM_VOLATILE(descr, member) THREAD_GETMEM (descr, member)
|
||||
|
||||
/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
|
||||
#define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
diff --git a/sysdeps/nptl/tcb-access.h b/sysdeps/nptl/tcb-access.h
|
||||
index b4137b8a..bbe20b72 100644
|
||||
--- a/sysdeps/nptl/tcb-access.h
|
||||
+++ b/sysdeps/nptl/tcb-access.h
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#define THREAD_GETMEM(descr, member) \
|
||||
descr->member
|
||||
+#define THREAD_GETMEM_VOLATILE(descr, member) \
|
||||
+ (*(volatile __typeof (descr->member) *)&descr->member)
|
||||
#define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
descr->member[idx]
|
||||
#define THREAD_SETMEM(descr, member, value) \
|
||||
diff --git a/sysdeps/x86_64/nptl/tcb-access.h b/sysdeps/x86_64/nptl/tcb-access.h
|
||||
index 18848a72..e4d2d07a 100644
|
||||
--- a/sysdeps/x86_64/nptl/tcb-access.h
|
||||
+++ b/sysdeps/x86_64/nptl/tcb-access.h
|
||||
@@ -39,6 +39,8 @@
|
||||
} \
|
||||
__value; })
|
||||
|
||||
+/* THREAD_GETMEM already forces a read. */
|
||||
+#define THREAD_GETMEM_VOLATILE(descr, member) THREAD_GETMEM (descr, member)
|
||||
|
||||
/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
|
||||
# define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
--
|
||||
2.23.0
|
||||
|
||||
935
rseq-nptl-Introduce-tcb-access.h-for-THREAD_-accessors.patch
Normal file
935
rseq-nptl-Introduce-tcb-access.h-for-THREAD_-accessors.patch
Normal file
@ -0,0 +1,935 @@
|
||||
From da3869963c4039b583d011e5612c2546efe90ed3 Mon Sep 17 00:00:00 2001
|
||||
From: qinyu <qinyu16@huawei.com>
|
||||
Date: Fri, 25 Feb 2022 10:55:45 +0800
|
||||
Subject: [PATCH 2/9] nptl: Introduce <tcb-access.h> for THREAD_* accessors
|
||||
|
||||
These are common between most architectures. Only the x86 targets
|
||||
are outliers.
|
||||
|
||||
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
------
|
||||
conflicts:
|
||||
context conflicts
|
||||
---
|
||||
sysdeps/aarch64/nptl/tls.h | 10 +--
|
||||
sysdeps/alpha/nptl/tls.h | 10 +--
|
||||
sysdeps/arc/nptl/tls.h | 10 +--
|
||||
sysdeps/arm/nptl/tls.h | 10 +--
|
||||
sysdeps/csky/nptl/tls.h | 10 +--
|
||||
sysdeps/hppa/nptl/tls.h | 10 +--
|
||||
sysdeps/i386/nptl/tcb-access.h | 123 +++++++++++++++++++++++++++++
|
||||
sysdeps/i386/nptl/tls.h | 108 +------------------------
|
||||
sysdeps/ia64/nptl/tls.h | 10 +--
|
||||
sysdeps/m68k/nptl/tls.h | 10 +--
|
||||
sysdeps/microblaze/nptl/tls.h | 15 +---
|
||||
sysdeps/mips/nptl/tls.h | 9 +--
|
||||
sysdeps/nios2/nptl/tls.h | 10 +--
|
||||
sysdeps/nptl/tcb-access.h | 30 +++++++
|
||||
sysdeps/powerpc/nptl/tls.h | 15 +---
|
||||
sysdeps/riscv/nptl/tls.h | 9 +--
|
||||
sysdeps/s390/nptl/tls.h | 10 +--
|
||||
sysdeps/sh/nptl/tls.h | 14 +---
|
||||
sysdeps/sparc/nptl/tls.h | 10 +--
|
||||
sysdeps/x86_64/nptl/tcb-access.h | 130 +++++++++++++++++++++++++++++++
|
||||
sysdeps/x86_64/nptl/tls.h | 114 +--------------------------
|
||||
21 files changed, 301 insertions(+), 376 deletions(-)
|
||||
create mode 100644 sysdeps/i386/nptl/tcb-access.h
|
||||
create mode 100644 sysdeps/nptl/tcb-access.h
|
||||
create mode 100644 sysdeps/x86_64/nptl/tcb-access.h
|
||||
|
||||
diff --git a/sysdeps/aarch64/nptl/tls.h b/sysdeps/aarch64/nptl/tls.h
|
||||
index 6e896207..cd9abb5d 100644
|
||||
--- a/sysdeps/aarch64/nptl/tls.h
|
||||
+++ b/sysdeps/aarch64/nptl/tls.h
|
||||
@@ -98,15 +98,7 @@ typedef struct
|
||||
# define DB_THREAD_SELF \
|
||||
CONST_THREAD_AREA (64, sizeof (struct pthread))
|
||||
|
||||
-/* Access to data in the thread descriptor is easy. */
|
||||
-# define THREAD_GETMEM(descr, member) \
|
||||
- descr->member
|
||||
-# define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
- descr->member[idx]
|
||||
-# define THREAD_SETMEM(descr, member, value) \
|
||||
- descr->member = (value)
|
||||
-# define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- descr->member[idx] = (value)
|
||||
+# include <tcb-access.h>
|
||||
|
||||
/* Get and set the global scope generation counter in struct pthread. */
|
||||
# define THREAD_GSCOPE_IN_TCB 1
|
||||
diff --git a/sysdeps/alpha/nptl/tls.h b/sysdeps/alpha/nptl/tls.h
|
||||
index 4dbccc52..5f4843b2 100644
|
||||
--- a/sysdeps/alpha/nptl/tls.h
|
||||
+++ b/sysdeps/alpha/nptl/tls.h
|
||||
@@ -92,15 +92,7 @@ typedef struct
|
||||
# define DB_THREAD_SELF \
|
||||
REGISTER (64, 64, 32 * 8, -sizeof (struct pthread))
|
||||
|
||||
-/* Access to data in the thread descriptor is easy. */
|
||||
-#define THREAD_GETMEM(descr, member) \
|
||||
- descr->member
|
||||
-#define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
- descr->member[idx]
|
||||
-#define THREAD_SETMEM(descr, member, value) \
|
||||
- descr->member = (value)
|
||||
-#define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- descr->member[idx] = (value)
|
||||
+# include <tcb-access.h>
|
||||
|
||||
/* Get and set the global scope generation counter in struct pthread. */
|
||||
#define THREAD_GSCOPE_IN_TCB 1
|
||||
diff --git a/sysdeps/arc/nptl/tls.h b/sysdeps/arc/nptl/tls.h
|
||||
index 95300fdd..d9ada2f3 100644
|
||||
--- a/sysdeps/arc/nptl/tls.h
|
||||
+++ b/sysdeps/arc/nptl/tls.h
|
||||
@@ -100,15 +100,7 @@ typedef struct
|
||||
# define DB_THREAD_SELF \
|
||||
CONST_THREAD_AREA (32, sizeof (struct pthread))
|
||||
|
||||
-/* Access to data in the thread descriptor is easy. */
|
||||
-# define THREAD_GETMEM(descr, member) \
|
||||
- descr->member
|
||||
-# define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
- descr->member[idx]
|
||||
-# define THREAD_SETMEM(descr, member, value) \
|
||||
- descr->member = (value)
|
||||
-# define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- descr->member[idx] = (value)
|
||||
+# include <tcb-access.h>
|
||||
|
||||
/* Get and set the global scope generation counter in struct pthread. */
|
||||
#define THREAD_GSCOPE_IN_TCB 1
|
||||
diff --git a/sysdeps/arm/nptl/tls.h b/sysdeps/arm/nptl/tls.h
|
||||
index 1bd11307..354aae33 100644
|
||||
--- a/sysdeps/arm/nptl/tls.h
|
||||
+++ b/sysdeps/arm/nptl/tls.h
|
||||
@@ -89,15 +89,7 @@ typedef struct
|
||||
# define DB_THREAD_SELF \
|
||||
CONST_THREAD_AREA (32, sizeof (struct pthread))
|
||||
|
||||
-/* Access to data in the thread descriptor is easy. */
|
||||
-#define THREAD_GETMEM(descr, member) \
|
||||
- descr->member
|
||||
-#define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
- descr->member[idx]
|
||||
-#define THREAD_SETMEM(descr, member, value) \
|
||||
- descr->member = (value)
|
||||
-#define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- descr->member[idx] = (value)
|
||||
+# include <tcb-access.h>
|
||||
|
||||
/* Get and set the global scope generation counter in struct pthread. */
|
||||
#define THREAD_GSCOPE_IN_TCB 1
|
||||
diff --git a/sysdeps/csky/nptl/tls.h b/sysdeps/csky/nptl/tls.h
|
||||
index 7a234041..f3fa3fcb 100644
|
||||
--- a/sysdeps/csky/nptl/tls.h
|
||||
+++ b/sysdeps/csky/nptl/tls.h
|
||||
@@ -116,15 +116,7 @@ typedef struct
|
||||
# define DB_THREAD_SELF \
|
||||
CONST_THREAD_AREA (32, sizeof (struct pthread))
|
||||
|
||||
-/* Access to data in the thread descriptor is easy. */
|
||||
-# define THREAD_GETMEM(descr, member) \
|
||||
- descr->member
|
||||
-# define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
- descr->member[idx]
|
||||
-# define THREAD_SETMEM(descr, member, value) \
|
||||
- descr->member = (value)
|
||||
-# define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- descr->member[idx] = (value)
|
||||
+# include <tcb-access.h>
|
||||
|
||||
/* Get and set the global scope generation counter in struct pthread. */
|
||||
# define THREAD_GSCOPE_IN_TCB 1
|
||||
diff --git a/sysdeps/hppa/nptl/tls.h b/sysdeps/hppa/nptl/tls.h
|
||||
index 857003a7..f0e274c4 100644
|
||||
--- a/sysdeps/hppa/nptl/tls.h
|
||||
+++ b/sysdeps/hppa/nptl/tls.h
|
||||
@@ -107,15 +107,7 @@ typedef struct
|
||||
# define DB_THREAD_SELF \
|
||||
REGISTER (32, 32, 53 * 4, -sizeof (struct pthread))
|
||||
|
||||
-/* Access to data in the thread descriptor is easy. */
|
||||
-# define THREAD_GETMEM(descr, member) \
|
||||
- descr->member
|
||||
-# define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
- descr->member[idx]
|
||||
-# define THREAD_SETMEM(descr, member, value) \
|
||||
- descr->member = (value)
|
||||
-# define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- descr->member[idx] = (value)
|
||||
+# include <tcb-access.h>
|
||||
|
||||
static inline struct pthread *__get_cr27(void)
|
||||
{
|
||||
diff --git a/sysdeps/i386/nptl/tcb-access.h b/sysdeps/i386/nptl/tcb-access.h
|
||||
new file mode 100644
|
||||
index 00000000..6c6d561e
|
||||
--- /dev/null
|
||||
+++ b/sysdeps/i386/nptl/tcb-access.h
|
||||
@@ -0,0 +1,123 @@
|
||||
+/* THREAD_* accessors. i386 version.
|
||||
+ Copyright (C) 2002-2021 Free Software Foundation, Inc.
|
||||
+ This file is part of the GNU C Library.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library; if not, see
|
||||
+ <https://www.gnu.org/licenses/>. */
|
||||
+
|
||||
+/* Read member of the thread descriptor directly. */
|
||||
+#define THREAD_GETMEM(descr, member) \
|
||||
+ ({ __typeof (descr->member) __value; \
|
||||
+ _Static_assert (sizeof (__value) == 1 \
|
||||
+ || sizeof (__value) == 4 \
|
||||
+ || sizeof (__value) == 8, \
|
||||
+ "size of per-thread data"); \
|
||||
+ if (sizeof (__value) == 1) \
|
||||
+ asm volatile ("movb %%gs:%P2,%b0" \
|
||||
+ : "=q" (__value) \
|
||||
+ : "0" (0), "i" (offsetof (struct pthread, member))); \
|
||||
+ else if (sizeof (__value) == 4) \
|
||||
+ asm volatile ("movl %%gs:%P1,%0" \
|
||||
+ : "=r" (__value) \
|
||||
+ : "i" (offsetof (struct pthread, member))); \
|
||||
+ else /* 8 */ \
|
||||
+ { \
|
||||
+ asm volatile ("movl %%gs:%P1,%%eax\n\t" \
|
||||
+ "movl %%gs:%P2,%%edx" \
|
||||
+ : "=A" (__value) \
|
||||
+ : "i" (offsetof (struct pthread, member)), \
|
||||
+ "i" (offsetof (struct pthread, member) + 4)); \
|
||||
+ } \
|
||||
+ __value; })
|
||||
+
|
||||
+
|
||||
+/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
|
||||
+#define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
+ ({ __typeof (descr->member[0]) __value; \
|
||||
+ _Static_assert (sizeof (__value) == 1 \
|
||||
+ || sizeof (__value) == 4 \
|
||||
+ || sizeof (__value) == 8, \
|
||||
+ "size of per-thread data"); \
|
||||
+ if (sizeof (__value) == 1) \
|
||||
+ asm volatile ("movb %%gs:%P2(%3),%b0" \
|
||||
+ : "=q" (__value) \
|
||||
+ : "0" (0), "i" (offsetof (struct pthread, member[0])), \
|
||||
+ "r" (idx)); \
|
||||
+ else if (sizeof (__value) == 4) \
|
||||
+ asm volatile ("movl %%gs:%P1(,%2,4),%0" \
|
||||
+ : "=r" (__value) \
|
||||
+ : "i" (offsetof (struct pthread, member[0])), \
|
||||
+ "r" (idx)); \
|
||||
+ else /* 8 */ \
|
||||
+ { \
|
||||
+ asm volatile ("movl %%gs:%P1(,%2,8),%%eax\n\t" \
|
||||
+ "movl %%gs:4+%P1(,%2,8),%%edx" \
|
||||
+ : "=&A" (__value) \
|
||||
+ : "i" (offsetof (struct pthread, member[0])), \
|
||||
+ "r" (idx)); \
|
||||
+ } \
|
||||
+ __value; })
|
||||
+
|
||||
+
|
||||
+
|
||||
+/* Set member of the thread descriptor directly. */
|
||||
+#define THREAD_SETMEM(descr, member, value) \
|
||||
+ ({ \
|
||||
+ _Static_assert (sizeof (descr->member) == 1 \
|
||||
+ || sizeof (descr->member) == 4 \
|
||||
+ || sizeof (descr->member) == 8, \
|
||||
+ "size of per-thread data"); \
|
||||
+ if (sizeof (descr->member) == 1) \
|
||||
+ asm volatile ("movb %b0,%%gs:%P1" : \
|
||||
+ : "iq" (value), \
|
||||
+ "i" (offsetof (struct pthread, member))); \
|
||||
+ else if (sizeof (descr->member) == 4) \
|
||||
+ asm volatile ("movl %0,%%gs:%P1" : \
|
||||
+ : "ir" (value), \
|
||||
+ "i" (offsetof (struct pthread, member))); \
|
||||
+ else /* 8 */ \
|
||||
+ { \
|
||||
+ asm volatile ("movl %%eax,%%gs:%P1\n\t" \
|
||||
+ "movl %%edx,%%gs:%P2" : \
|
||||
+ : "A" ((uint64_t) cast_to_integer (value)), \
|
||||
+ "i" (offsetof (struct pthread, member)), \
|
||||
+ "i" (offsetof (struct pthread, member) + 4)); \
|
||||
+ }})
|
||||
+
|
||||
+
|
||||
+/* Same as THREAD_SETMEM, but the member offset can be non-constant. */
|
||||
+#define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
+ ({ \
|
||||
+ _Static_assert (sizeof (descr->member[0]) == 1 \
|
||||
+ || sizeof (descr->member[0]) == 4 \
|
||||
+ || sizeof (descr->member[0]) == 8, \
|
||||
+ "size of per-thread data"); \
|
||||
+ if (sizeof (descr->member[0]) == 1) \
|
||||
+ asm volatile ("movb %b0,%%gs:%P1(%2)" : \
|
||||
+ : "iq" (value), \
|
||||
+ "i" (offsetof (struct pthread, member)), \
|
||||
+ "r" (idx)); \
|
||||
+ else if (sizeof (descr->member[0]) == 4) \
|
||||
+ asm volatile ("movl %0,%%gs:%P1(,%2,4)" : \
|
||||
+ : "ir" (value), \
|
||||
+ "i" (offsetof (struct pthread, member)), \
|
||||
+ "r" (idx)); \
|
||||
+ else /* 8 */ \
|
||||
+ { \
|
||||
+ asm volatile ("movl %%eax,%%gs:%P1(,%2,8)\n\t" \
|
||||
+ "movl %%edx,%%gs:4+%P1(,%2,8)" : \
|
||||
+ : "A" ((uint64_t) cast_to_integer (value)), \
|
||||
+ "i" (offsetof (struct pthread, member)), \
|
||||
+ "r" (idx)); \
|
||||
+ }})
|
||||
diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h
|
||||
index 86ee1ef3..111c9ee5 100644
|
||||
--- a/sysdeps/i386/nptl/tls.h
|
||||
+++ b/sysdeps/i386/nptl/tls.h
|
||||
@@ -250,113 +250,7 @@ tls_fill_user_desc (union user_desc_init *desc,
|
||||
REGISTER_THREAD_AREA (32, offsetof (struct user_regs_struct, xgs), 3) \
|
||||
REGISTER_THREAD_AREA (64, 26 * 8, 3) /* x86-64's user_regs_struct->gs */
|
||||
|
||||
-
|
||||
-/* Read member of the thread descriptor directly. */
|
||||
-# define THREAD_GETMEM(descr, member) \
|
||||
- ({ __typeof (descr->member) __value; \
|
||||
- _Static_assert (sizeof (__value) == 1 \
|
||||
- || sizeof (__value) == 4 \
|
||||
- || sizeof (__value) == 8, \
|
||||
- "size of per-thread data"); \
|
||||
- if (sizeof (__value) == 1) \
|
||||
- asm volatile ("movb %%gs:%P2,%b0" \
|
||||
- : "=q" (__value) \
|
||||
- : "0" (0), "i" (offsetof (struct pthread, member))); \
|
||||
- else if (sizeof (__value) == 4) \
|
||||
- asm volatile ("movl %%gs:%P1,%0" \
|
||||
- : "=r" (__value) \
|
||||
- : "i" (offsetof (struct pthread, member))); \
|
||||
- else /* 8 */ \
|
||||
- { \
|
||||
- asm volatile ("movl %%gs:%P1,%%eax\n\t" \
|
||||
- "movl %%gs:%P2,%%edx" \
|
||||
- : "=A" (__value) \
|
||||
- : "i" (offsetof (struct pthread, member)), \
|
||||
- "i" (offsetof (struct pthread, member) + 4)); \
|
||||
- } \
|
||||
- __value; })
|
||||
-
|
||||
-
|
||||
-/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
|
||||
-# define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
- ({ __typeof (descr->member[0]) __value; \
|
||||
- _Static_assert (sizeof (__value) == 1 \
|
||||
- || sizeof (__value) == 4 \
|
||||
- || sizeof (__value) == 8, \
|
||||
- "size of per-thread data"); \
|
||||
- if (sizeof (__value) == 1) \
|
||||
- asm volatile ("movb %%gs:%P2(%3),%b0" \
|
||||
- : "=q" (__value) \
|
||||
- : "0" (0), "i" (offsetof (struct pthread, member[0])), \
|
||||
- "r" (idx)); \
|
||||
- else if (sizeof (__value) == 4) \
|
||||
- asm volatile ("movl %%gs:%P1(,%2,4),%0" \
|
||||
- : "=r" (__value) \
|
||||
- : "i" (offsetof (struct pthread, member[0])), \
|
||||
- "r" (idx)); \
|
||||
- else /* 8 */ \
|
||||
- { \
|
||||
- asm volatile ("movl %%gs:%P1(,%2,8),%%eax\n\t" \
|
||||
- "movl %%gs:4+%P1(,%2,8),%%edx" \
|
||||
- : "=&A" (__value) \
|
||||
- : "i" (offsetof (struct pthread, member[0])), \
|
||||
- "r" (idx)); \
|
||||
- } \
|
||||
- __value; })
|
||||
-
|
||||
-
|
||||
-
|
||||
-/* Set member of the thread descriptor directly. */
|
||||
-# define THREAD_SETMEM(descr, member, value) \
|
||||
- ({ \
|
||||
- _Static_assert (sizeof (descr->member) == 1 \
|
||||
- || sizeof (descr->member) == 4 \
|
||||
- || sizeof (descr->member) == 8, \
|
||||
- "size of per-thread data"); \
|
||||
- if (sizeof (descr->member) == 1) \
|
||||
- asm volatile ("movb %b0,%%gs:%P1" : \
|
||||
- : "iq" (value), \
|
||||
- "i" (offsetof (struct pthread, member))); \
|
||||
- else if (sizeof (descr->member) == 4) \
|
||||
- asm volatile ("movl %0,%%gs:%P1" : \
|
||||
- : "ir" (value), \
|
||||
- "i" (offsetof (struct pthread, member))); \
|
||||
- else /* 8 */ \
|
||||
- { \
|
||||
- asm volatile ("movl %%eax,%%gs:%P1\n\t" \
|
||||
- "movl %%edx,%%gs:%P2" : \
|
||||
- : "A" ((uint64_t) cast_to_integer (value)), \
|
||||
- "i" (offsetof (struct pthread, member)), \
|
||||
- "i" (offsetof (struct pthread, member) + 4)); \
|
||||
- }})
|
||||
-
|
||||
-
|
||||
-/* Same as THREAD_SETMEM, but the member offset can be non-constant. */
|
||||
-# define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- ({ \
|
||||
- _Static_assert (sizeof (descr->member[0]) == 1 \
|
||||
- || sizeof (descr->member[0]) == 4 \
|
||||
- || sizeof (descr->member[0]) == 8, \
|
||||
- "size of per-thread data"); \
|
||||
- if (sizeof (descr->member[0]) == 1) \
|
||||
- asm volatile ("movb %b0,%%gs:%P1(%2)" : \
|
||||
- : "iq" (value), \
|
||||
- "i" (offsetof (struct pthread, member)), \
|
||||
- "r" (idx)); \
|
||||
- else if (sizeof (descr->member[0]) == 4) \
|
||||
- asm volatile ("movl %0,%%gs:%P1(,%2,4)" : \
|
||||
- : "ir" (value), \
|
||||
- "i" (offsetof (struct pthread, member)), \
|
||||
- "r" (idx)); \
|
||||
- else /* 8 */ \
|
||||
- { \
|
||||
- asm volatile ("movl %%eax,%%gs:%P1(,%2,8)\n\t" \
|
||||
- "movl %%edx,%%gs:4+%P1(,%2,8)" : \
|
||||
- : "A" ((uint64_t) cast_to_integer (value)), \
|
||||
- "i" (offsetof (struct pthread, member)), \
|
||||
- "r" (idx)); \
|
||||
- }})
|
||||
-
|
||||
+# include <tcb-access.h>
|
||||
|
||||
/* Set the stack guard field in TCB head. */
|
||||
#define THREAD_SET_STACK_GUARD(value) \
|
||||
diff --git a/sysdeps/ia64/nptl/tls.h b/sysdeps/ia64/nptl/tls.h
|
||||
index 66d9bf31..26fe555c 100644
|
||||
--- a/sysdeps/ia64/nptl/tls.h
|
||||
+++ b/sysdeps/ia64/nptl/tls.h
|
||||
@@ -128,15 +128,7 @@ register struct pthread *__thread_self __asm__("r13");
|
||||
/* Magic for libthread_db to know how to do THREAD_SELF. */
|
||||
# define DB_THREAD_SELF REGISTER (64, 64, 13 * 8, -TLS_PRE_TCB_SIZE)
|
||||
|
||||
-/* Access to data in the thread descriptor is easy. */
|
||||
-#define THREAD_GETMEM(descr, member) \
|
||||
- descr->member
|
||||
-#define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
- descr->member[idx]
|
||||
-#define THREAD_SETMEM(descr, member, value) \
|
||||
- descr->member = (value)
|
||||
-#define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- descr->member[idx] = (value)
|
||||
+# include <tcb-access.h>
|
||||
|
||||
/* Set the stack guard field in TCB head. */
|
||||
#define THREAD_SET_STACK_GUARD(value) \
|
||||
diff --git a/sysdeps/m68k/nptl/tls.h b/sysdeps/m68k/nptl/tls.h
|
||||
index cfcd6d2b..9f562c38 100644
|
||||
--- a/sysdeps/m68k/nptl/tls.h
|
||||
+++ b/sysdeps/m68k/nptl/tls.h
|
||||
@@ -118,15 +118,7 @@ extern void * __m68k_read_tp (void);
|
||||
# define DB_THREAD_SELF \
|
||||
CONST_THREAD_AREA (32, TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE)
|
||||
|
||||
-/* Access to data in the thread descriptor is easy. */
|
||||
-# define THREAD_GETMEM(descr, member) \
|
||||
- descr->member
|
||||
-# define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
- descr->member[idx]
|
||||
-# define THREAD_SETMEM(descr, member, value) \
|
||||
- descr->member = (value)
|
||||
-# define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- descr->member[idx] = (value)
|
||||
+# include <tcb-access.h>
|
||||
|
||||
/* l_tls_offset == 0 is perfectly valid on M68K, so we have to use some
|
||||
different value to mean unset l_tls_offset. */
|
||||
diff --git a/sysdeps/microblaze/nptl/tls.h b/sysdeps/microblaze/nptl/tls.h
|
||||
index c93d90b1..bfa6efa7 100644
|
||||
--- a/sysdeps/microblaze/nptl/tls.h
|
||||
+++ b/sysdeps/microblaze/nptl/tls.h
|
||||
@@ -100,20 +100,7 @@ typedef struct
|
||||
# define DB_THREAD_SELF \
|
||||
CONST_THREAD_AREA (32, sizeof (struct pthread))
|
||||
|
||||
-/* Read member of the thread descriptor directly. */
|
||||
-# define THREAD_GETMEM(descr, member) (descr->member)
|
||||
-
|
||||
-/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
|
||||
-# define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
- (descr->member[idx])
|
||||
-
|
||||
-/* Set member of the thread descriptor directly. */
|
||||
-# define THREAD_SETMEM(descr, member, value) \
|
||||
- (descr->member = (value))
|
||||
-
|
||||
-/* Same as THREAD_SETMEM, but the member offset can be non-constant. */
|
||||
-# define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- (descr->member[idx] = (value))
|
||||
+# include <tcb-access.h>
|
||||
|
||||
/* Get and set the global scope generation counter in struct pthread. */
|
||||
# define THREAD_GSCOPE_IN_TCB 1
|
||||
diff --git a/sysdeps/mips/nptl/tls.h b/sysdeps/mips/nptl/tls.h
|
||||
index c09f4907..ef99aa64 100644
|
||||
--- a/sysdeps/mips/nptl/tls.h
|
||||
+++ b/sysdeps/mips/nptl/tls.h
|
||||
@@ -144,14 +144,7 @@ typedef struct
|
||||
CONST_THREAD_AREA (32, TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE)
|
||||
|
||||
/* Access to data in the thread descriptor is easy. */
|
||||
-# define THREAD_GETMEM(descr, member) \
|
||||
- descr->member
|
||||
-# define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
- descr->member[idx]
|
||||
-# define THREAD_SETMEM(descr, member, value) \
|
||||
- descr->member = (value)
|
||||
-# define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- descr->member[idx] = (value)
|
||||
+# include <tcb-access.h>
|
||||
|
||||
/* l_tls_offset == 0 is perfectly valid on MIPS, so we have to use some
|
||||
different value to mean unset l_tls_offset. */
|
||||
diff --git a/sysdeps/nios2/nptl/tls.h b/sysdeps/nios2/nptl/tls.h
|
||||
index 02a05b4e..7110cfcc 100644
|
||||
--- a/sysdeps/nios2/nptl/tls.h
|
||||
+++ b/sysdeps/nios2/nptl/tls.h
|
||||
@@ -112,15 +112,7 @@ register struct pthread *__thread_self __asm__("r23");
|
||||
# define DB_THREAD_SELF \
|
||||
REGISTER (32, 32, 23 * 4, -TLS_PRE_TCB_SIZE - TLS_TCB_OFFSET)
|
||||
|
||||
-/* Access to data in the thread descriptor is easy. */
|
||||
-# define THREAD_GETMEM(descr, member) \
|
||||
- descr->member
|
||||
-# define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
- descr->member[idx]
|
||||
-# define THREAD_SETMEM(descr, member, value) \
|
||||
- descr->member = (value)
|
||||
-# define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- descr->member[idx] = (value)
|
||||
+# include <tcb-access.h>
|
||||
|
||||
# define THREAD_GET_POINTER_GUARD() \
|
||||
(((tcbhead_t *) (READ_THREAD_POINTER () \
|
||||
diff --git a/sysdeps/nptl/tcb-access.h b/sysdeps/nptl/tcb-access.h
|
||||
new file mode 100644
|
||||
index 00000000..b4137b8a
|
||||
--- /dev/null
|
||||
+++ b/sysdeps/nptl/tcb-access.h
|
||||
@@ -0,0 +1,30 @@
|
||||
+/* THREAD_* accessors. Generic version based on struct pthread pointers.
|
||||
+ Copyright (C) 2002-2021 Free Software Foundation, Inc.
|
||||
+ This file is part of the GNU C Library.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library; if not, see
|
||||
+ <https://www.gnu.org/licenses/>. */
|
||||
+
|
||||
+/* Note: These are for accessing the TCB of the *current* thread.
|
||||
+ descr can be disregarded on some targets as an optimization. See
|
||||
+ i386 for an example. */
|
||||
+
|
||||
+#define THREAD_GETMEM(descr, member) \
|
||||
+ descr->member
|
||||
+#define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
+ descr->member[idx]
|
||||
+#define THREAD_SETMEM(descr, member, value) \
|
||||
+ descr->member = (value)
|
||||
+#define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
+ descr->member[idx] = (value)
|
||||
diff --git a/sysdeps/powerpc/nptl/tls.h b/sysdeps/powerpc/nptl/tls.h
|
||||
index 6c779b66..110d085d 100644
|
||||
--- a/sysdeps/powerpc/nptl/tls.h
|
||||
+++ b/sysdeps/powerpc/nptl/tls.h
|
||||
@@ -176,20 +176,7 @@ typedef struct
|
||||
REGISTER (64, 64, PT_THREAD_POINTER * 8, \
|
||||
- TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
|
||||
|
||||
-/* Read member of the thread descriptor directly. */
|
||||
-# define THREAD_GETMEM(descr, member) ((void)(descr), (THREAD_SELF)->member)
|
||||
-
|
||||
-/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
|
||||
-# define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
- ((void)(descr), (THREAD_SELF)->member[idx])
|
||||
-
|
||||
-/* Set member of the thread descriptor directly. */
|
||||
-# define THREAD_SETMEM(descr, member, value) \
|
||||
- ((void)(descr), (THREAD_SELF)->member = (value))
|
||||
-
|
||||
-/* Same as THREAD_SETMEM, but the member offset can be non-constant. */
|
||||
-# define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- ((void)(descr), (THREAD_SELF)->member[idx] = (value))
|
||||
+# include <tcb-access.h>
|
||||
|
||||
/* Set the stack guard field in TCB head. */
|
||||
# define THREAD_SET_STACK_GUARD(value) \
|
||||
diff --git a/sysdeps/riscv/nptl/tls.h b/sysdeps/riscv/nptl/tls.h
|
||||
index 5350bcc0..bdc0a3a6 100644
|
||||
--- a/sysdeps/riscv/nptl/tls.h
|
||||
+++ b/sysdeps/riscv/nptl/tls.h
|
||||
@@ -105,14 +105,7 @@ typedef struct
|
||||
REGISTER (64, 64, 4 * 8, - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
|
||||
|
||||
/* Access to data in the thread descriptor is easy. */
|
||||
-# define THREAD_GETMEM(descr, member) \
|
||||
- descr->member
|
||||
-# define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
- descr->member[idx]
|
||||
-# define THREAD_SETMEM(descr, member, value) \
|
||||
- descr->member = (value)
|
||||
-# define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- descr->member[idx] = (value)
|
||||
+# include <tcb-access.h>
|
||||
|
||||
/* l_tls_offset == 0 is perfectly valid, so we have to use some different
|
||||
value to mean unset l_tls_offset. */
|
||||
diff --git a/sysdeps/s390/nptl/tls.h b/sysdeps/s390/nptl/tls.h
|
||||
index efb52515..2cdd18eb 100644
|
||||
--- a/sysdeps/s390/nptl/tls.h
|
||||
+++ b/sysdeps/s390/nptl/tls.h
|
||||
@@ -135,15 +135,7 @@ typedef struct
|
||||
# define DB_THREAD_SELF REGISTER (32, 32, 18 * 4, 0) \
|
||||
REGISTER (64, __WORDSIZE, 18 * 8, 0)
|
||||
|
||||
-/* Access to data in the thread descriptor is easy. */
|
||||
-#define THREAD_GETMEM(descr, member) \
|
||||
- descr->member
|
||||
-#define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
- descr->member[idx]
|
||||
-#define THREAD_SETMEM(descr, member, value) \
|
||||
- descr->member = (value)
|
||||
-#define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- descr->member[idx] = (value)
|
||||
+# include <tcb-access.h>
|
||||
|
||||
/* Set the stack guard field in TCB head. */
|
||||
#define THREAD_SET_STACK_GUARD(value) \
|
||||
diff --git a/sysdeps/sh/nptl/tls.h b/sysdeps/sh/nptl/tls.h
|
||||
index ac3c9a9e..39064002 100644
|
||||
--- a/sysdeps/sh/nptl/tls.h
|
||||
+++ b/sysdeps/sh/nptl/tls.h
|
||||
@@ -113,19 +113,7 @@ typedef struct
|
||||
# define DB_THREAD_SELF \
|
||||
REGISTER (32, 32, REG_GBR * 4, -sizeof (struct pthread))
|
||||
|
||||
-/* Read member of the thread descriptor directly. */
|
||||
-# define THREAD_GETMEM(descr, member) (descr->member)
|
||||
-
|
||||
-/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
|
||||
-# define THREAD_GETMEM_NC(descr, member, idx) (descr->member[idx])
|
||||
-
|
||||
-/* Set member of the thread descriptor directly. */
|
||||
-# define THREAD_SETMEM(descr, member, value) \
|
||||
- descr->member = (value)
|
||||
-
|
||||
-/* Same as THREAD_SETMEM, but the member offset can be non-constant. */
|
||||
-# define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- descr->member[idx] = (value)
|
||||
+# include <tcb-access.h>
|
||||
|
||||
#define THREAD_GET_POINTER_GUARD() \
|
||||
({ tcbhead_t *__tcbp; \
|
||||
diff --git a/sysdeps/sparc/nptl/tls.h b/sysdeps/sparc/nptl/tls.h
|
||||
index dd1eb82a..376d7299 100644
|
||||
--- a/sysdeps/sparc/nptl/tls.h
|
||||
+++ b/sysdeps/sparc/nptl/tls.h
|
||||
@@ -112,15 +112,7 @@ register struct pthread *__thread_self __asm__("%g7");
|
||||
REGISTER (32, 32, 10 * 4, 0) \
|
||||
REGISTER (64, __WORDSIZE, (6 * 8) + (__WORDSIZE==64?0:4), 0)
|
||||
|
||||
-/* Access to data in the thread descriptor is easy. */
|
||||
-#define THREAD_GETMEM(descr, member) \
|
||||
- descr->member
|
||||
-#define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
- descr->member[idx]
|
||||
-#define THREAD_SETMEM(descr, member, value) \
|
||||
- descr->member = (value)
|
||||
-#define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- descr->member[idx] = (value)
|
||||
+# include <tcb-access.h>
|
||||
|
||||
/* Set the stack guard field in TCB head. */
|
||||
#define THREAD_SET_STACK_GUARD(value) \
|
||||
diff --git a/sysdeps/x86_64/nptl/tcb-access.h b/sysdeps/x86_64/nptl/tcb-access.h
|
||||
new file mode 100644
|
||||
index 00000000..18848a72
|
||||
--- /dev/null
|
||||
+++ b/sysdeps/x86_64/nptl/tcb-access.h
|
||||
@@ -0,0 +1,130 @@
|
||||
+/* THREAD_* accessors. x86_64 version.
|
||||
+ Copyright (C) 2002-2021 Free Software Foundation, Inc.
|
||||
+ This file is part of the GNU C Library.
|
||||
+
|
||||
+ The GNU C Library is free software; you can redistribute it and/or
|
||||
+ modify it under the terms of the GNU Lesser General Public
|
||||
+ License as published by the Free Software Foundation; either
|
||||
+ version 2.1 of the License, or (at your option) any later version.
|
||||
+
|
||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ Lesser General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU Lesser General Public
|
||||
+ License along with the GNU C Library; if not, see
|
||||
+ <https://www.gnu.org/licenses/>. */
|
||||
+
|
||||
+/* Read member of the thread descriptor directly. */
|
||||
+# define THREAD_GETMEM(descr, member) \
|
||||
+ ({ __typeof (descr->member) __value; \
|
||||
+ _Static_assert (sizeof (__value) == 1 \
|
||||
+ || sizeof (__value) == 4 \
|
||||
+ || sizeof (__value) == 8, \
|
||||
+ "size of per-thread data"); \
|
||||
+ if (sizeof (__value) == 1) \
|
||||
+ asm volatile ("movb %%fs:%P2,%b0" \
|
||||
+ : "=q" (__value) \
|
||||
+ : "0" (0), "i" (offsetof (struct pthread, member))); \
|
||||
+ else if (sizeof (__value) == 4) \
|
||||
+ asm volatile ("movl %%fs:%P1,%0" \
|
||||
+ : "=r" (__value) \
|
||||
+ : "i" (offsetof (struct pthread, member))); \
|
||||
+ else /* 8 */ \
|
||||
+ { \
|
||||
+ asm volatile ("movq %%fs:%P1,%q0" \
|
||||
+ : "=r" (__value) \
|
||||
+ : "i" (offsetof (struct pthread, member))); \
|
||||
+ } \
|
||||
+ __value; })
|
||||
+
|
||||
+
|
||||
+/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
|
||||
+# define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
+ ({ __typeof (descr->member[0]) __value; \
|
||||
+ _Static_assert (sizeof (__value) == 1 \
|
||||
+ || sizeof (__value) == 4 \
|
||||
+ || sizeof (__value) == 8, \
|
||||
+ "size of per-thread data"); \
|
||||
+ if (sizeof (__value) == 1) \
|
||||
+ asm volatile ("movb %%fs:%P2(%q3),%b0" \
|
||||
+ : "=q" (__value) \
|
||||
+ : "0" (0), "i" (offsetof (struct pthread, member[0])), \
|
||||
+ "r" (idx)); \
|
||||
+ else if (sizeof (__value) == 4) \
|
||||
+ asm volatile ("movl %%fs:%P1(,%q2,4),%0" \
|
||||
+ : "=r" (__value) \
|
||||
+ : "i" (offsetof (struct pthread, member[0])), "r" (idx));\
|
||||
+ else /* 8 */ \
|
||||
+ { \
|
||||
+ asm volatile ("movq %%fs:%P1(,%q2,8),%q0" \
|
||||
+ : "=r" (__value) \
|
||||
+ : "i" (offsetof (struct pthread, member[0])), \
|
||||
+ "r" (idx)); \
|
||||
+ } \
|
||||
+ __value; })
|
||||
+
|
||||
+
|
||||
+/* Loading addresses of objects on x86-64 needs to be treated special
|
||||
+ when generating PIC code. */
|
||||
+#ifdef __pic__
|
||||
+# define IMM_MODE "nr"
|
||||
+#else
|
||||
+# define IMM_MODE "ir"
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
+/* Set member of the thread descriptor directly. */
|
||||
+# define THREAD_SETMEM(descr, member, value) \
|
||||
+ ({ \
|
||||
+ _Static_assert (sizeof (descr->member) == 1 \
|
||||
+ || sizeof (descr->member) == 4 \
|
||||
+ || sizeof (descr->member) == 8, \
|
||||
+ "size of per-thread data"); \
|
||||
+ if (sizeof (descr->member) == 1) \
|
||||
+ asm volatile ("movb %b0,%%fs:%P1" : \
|
||||
+ : "iq" (value), \
|
||||
+ "i" (offsetof (struct pthread, member))); \
|
||||
+ else if (sizeof (descr->member) == 4) \
|
||||
+ asm volatile ("movl %0,%%fs:%P1" : \
|
||||
+ : IMM_MODE (value), \
|
||||
+ "i" (offsetof (struct pthread, member))); \
|
||||
+ else /* 8 */ \
|
||||
+ { \
|
||||
+ /* Since movq takes a signed 32-bit immediate or a register source \
|
||||
+ operand, use "er" constraint for 32-bit signed integer constant \
|
||||
+ or register. */ \
|
||||
+ asm volatile ("movq %q0,%%fs:%P1" : \
|
||||
+ : "er" ((uint64_t) cast_to_integer (value)), \
|
||||
+ "i" (offsetof (struct pthread, member))); \
|
||||
+ }})
|
||||
+
|
||||
+
|
||||
+/* Same as THREAD_SETMEM, but the member offset can be non-constant. */
|
||||
+# define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
+ ({ \
|
||||
+ _Static_assert (sizeof (descr->member[0]) == 1 \
|
||||
+ || sizeof (descr->member[0]) == 4 \
|
||||
+ || sizeof (descr->member[0]) == 8, \
|
||||
+ "size of per-thread data"); \
|
||||
+ if (sizeof (descr->member[0]) == 1) \
|
||||
+ asm volatile ("movb %b0,%%fs:%P1(%q2)" : \
|
||||
+ : "iq" (value), \
|
||||
+ "i" (offsetof (struct pthread, member[0])), \
|
||||
+ "r" (idx)); \
|
||||
+ else if (sizeof (descr->member[0]) == 4) \
|
||||
+ asm volatile ("movl %0,%%fs:%P1(,%q2,4)" : \
|
||||
+ : IMM_MODE (value), \
|
||||
+ "i" (offsetof (struct pthread, member[0])), \
|
||||
+ "r" (idx)); \
|
||||
+ else /* 8 */ \
|
||||
+ { \
|
||||
+ /* Since movq takes a signed 32-bit immediate or a register source \
|
||||
+ operand, use "er" constraint for 32-bit signed integer constant \
|
||||
+ or register. */ \
|
||||
+ asm volatile ("movq %q0,%%fs:%P1(,%q2,8)" : \
|
||||
+ : "er" ((uint64_t) cast_to_integer (value)), \
|
||||
+ "i" (offsetof (struct pthread, member[0])), \
|
||||
+ "r" (idx)); \
|
||||
+ }})
|
||||
diff --git a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h
|
||||
index a78c4f4d..3af1836e 100644
|
||||
--- a/sysdeps/x86_64/nptl/tls.h
|
||||
+++ b/sysdeps/x86_64/nptl/tls.h
|
||||
@@ -195,119 +195,7 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80,
|
||||
# define DB_THREAD_SELF_INCLUDE <sys/reg.h> /* For the FS constant. */
|
||||
# define DB_THREAD_SELF CONST_THREAD_AREA (64, FS)
|
||||
|
||||
-/* Read member of the thread descriptor directly. */
|
||||
-# define THREAD_GETMEM(descr, member) \
|
||||
- ({ __typeof (descr->member) __value; \
|
||||
- _Static_assert (sizeof (__value) == 1 \
|
||||
- || sizeof (__value) == 4 \
|
||||
- || sizeof (__value) == 8, \
|
||||
- "size of per-thread data"); \
|
||||
- if (sizeof (__value) == 1) \
|
||||
- asm volatile ("movb %%fs:%P2,%b0" \
|
||||
- : "=q" (__value) \
|
||||
- : "0" (0), "i" (offsetof (struct pthread, member))); \
|
||||
- else if (sizeof (__value) == 4) \
|
||||
- asm volatile ("movl %%fs:%P1,%0" \
|
||||
- : "=r" (__value) \
|
||||
- : "i" (offsetof (struct pthread, member))); \
|
||||
- else /* 8 */ \
|
||||
- { \
|
||||
- asm volatile ("movq %%fs:%P1,%q0" \
|
||||
- : "=r" (__value) \
|
||||
- : "i" (offsetof (struct pthread, member))); \
|
||||
- } \
|
||||
- __value; })
|
||||
-
|
||||
-
|
||||
-/* Same as THREAD_GETMEM, but the member offset can be non-constant. */
|
||||
-# define THREAD_GETMEM_NC(descr, member, idx) \
|
||||
- ({ __typeof (descr->member[0]) __value; \
|
||||
- _Static_assert (sizeof (__value) == 1 \
|
||||
- || sizeof (__value) == 4 \
|
||||
- || sizeof (__value) == 8, \
|
||||
- "size of per-thread data"); \
|
||||
- if (sizeof (__value) == 1) \
|
||||
- asm volatile ("movb %%fs:%P2(%q3),%b0" \
|
||||
- : "=q" (__value) \
|
||||
- : "0" (0), "i" (offsetof (struct pthread, member[0])), \
|
||||
- "r" (idx)); \
|
||||
- else if (sizeof (__value) == 4) \
|
||||
- asm volatile ("movl %%fs:%P1(,%q2,4),%0" \
|
||||
- : "=r" (__value) \
|
||||
- : "i" (offsetof (struct pthread, member[0])), "r" (idx));\
|
||||
- else /* 8 */ \
|
||||
- { \
|
||||
- asm volatile ("movq %%fs:%P1(,%q2,8),%q0" \
|
||||
- : "=r" (__value) \
|
||||
- : "i" (offsetof (struct pthread, member[0])), \
|
||||
- "r" (idx)); \
|
||||
- } \
|
||||
- __value; })
|
||||
-
|
||||
-
|
||||
-/* Loading addresses of objects on x86-64 needs to be treated special
|
||||
- when generating PIC code. */
|
||||
-#ifdef __pic__
|
||||
-# define IMM_MODE "nr"
|
||||
-#else
|
||||
-# define IMM_MODE "ir"
|
||||
-#endif
|
||||
-
|
||||
-
|
||||
-/* Set member of the thread descriptor directly. */
|
||||
-# define THREAD_SETMEM(descr, member, value) \
|
||||
- ({ \
|
||||
- _Static_assert (sizeof (descr->member) == 1 \
|
||||
- || sizeof (descr->member) == 4 \
|
||||
- || sizeof (descr->member) == 8, \
|
||||
- "size of per-thread data"); \
|
||||
- if (sizeof (descr->member) == 1) \
|
||||
- asm volatile ("movb %b0,%%fs:%P1" : \
|
||||
- : "iq" (value), \
|
||||
- "i" (offsetof (struct pthread, member))); \
|
||||
- else if (sizeof (descr->member) == 4) \
|
||||
- asm volatile ("movl %0,%%fs:%P1" : \
|
||||
- : IMM_MODE (value), \
|
||||
- "i" (offsetof (struct pthread, member))); \
|
||||
- else /* 8 */ \
|
||||
- { \
|
||||
- /* Since movq takes a signed 32-bit immediate or a register source \
|
||||
- operand, use "er" constraint for 32-bit signed integer constant \
|
||||
- or register. */ \
|
||||
- asm volatile ("movq %q0,%%fs:%P1" : \
|
||||
- : "er" ((uint64_t) cast_to_integer (value)), \
|
||||
- "i" (offsetof (struct pthread, member))); \
|
||||
- }})
|
||||
-
|
||||
-
|
||||
-/* Same as THREAD_SETMEM, but the member offset can be non-constant. */
|
||||
-# define THREAD_SETMEM_NC(descr, member, idx, value) \
|
||||
- ({ \
|
||||
- _Static_assert (sizeof (descr->member[0]) == 1 \
|
||||
- || sizeof (descr->member[0]) == 4 \
|
||||
- || sizeof (descr->member[0]) == 8, \
|
||||
- "size of per-thread data"); \
|
||||
- if (sizeof (descr->member[0]) == 1) \
|
||||
- asm volatile ("movb %b0,%%fs:%P1(%q2)" : \
|
||||
- : "iq" (value), \
|
||||
- "i" (offsetof (struct pthread, member[0])), \
|
||||
- "r" (idx)); \
|
||||
- else if (sizeof (descr->member[0]) == 4) \
|
||||
- asm volatile ("movl %0,%%fs:%P1(,%q2,4)" : \
|
||||
- : IMM_MODE (value), \
|
||||
- "i" (offsetof (struct pthread, member[0])), \
|
||||
- "r" (idx)); \
|
||||
- else /* 8 */ \
|
||||
- { \
|
||||
- /* Since movq takes a signed 32-bit immediate or a register source \
|
||||
- operand, use "er" constraint for 32-bit signed integer constant \
|
||||
- or register. */ \
|
||||
- asm volatile ("movq %q0,%%fs:%P1(,%q2,8)" : \
|
||||
- : "er" ((uint64_t) cast_to_integer (value)), \
|
||||
- "i" (offsetof (struct pthread, member[0])), \
|
||||
- "r" (idx)); \
|
||||
- }})
|
||||
-
|
||||
+# include <tcb-access.h>
|
||||
|
||||
/* Set the stack guard field in TCB head. */
|
||||
# define THREAD_SET_STACK_GUARD(value) \
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
From 210967ce32172eb7356747ed0b655e1fc37d0c57 Mon Sep 17 00:00:00 2001
|
||||
From: Florian Weimer <fweimer@redhat.com>
|
||||
Date: Thu, 9 Dec 2021 09:49:32 +0100
|
||||
Subject: [PATCH 8/9] nptl: rseq failure after registration on main thread is
|
||||
fatal
|
||||
|
||||
This simplifies the application programming model.
|
||||
|
||||
Browser sandboxes have already been fixed:
|
||||
|
||||
Sandbox is incompatible with rseq registration
|
||||
<https://bugzilla.mozilla.org/show_bug.cgi?id=1651701>
|
||||
|
||||
Allow rseq in the Linux sandboxes. r=gcp
|
||||
<https://hg.mozilla.org/mozilla-central/rev/042425712eb1>
|
||||
|
||||
Sandbox needs to support rseq system call
|
||||
<https://bugs.chromium.org/p/chromium/issues/detail?id=1104160>
|
||||
|
||||
Linux sandbox: Allow rseq(2)
|
||||
<https://chromium.googlesource.com/chromium/src.git/+/230675d9ac8f1>
|
||||
|
||||
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
---
|
||||
nptl/pthread_create.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
|
||||
index f405fa35..109c5e3d 100644
|
||||
--- a/nptl/pthread_create.c
|
||||
+++ b/nptl/pthread_create.c
|
||||
@@ -371,7 +371,8 @@ start_thread (void *arg)
|
||||
/* Register rseq TLS to the kernel. */
|
||||
{
|
||||
bool do_rseq = THREAD_GETMEM (pd, flags) & ATTR_FLAG_DO_RSEQ;
|
||||
- rseq_register_current_thread (pd, do_rseq);
|
||||
+ if (!rseq_register_current_thread (pd, do_rseq) && do_rseq)
|
||||
+ __libc_fatal ("Fatal glibc error: rseq registration failed\n");
|
||||
}
|
||||
|
||||
#ifndef __ASSUME_SET_ROBUST_LIST
|
||||
--
|
||||
2.23.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user