diff options
| -rw-r--r-- | include/uapi/linux/rseq.h | 69 | ||||
| -rw-r--r-- | kernel/rseq.c | 2 |
2 files changed, 37 insertions, 34 deletions
diff --git a/include/uapi/linux/rseq.h b/include/uapi/linux/rseq.h index 519ad6e176d1..bf4188c13bec 100644 --- a/include/uapi/linux/rseq.h +++ b/include/uapi/linux/rseq.h | |||
| @@ -67,28 +67,30 @@ struct rseq_cs { | |||
| 67 | struct rseq { | 67 | struct rseq { |
| 68 | /* | 68 | /* |
| 69 | * Restartable sequences cpu_id_start field. Updated by the | 69 | * Restartable sequences cpu_id_start field. Updated by the |
| 70 | * kernel, and read by user-space with single-copy atomicity | 70 | * kernel. Read by user-space with single-copy atomicity |
| 71 | * semantics. Aligned on 32-bit. Always contains a value in the | 71 | * semantics. This field should only be read by the thread which |
| 72 | * range of possible CPUs, although the value may not be the | 72 | * registered this data structure. Aligned on 32-bit. Always |
| 73 | * actual current CPU (e.g. if rseq is not initialized). This | 73 | * contains a value in the range of possible CPUs, although the |
| 74 | * CPU number value should always be compared against the value | 74 | * 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 | 75 | * initialized). This CPU number value should always be compared |
| 76 | * returning a value read from a data structure indexed using | 76 | * against the value of the cpu_id field before performing a rseq |
| 77 | * the cpu_id_start value. | 77 | * commit or returning a value read from a data structure indexed |
| 78 | * using the cpu_id_start value. | ||
| 78 | */ | 79 | */ |
| 79 | __u32 cpu_id_start; | 80 | __u32 cpu_id_start; |
| 80 | /* | 81 | /* |
| 81 | * Restartable sequences cpu_id field. Updated by the kernel, | 82 | * Restartable sequences cpu_id field. Updated by the kernel. |
| 82 | * and read by user-space with single-copy atomicity semantics. | 83 | * Read by user-space with single-copy atomicity semantics. This |
| 83 | * Aligned on 32-bit. Values RSEQ_CPU_ID_UNINITIALIZED and | 84 | * field should only be read by the thread which registered this |
| 84 | * RSEQ_CPU_ID_REGISTRATION_FAILED have a special semantic: the | 85 | * data structure. Aligned on 32-bit. Values |
| 85 | * former means "rseq uninitialized", and latter means "rseq | 86 | * RSEQ_CPU_ID_UNINITIALIZED and RSEQ_CPU_ID_REGISTRATION_FAILED |
| 86 | * initialization failed". This value is meant to be read within | 87 | * have a special semantic: the former means "rseq uninitialized", |
| 87 | * rseq critical sections and compared with the cpu_id_start | 88 | * and latter means "rseq initialization failed". This value is |
| 88 | * value previously read, before performing the commit instruction, | 89 | * meant to be read within rseq critical sections and compared |
| 89 | * or read and compared with the cpu_id_start value before returning | 90 | * with the cpu_id_start value previously read, before performing |
| 90 | * a value loaded from a data structure indexed using the | 91 | * the commit instruction, or read and compared with the |
| 91 | * cpu_id_start value. | 92 | * cpu_id_start value before returning a value loaded from a data |
| 93 | * structure indexed using the cpu_id_start value. | ||
| 92 | */ | 94 | */ |
| 93 | __u32 cpu_id; | 95 | __u32 cpu_id; |
| 94 | /* | 96 | /* |
| @@ -105,27 +107,28 @@ struct rseq { | |||
| 105 | * targeted by the rseq_cs. Also needs to be set to NULL by user-space | 107 | * 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. | 108 | * before reclaiming memory that contains the targeted struct rseq_cs. |
| 107 | * | 109 | * |
| 108 | * Read and set by the kernel with single-copy atomicity semantics. | 110 | * Read and set by the kernel. Set by user-space with single-copy |
| 109 | * Set by user-space with single-copy atomicity semantics. Aligned | 111 | * atomicity semantics. This field should only be updated by the |
| 110 | * on 64-bit. | 112 | * thread which registered this data structure. Aligned on 64-bit. |
| 111 | */ | 113 | */ |
| 112 | LINUX_FIELD_u32_u64(rseq_cs); | 114 | LINUX_FIELD_u32_u64(rseq_cs); |
| 113 | /* | 115 | /* |
| 114 | * - RSEQ_DISABLE flag: | 116 | * Restartable sequences flags field. |
| 117 | * | ||
| 118 | * This field should only be updated by the thread which | ||
| 119 | * registered this data structure. Read by the kernel. | ||
| 120 | * Mainly used for single-stepping through rseq critical sections | ||
| 121 | * with debuggers. | ||
| 115 | * | 122 | * |
| 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 | 123 | * - RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT |
| 121 | * Inhibit instruction sequence block restart and event | 124 | * Inhibit instruction sequence block restart on preemption |
| 122 | * counter increment on preemption for this thread. | 125 | * for this thread. |
| 123 | * - RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL | 126 | * - RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL |
| 124 | * Inhibit instruction sequence block restart and event | 127 | * Inhibit instruction sequence block restart on signal |
| 125 | * counter increment on signal delivery for this thread. | 128 | * delivery for this thread. |
| 126 | * - RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE | 129 | * - RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE |
| 127 | * Inhibit instruction sequence block restart and event | 130 | * Inhibit instruction sequence block restart on migration for |
| 128 | * counter increment on migration for this thread. | 131 | * this thread. |
| 129 | */ | 132 | */ |
| 130 | __u32 flags; | 133 | __u32 flags; |
| 131 | } __attribute__((aligned(4 * sizeof(__u64)))); | 134 | } __attribute__((aligned(4 * sizeof(__u64)))); |
diff --git a/kernel/rseq.c b/kernel/rseq.c index 2c8463acb50d..2a7748675be7 100644 --- a/kernel/rseq.c +++ b/kernel/rseq.c | |||
| @@ -201,7 +201,7 @@ static int clear_rseq_cs(struct task_struct *t) | |||
| 201 | * of code outside of the rseq assembly block. This performs | 201 | * of code outside of the rseq assembly block. This performs |
| 202 | * a lazy clear of the rseq_cs field. | 202 | * a lazy clear of the rseq_cs field. |
| 203 | * | 203 | * |
| 204 | * Set rseq_cs to NULL with single-copy atomicity. | 204 | * Set rseq_cs to NULL. |
| 205 | */ | 205 | */ |
| 206 | return put_user(0UL, &t->rseq->rseq_cs); | 206 | return put_user(0UL, &t->rseq->rseq_cs); |
| 207 | } | 207 | } |
