[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200706204913.20347-4-mathieu.desnoyers@efficios.com>
Date: Mon, 6 Jul 2020 16:49:12 -0400
From: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: linux-kernel@...r.kernel.org,
Peter Zijlstra <peterz@...radead.org>,
"Paul E . McKenney" <paulmck@...ux.ibm.com>,
Boqun Feng <boqun.feng@...il.com>,
"H . Peter Anvin" <hpa@...or.com>, Paul Turner <pjt@...gle.com>,
linux-api@...r.kernel.org, Florian Weimer <fw@...eb.enyo.de>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Dmitry Vyukov <dvyukov@...gle.com>,
Neel Natu <neelnatu@...gle.com>
Subject: [RFC PATCH for 5.8 3/4] rseq: Introduce RSEQ_FLAG_RELIABLE_CPU_ID
commit 93b585c08d16 ("Fix: sched: unreliable rseq cpu_id for new tasks")
addresses an issue with cpu_id field of newly created processes. Expose
a flag which can be used by user-space to query whether the kernel
implements this fix.
Considering that this issue can cause corruption of user-space per-cpu
data updated with rseq, it is recommended that user-space detects
availability of this fix by using the RSEQ_FLAG_RELIABLE_CPU_ID flag
either combined with registration or on its own before using rseq.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Cc: Peter Zijlstra (Intel) <peterz@...radead.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Florian Weimer <fw@...eb.enyo.de>
Cc: "Paul E. McKenney" <paulmck@...ux.ibm.com>
Cc: Boqun Feng <boqun.feng@...il.com>
Cc: "H . Peter Anvin" <hpa@...or.com>
Cc: Paul Turner <pjt@...gle.com>
Cc: Dmitry Vyukov <dvyukov@...gle.com>
Cc: Neel Natu <neelnatu@...gle.com>
Cc: linux-api@...r.kernel.org
---
include/uapi/linux/rseq.h | 5 +++++
kernel/rseq.c | 4 ++++
2 files changed, 9 insertions(+)
diff --git a/include/uapi/linux/rseq.h b/include/uapi/linux/rseq.h
index 3b5fba25461a..a548b77c9520 100644
--- a/include/uapi/linux/rseq.h
+++ b/include/uapi/linux/rseq.h
@@ -21,13 +21,18 @@ enum rseq_cpu_id_state {
/*
* RSEQ_FLAG_UNREGISTER: Unregister rseq ABI for caller thread.
* RSEQ_FLAG_REGISTER: Register rseq ABI for caller thread.
+ * RSEQ_FLAG_RELIABLE_CPU_ID: rseq provides a reliable cpu_id field.
*
* Flag value 0 has the same behavior as RSEQ_FLAG_REGISTER, but cannot be
* combined with other flags. This behavior is kept for backward compatibility.
+ *
+ * The flag RSEQ_FLAG_REGISTER can be combined with the RSEQ_FLAG_RELIABLE_CPU_ID
+ * flag.
*/
enum rseq_flags {
RSEQ_FLAG_UNREGISTER = (1 << 0),
RSEQ_FLAG_REGISTER = (1 << 1),
+ RSEQ_FLAG_RELIABLE_CPU_ID = (1 << 2),
};
enum rseq_cs_flags_bit {
diff --git a/kernel/rseq.c b/kernel/rseq.c
index 47ce221cd6f9..32cc2e0d961f 100644
--- a/kernel/rseq.c
+++ b/kernel/rseq.c
@@ -333,6 +333,8 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len,
current->rseq_sig = 0;
break;
case RSEQ_FLAG_REGISTER:
+ fallthrough;
+ case RSEQ_FLAG_REGISTER | RSEQ_FLAG_RELIABLE_CPU_ID:
if (current->rseq) {
/*
* If rseq is already registered, check whether
@@ -365,6 +367,8 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len,
*/
rseq_set_notify_resume(current);
break;
+ case RSEQ_FLAG_RELIABLE_CPU_ID:
+ break;
default:
return -EINVAL;
}
--
2.17.1
Powered by blists - more mailing lists