aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/linux/rseq.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/uapi/linux/rseq.h')
-rw-r--r--include/uapi/linux/rseq.h102
1 files changed, 58 insertions, 44 deletions
diff --git a/include/uapi/linux/rseq.h b/include/uapi/linux/rseq.h
index d620fa43756c..9a402fdb60e9 100644
--- a/include/uapi/linux/rseq.h
+++ b/include/uapi/linux/rseq.h
@@ -10,13 +10,8 @@
10 * Copyright (c) 2015-2018 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> 10 * Copyright (c) 2015-2018 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 */ 11 */
12 12
13#ifdef __KERNEL__ 13#include <linux/types.h>
14# include <linux/types.h> 14#include <asm/byteorder.h>
15#else
16# include <stdint.h>
17#endif
18
19#include <linux/types_32_64.h>
20 15
21enum rseq_cpu_id_state { 16enum rseq_cpu_id_state {
22 RSEQ_CPU_ID_UNINITIALIZED = -1, 17 RSEQ_CPU_ID_UNINITIALIZED = -1,
@@ -52,10 +47,10 @@ struct rseq_cs {
52 __u32 version; 47 __u32 version;
53 /* enum rseq_cs_flags */ 48 /* enum rseq_cs_flags */
54 __u32 flags; 49 __u32 flags;
55 LINUX_FIELD_u32_u64(start_ip); 50 __u64 start_ip;
56 /* Offset from start_ip. */ 51 /* Offset from start_ip. */
57 LINUX_FIELD_u32_u64(post_commit_offset); 52 __u64 post_commit_offset;
58 LINUX_FIELD_u32_u64(abort_ip); 53 __u64 abort_ip;
59} __attribute__((aligned(4 * sizeof(__u64)))); 54} __attribute__((aligned(4 * sizeof(__u64))));
60 55
61/* 56/*
@@ -67,28 +62,30 @@ struct rseq_cs {
67struct rseq { 62struct rseq {
68 /* 63 /*
69 * Restartable sequences cpu_id_start field. Updated by the 64 * Restartable sequences cpu_id_start field. Updated by the
70 * kernel, and read by user-space with single-copy atomicity 65 * kernel. Read by user-space with single-copy atomicity
71 * semantics. Aligned on 32-bit. Always contains a value in the 66 * semantics. This field should only be read by the thread which
72 * range of possible CPUs, although the value may not be the 67 * registered this data structure. Aligned on 32-bit. Always
73 * actual current CPU (e.g. if rseq is not initialized). This 68 * contains a value in the range of possible CPUs, although the
74 * CPU number value should always be compared against the value 69 * value may not be the actual current CPU (e.g. if rseq is not
75 * of the cpu_id field before performing a rseq commit or 70 * initialized). This CPU number value should always be compared
76 * returning a value read from a data structure indexed using 71 * against the value of the cpu_id field before performing a rseq
77 * the cpu_id_start value. 72 * commit or returning a value read from a data structure indexed
73 * using the cpu_id_start value.
78 */ 74 */
79 __u32 cpu_id_start; 75 __u32 cpu_id_start;
80 /* 76 /*
81 * Restartable sequences cpu_id field. Updated by the kernel, 77 * Restartable sequences cpu_id field. Updated by the kernel.
82 * and read by user-space with single-copy atomicity semantics. 78 * Read by user-space with single-copy atomicity semantics. This
83 * Aligned on 32-bit. Values RSEQ_CPU_ID_UNINITIALIZED and 79 * field should only be read by the thread which registered this
84 * RSEQ_CPU_ID_REGISTRATION_FAILED have a special semantic: the 80 * data structure. Aligned on 32-bit. Values
85 * former means "rseq uninitialized", and latter means "rseq 81 * RSEQ_CPU_ID_UNINITIALIZED and RSEQ_CPU_ID_REGISTRATION_FAILED
86 * initialization failed". This value is meant to be read within 82 * have a special semantic: the former means "rseq uninitialized",
87 * rseq critical sections and compared with the cpu_id_start 83 * and latter means "rseq initialization failed". This value is
88 * value previously read, before performing the commit instruction, 84 * meant to be read within rseq critical sections and compared
89 * or read and compared with the cpu_id_start value before returning 85 * with the cpu_id_start value previously read, before performing
90 * a value loaded from a data structure indexed using the 86 * the commit instruction, or read and compared with the
91 * cpu_id_start value. 87 * cpu_id_start value before returning a value loaded from a data
88 * structure indexed using the cpu_id_start value.
92 */ 89 */
93 __u32 cpu_id; 90 __u32 cpu_id;
94 /* 91 /*
@@ -105,27 +102,44 @@ struct rseq {
105 * targeted by the rseq_cs. Also needs to be set to NULL by user-space 102 * targeted by the rseq_cs. Also needs to be set to NULL by user-space
106 * before reclaiming memory that contains the targeted struct rseq_cs. 103 * before reclaiming memory that contains the targeted struct rseq_cs.
107 * 104 *
108 * Read and set by the kernel with single-copy atomicity semantics. 105 * Read and set by the kernel. Set by user-space with single-copy
109 * Set by user-space with single-copy atomicity semantics. Aligned 106 * atomicity semantics. This field should only be updated by the
110 * on 64-bit. 107 * thread which registered this data structure. Aligned on 64-bit.
111 */ 108 */
112 LINUX_FIELD_u32_u64(rseq_cs); 109 union {
110 __u64 ptr64;
111#ifdef __LP64__
112 __u64 ptr;
113#else
114 struct {
115#if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || defined(__BIG_ENDIAN)
116 __u32 padding; /* Initialized to zero. */
117 __u32 ptr32;
118#else /* LITTLE */
119 __u32 ptr32;
120 __u32 padding; /* Initialized to zero. */
121#endif /* ENDIAN */
122 } ptr;
123#endif
124 } rseq_cs;
125
113 /* 126 /*
114 * - RSEQ_DISABLE flag: 127 * Restartable sequences flags field.
128 *
129 * This field should only be updated by the thread which
130 * registered this data structure. Read by the kernel.
131 * Mainly used for single-stepping through rseq critical sections
132 * with debuggers.
115 * 133 *
116 * Fallback fast-track flag for single-stepping.
117 * Set by user-space if lack of progress is detected.
118 * Cleared by user-space after rseq finish.
119 * Read by the kernel.
120 * - RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT 134 * - RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT
121 * Inhibit instruction sequence block restart and event 135 * Inhibit instruction sequence block restart on preemption
122 * counter increment on preemption for this thread. 136 * for this thread.
123 * - RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL 137 * - RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL
124 * Inhibit instruction sequence block restart and event 138 * Inhibit instruction sequence block restart on signal
125 * counter increment on signal delivery for this thread. 139 * delivery for this thread.
126 * - RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE 140 * - RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE
127 * Inhibit instruction sequence block restart and event 141 * Inhibit instruction sequence block restart on migration for
128 * counter increment on migration for this thread. 142 * this thread.
129 */ 143 */
130 __u32 flags; 144 __u32 flags;
131} __attribute__((aligned(4 * sizeof(__u64)))); 145} __attribute__((aligned(4 * sizeof(__u64))));