Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx> --- tools/testing/selftests/rseq/rseq-abi.h | 15 +++++++++++++++ tools/testing/selftests/rseq/rseq.c | 6 +++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/rseq/rseq-abi.h b/tools/testing/selftests/rseq/rseq-abi.h index 850827e8d089..929183c2b3c0 100644 --- a/tools/testing/selftests/rseq/rseq-abi.h +++ b/tools/testing/selftests/rseq/rseq-abi.h @@ -169,6 +169,21 @@ struct rseq_abi { * rseq_len. Use the offset immediately after the node_id field as * rseq_len. */ + + /* + * Restartable sequences tg_vcpu_id field. Updated by the kernel. Read by + * user-space with single-copy atomicity semantics. This field should + * only be read by the thread which registered this data structure. + * Aligned on 32-bit. Contains the current thread's virtual CPU ID + * (allocated uniquely within thread group). + */ + __u32 tg_vcpu_id; + + /* + * This is a valid end of rseq ABI for the purpose of rseq registration + * rseq_len. Use the offset immediately after the tg_vcpu_id field as + * rseq_len. + */ } __attribute__((aligned(4 * sizeof(__u64)))); #endif /* _RSEQ_ABI_H */ diff --git a/tools/testing/selftests/rseq/rseq.c b/tools/testing/selftests/rseq/rseq.c index 4b0e68051db8..c8d30e770d59 100644 --- a/tools/testing/selftests/rseq/rseq.c +++ b/tools/testing/selftests/rseq/rseq.c @@ -88,7 +88,7 @@ int rseq_register_current_thread(void) /* Treat libc's ownership as a successful registration. */ return 0; } - rc = sys_rseq(&__rseq_abi, rseq_offsetofend(struct rseq_abi, node_id), 0, RSEQ_SIG); + rc = sys_rseq(&__rseq_abi, rseq_offsetofend(struct rseq_abi, tg_vcpu_id), 0, RSEQ_SIG); if (rc) return -1; assert(rseq_current_cpu_raw() >= 0); @@ -103,7 +103,7 @@ int rseq_unregister_current_thread(void) /* Treat libc's ownership as a successful unregistration. */ return 0; } - rc = sys_rseq(&__rseq_abi, rseq_offsetofend(struct rseq_abi, node_id), RSEQ_ABI_FLAG_UNREGISTER, RSEQ_SIG); + rc = sys_rseq(&__rseq_abi, rseq_offsetofend(struct rseq_abi, tg_vcpu_id), RSEQ_ABI_FLAG_UNREGISTER, RSEQ_SIG); if (rc) return -1; return 0; @@ -126,7 +126,7 @@ void rseq_init(void) return; rseq_ownership = 1; rseq_offset = (void *)&__rseq_abi - rseq_thread_pointer(); - rseq_size = rseq_offsetofend(struct rseq_abi, node_id); + rseq_size = rseq_offsetofend(struct rseq_abi, tg_vcpu_id); rseq_flags = 0; } -- 2.17.1