summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/rseq/rseq.h
diff options
context:
space:
mode:
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>2022-01-24 20:12:43 +0300
committerPeter Zijlstra <peterz@infradead.org>2022-02-02 15:11:35 +0300
commite546cd48ccc456074ddb8920732aef4af65d7ca7 (patch)
treee9ca24ec796e1635c74982918b875776e19c5aee /tools/testing/selftests/rseq/rseq.h
parent94b80a19ebfe347a01301d750040a61c38200e2b (diff)
downloadlinux-e546cd48ccc456074ddb8920732aef4af65d7ca7.tar.xz
selftests/rseq: Introduce rseq_get_abi() helper
This is done in preparation for the selftest uplift to become compatible with glibc-2.35. glibc-2.35 exposes the rseq per-thread data in the TCB, accessible at an offset from the thread pointer, rather than through an actual Thread-Local Storage (TLS) variable, as the kernel selftests initially expected. Introduce a rseq_get_abi() helper, initially using the __rseq_abi TLS variable, in preparation for changing this userspace ABI for one which is compatible with glibc-2.35. Note that the __rseq_abi TLS and glibc-2.35's ABI for per-thread data cannot actively coexist in a process, because the kernel supports only a single rseq registration per thread. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20220124171253.22072-6-mathieu.desnoyers@efficios.com
Diffstat (limited to 'tools/testing/selftests/rseq/rseq.h')
-rw-r--r--tools/testing/selftests/rseq/rseq.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/testing/selftests/rseq/rseq.h b/tools/testing/selftests/rseq/rseq.h
index d580f8e9c001..ca668a2af172 100644
--- a/tools/testing/selftests/rseq/rseq.h
+++ b/tools/testing/selftests/rseq/rseq.h
@@ -46,6 +46,11 @@
extern __thread struct rseq_abi __rseq_abi;
extern int __rseq_handled;
+static inline struct rseq_abi *rseq_get_abi(void)
+{
+ return &__rseq_abi;
+}
+
#define rseq_likely(x) __builtin_expect(!!(x), 1)
#define rseq_unlikely(x) __builtin_expect(!!(x), 0)
#define rseq_barrier() __asm__ __volatile__("" : : : "memory")
@@ -108,7 +113,7 @@ int32_t rseq_fallback_current_cpu(void);
*/
static inline int32_t rseq_current_cpu_raw(void)
{
- return RSEQ_ACCESS_ONCE(__rseq_abi.cpu_id);
+ return RSEQ_ACCESS_ONCE(rseq_get_abi()->cpu_id);
}
/*
@@ -124,7 +129,7 @@ static inline int32_t rseq_current_cpu_raw(void)
*/
static inline uint32_t rseq_cpu_start(void)
{
- return RSEQ_ACCESS_ONCE(__rseq_abi.cpu_id_start);
+ return RSEQ_ACCESS_ONCE(rseq_get_abi()->cpu_id_start);
}
static inline uint32_t rseq_current_cpu(void)
@@ -139,7 +144,7 @@ static inline uint32_t rseq_current_cpu(void)
static inline void rseq_clear_rseq_cs(void)
{
- RSEQ_WRITE_ONCE(__rseq_abi.rseq_cs.arch.ptr, 0);
+ RSEQ_WRITE_ONCE(rseq_get_abi()->rseq_cs.arch.ptr, 0);
}
/*