[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f9d71d6c6f87b6ea88b904f328595b7663e6a6d2.1732326588.git.jpoimboe@kernel.org>
Date: Fri, 22 Nov 2024 17:52:20 -0800
From: Josh Poimboeuf <jpoimboe@...nel.org>
To: Valentin Schneider <vschneid@...hat.com>
Cc: linux-kernel@...r.kernel.org,
Peter Zijlstra <peterz@...radead.org>
Subject: [PATCH 1/3] jump_label: Add annotations for validating noinstr usage
Deferring a code patching IPI is unsafe if the patched code is in a
noinstr region. In that case the text poke code must trigger an
immediate IPI to all CPUs, which can rudely interrupt an isolated NO_HZ
CPU running in userspace.
Some noinstr static branches may really need to be patched at runtime,
despite the resulting disruption. Add DEFINE_STATIC_KEY_*_NOINSTR()
variants for those. They don't do anything special yet; that will come
later.
Signed-off-by: Josh Poimboeuf <jpoimboe@...nel.org>
---
include/linux/jump_label.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index f5a2727ca4a9..88bb6e32fdcb 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -385,6 +385,23 @@ struct static_key_false {
#define DEFINE_STATIC_KEY_FALSE_RO(name) \
struct static_key_false name __ro_after_init = STATIC_KEY_FALSE_INIT
+/*
+ * The _NOINSTR variants are used to tell objtool the static key is allowed to
+ * be used in noinstr code.
+ *
+ * They should almost never be used, as they prevent code patching IPIs from
+ * being deferred, which can be problematic for isolated NOHZ_FULL CPUs running
+ * in pure userspace.
+ *
+ * If using one of these _NOINSTR variants, please add a comment above the
+ * definition with the rationale.
+ */
+#define DEFINE_STATIC_KEY_TRUE_NOINSTR(name) \
+ DEFINE_STATIC_KEY_TRUE(name)
+
+#define DEFINE_STATIC_KEY_FALSE_NOINSTR(name) \
+ DEFINE_STATIC_KEY_FALSE(name)
+
#define DECLARE_STATIC_KEY_FALSE(name) \
extern struct static_key_false name
--
2.47.0
Powered by blists - more mailing lists