selftests/rseq: Remove volatile from __rseq_abi
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 24 Jan 2022 17:12:42 +0000 (12:12 -0500)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 2 Feb 2022 12:11:34 +0000 (13:11 +0100)
This is done in preparation for the selftest uplift to become compatible
with glibc-2.35.

All accesses to the __rseq_abi fields are volatile, but remove the
volatile from the TLS variable declaration, otherwise we are stuck with
volatile for the upcoming rseq_get_abi() helper.

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-5-mathieu.desnoyers@efficios.com
tools/testing/selftests/rseq/rseq.c
tools/testing/selftests/rseq/rseq.h

index bfe1b2692ffc00cd18e3fb2ace8b6c1e6eb2510f..1f905b60728a351c50a4a2e229fa24f20d760f12 100644 (file)
@@ -30,7 +30,7 @@
 #include "../kselftest.h"
 #include "rseq.h"
 
-__thread volatile struct rseq_abi __rseq_abi = {
+__thread struct rseq_abi __rseq_abi = {
        .cpu_id = RSEQ_ABI_CPU_ID_UNINITIALIZED,
 };
 
@@ -92,7 +92,7 @@ int rseq_register_current_thread(void)
                goto end;
        }
        if (errno != EBUSY)
-               __rseq_abi.cpu_id = RSEQ_ABI_CPU_ID_REGISTRATION_FAILED;
+               RSEQ_WRITE_ONCE(__rseq_abi.cpu_id, RSEQ_ABI_CPU_ID_REGISTRATION_FAILED);
        ret = -1;
        __rseq_refcount--;
 end:
index cb6bbc53b5861dbdef4b2e050bed9cafa8f01d30..d580f8e9c0012073416f5aa241cf8d2184f52216 100644 (file)
@@ -43,7 +43,7 @@
 #define RSEQ_INJECT_FAILED
 #endif
 
-extern __thread volatile struct rseq_abi __rseq_abi;
+extern __thread struct rseq_abi __rseq_abi;
 extern int __rseq_handled;
 
 #define rseq_likely(x)         __builtin_expect(!!(x), 1)
@@ -139,7 +139,7 @@ static inline uint32_t rseq_current_cpu(void)
 
 static inline void rseq_clear_rseq_cs(void)
 {
-       __rseq_abi.rseq_cs.arch.ptr = 0;
+       RSEQ_WRITE_ONCE(__rseq_abi.rseq_cs.arch.ptr, 0);
 }
 
 /*