#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-/*
- * linux/rseq.h defines struct rseq as aligned on 32 bytes. The kernel ABI
- * size is 20 bytes. For support of multiple rseq users within a process,
- * user-space defines an extra 4 bytes field as a reference count, for a
- * total of 24 bytes.
- */
-struct libc_rseq {
- /* kernel-userspace ABI. */
- __u32 cpu_id_start;
- __u32 cpu_id;
- __u64 rseq_cs;
- __u32 flags;
- /* user-space ABI. */
- __u32 refcount;
-} __attribute__((aligned(4 * sizeof(__u64))));
-
-__attribute__((visibility("hidden"))) __thread
-volatile struct libc_rseq __lib_rseq_abi = {
+__attribute__((weak)) __thread
+volatile struct rseq __rseq_abi = {
.cpu_id = RSEQ_CPU_ID_UNINITIALIZED,
};
-extern __attribute__((weak, alias("__lib_rseq_abi"))) __thread
-volatile struct rseq __rseq_abi;
+__attribute__((weak)) __thread
+volatile uint32_t __rseq_refcount;
static int sys_rseq(volatile struct rseq *rseq_abi, uint32_t rseq_len,
int flags, uint32_t sig)
sigset_t oldset;
signal_off_save(&oldset);
- if (__lib_rseq_abi.refcount == INT_MAX) {
+ if (__rseq_refcount == UINT_MAX) {
ret = -1;
goto end;
}
- if (__lib_rseq_abi.refcount++)
+ if (__rseq_refcount++)
goto end;
rc = sys_rseq(&__rseq_abi, sizeof(struct rseq), 0, RSEQ_SIG);
if (!rc) {
if (errno != EBUSY)
__rseq_abi.cpu_id = RSEQ_CPU_ID_REGISTRATION_FAILED;
ret = -1;
- __lib_rseq_abi.refcount--;
+ __rseq_refcount--;
end:
signal_restore(oldset);
return ret;
sigset_t oldset;
signal_off_save(&oldset);
- if (!__lib_rseq_abi.refcount) {
+ if (!__rseq_refcount) {
ret = -1;
goto end;
}
- if (--__lib_rseq_abi.refcount)
+ if (--__rseq_refcount)
goto end;
rc = sys_rseq(&__rseq_abi, sizeof(struct rseq),
RSEQ_FLAG_UNREGISTER, RSEQ_SIG);