[v5,11/24] selftests/rseq: Implement rseq vm_vcpu_id field support
Commit Message
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
---
tools/testing/selftests/rseq/rseq-abi.h | 9 +++++++++
tools/testing/selftests/rseq/rseq.h | 10 ++++++++++
2 files changed, 19 insertions(+)
@@ -155,6 +155,15 @@ struct rseq_abi {
*/
__u32 node_id;
+ /*
+ * Restartable sequences vm_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 a memory space).
+ */
+ __u32 vm_vcpu_id;
+
/*
* Flexible array member at end of structure, after last feature field.
*/
@@ -191,6 +191,16 @@ static inline uint32_t rseq_current_node_id(void)
return RSEQ_ACCESS_ONCE(rseq_get_abi()->node_id);
}
+static inline bool rseq_vm_vcpu_id_available(void)
+{
+ return (int) rseq_feature_size >= rseq_offsetofend(struct rseq_abi, vm_vcpu_id);
+}
+
+static inline uint32_t rseq_current_vm_vcpu_id(void)
+{
+ return RSEQ_ACCESS_ONCE(rseq_get_abi()->vm_vcpu_id);
+}
+
static inline void rseq_clear_rseq_cs(void)
{
RSEQ_WRITE_ONCE(rseq_get_abi()->rseq_cs.arch.ptr, 0);