Commit 0fb9a1ab authored by Mathieu Desnoyers's avatar Mathieu Desnoyers Committed by Thomas Gleixner

rseq: uapi: Update uapi comments

Update rseq uapi header comments to reflect that user-space need to do
thread-local loads/stores from/to the struct rseq fields.

As a consequence of this added requirement, the kernel does not need
to perform loads/stores with single-copy atomicity.

Update the comment associated to the "flags" fields to describe
more accurately that it's only useful to facilitate single-stepping
through rseq critical sections with debuggers.
Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: linux-api@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Watson <davejwatson@fb.com>
Cc: Paul Turner <pjt@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: "H . Peter Anvin" <hpa@zytor.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Chris Lameter <cl@linux.com>
Cc: Ben Maurer <bmaurer@fb.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Joel Fernandes <joelaf@google.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Link: https://lkml.kernel.org/r/20180709195155.7654-4-mathieu.desnoyers@efficios.com
parent 8f281770
...@@ -67,28 +67,30 @@ struct rseq_cs { ...@@ -67,28 +67,30 @@ struct rseq_cs {
struct rseq { struct rseq {
/* /*
* Restartable sequences cpu_id_start field. Updated by the * Restartable sequences cpu_id_start field. Updated by the
* kernel, and read by user-space with single-copy atomicity * kernel. Read by user-space with single-copy atomicity
* semantics. Aligned on 32-bit. Always contains a value in the * semantics. This field should only be read by the thread which
* range of possible CPUs, although the value may not be the * registered this data structure. Aligned on 32-bit. Always
* actual current CPU (e.g. if rseq is not initialized). This * contains a value in the range of possible CPUs, although the
* CPU number value should always be compared against the value * value may not be the actual current CPU (e.g. if rseq is not
* of the cpu_id field before performing a rseq commit or * initialized). This CPU number value should always be compared
* returning a value read from a data structure indexed using * against the value of the cpu_id field before performing a rseq
* the cpu_id_start value. * commit or returning a value read from a data structure indexed
* using the cpu_id_start value.
*/ */
__u32 cpu_id_start; __u32 cpu_id_start;
/* /*
* Restartable sequences cpu_id field. Updated by the kernel, * Restartable sequences cpu_id field. Updated by the kernel.
* and read by user-space with single-copy atomicity semantics. * Read by user-space with single-copy atomicity semantics. This
* Aligned on 32-bit. Values RSEQ_CPU_ID_UNINITIALIZED and * field should only be read by the thread which registered this
* RSEQ_CPU_ID_REGISTRATION_FAILED have a special semantic: the * data structure. Aligned on 32-bit. Values
* former means "rseq uninitialized", and latter means "rseq * RSEQ_CPU_ID_UNINITIALIZED and RSEQ_CPU_ID_REGISTRATION_FAILED
* initialization failed". This value is meant to be read within * have a special semantic: the former means "rseq uninitialized",
* rseq critical sections and compared with the cpu_id_start * and latter means "rseq initialization failed". This value is
* value previously read, before performing the commit instruction, * meant to be read within rseq critical sections and compared
* or read and compared with the cpu_id_start value before returning * with the cpu_id_start value previously read, before performing
* a value loaded from a data structure indexed using the * the commit instruction, or read and compared with the
* cpu_id_start value. * cpu_id_start value before returning a value loaded from a data
* structure indexed using the cpu_id_start value.
*/ */
__u32 cpu_id; __u32 cpu_id;
/* /*
...@@ -105,27 +107,28 @@ struct rseq { ...@@ -105,27 +107,28 @@ struct rseq {
* targeted by the rseq_cs. Also needs to be set to NULL by user-space * targeted by the rseq_cs. Also needs to be set to NULL by user-space
* before reclaiming memory that contains the targeted struct rseq_cs. * before reclaiming memory that contains the targeted struct rseq_cs.
* *
* Read and set by the kernel with single-copy atomicity semantics. * Read and set by the kernel. Set by user-space with single-copy
* Set by user-space with single-copy atomicity semantics. Aligned * atomicity semantics. This field should only be updated by the
* on 64-bit. * thread which registered this data structure. Aligned on 64-bit.
*/ */
LINUX_FIELD_u32_u64(rseq_cs); LINUX_FIELD_u32_u64(rseq_cs);
/* /*
* - RSEQ_DISABLE flag: * Restartable sequences flags field.
*
* This field should only be updated by the thread which
* registered this data structure. Read by the kernel.
* Mainly used for single-stepping through rseq critical sections
* with debuggers.
* *
* Fallback fast-track flag for single-stepping.
* Set by user-space if lack of progress is detected.
* Cleared by user-space after rseq finish.
* Read by the kernel.
* - RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT * - RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT
* Inhibit instruction sequence block restart and event * Inhibit instruction sequence block restart on preemption
* counter increment on preemption for this thread. * for this thread.
* - RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL * - RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL
* Inhibit instruction sequence block restart and event * Inhibit instruction sequence block restart on signal
* counter increment on signal delivery for this thread. * delivery for this thread.
* - RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE * - RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE
* Inhibit instruction sequence block restart and event * Inhibit instruction sequence block restart on migration for
* counter increment on migration for this thread. * this thread.
*/ */
__u32 flags; __u32 flags;
} __attribute__((aligned(4 * sizeof(__u64)))); } __attribute__((aligned(4 * sizeof(__u64))));
......
...@@ -201,7 +201,7 @@ static int clear_rseq_cs(struct task_struct *t) ...@@ -201,7 +201,7 @@ static int clear_rseq_cs(struct task_struct *t)
* of code outside of the rseq assembly block. This performs * of code outside of the rseq assembly block. This performs
* a lazy clear of the rseq_cs field. * a lazy clear of the rseq_cs field.
* *
* Set rseq_cs to NULL with single-copy atomicity. * Set rseq_cs to NULL.
*/ */
return put_user(0UL, &t->rseq->rseq_cs); return put_user(0UL, &t->rseq->rseq_cs);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment