[PATCH v9 05/10] jump_label: Add annotations for validating .entry.text key usage

From: Valentin Schneider

Date: Tue May 05 2026 - 04:27:49 EST


From: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>

Adding static keys to entry text needs to be done with care, as they may be
executed before a context serialization operation has been run. Add
DEFINE_STATIC_KEY_*_ENTRY() variants for those. They don't do anything
special yet; that will come later.

Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
[Reduced from .noinstr to .entry.text]
Signed-off-by: Valentin Schneider <vschneid@xxxxxxxxxx>
---
include/linux/jump_label.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index b9c7b0ebf7b9d..e05b4a52ba1b4 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -374,6 +374,20 @@ struct static_key_false {
#define DEFINE_STATIC_KEY_FALSE_RO(name) \
struct static_key_false name __ro_after_init = STATIC_KEY_FALSE_INIT

+/*
+ * Objtool will warn about static keys used in early entry code, as they may
+ * be unsafe if executed before any serializing operation.
+ *
+ * The _ENTRY variants are used to tell objtool the static key is safe to be
+ * used. If using one of these _ENTRY variants, please add a comment above the
+ * definition with the rationale.
+ */
+#define DEFINE_STATIC_KEY_TRUE_ENTRY(name) \
+ DEFINE_STATIC_KEY_TRUE(name)
+
+#define DEFINE_STATIC_KEY_FALSE_ENTRY(name) \
+ DEFINE_STATIC_KEY_FALSE(name)
+
#define DECLARE_STATIC_KEY_FALSE(name) \
extern struct static_key_false name

--
2.52.0