From: Josh Poimboeuf <jpoimboe@kernel.org>
To: Valentin Schneider <vschneid@redhat.com>
Cc: linux-kernel@vger.kernel.org, Peter Zijlstra <peterz@infradead.org>
Subject: [PATCH v2 2/3] static_call: Add read-only-after-init static calls
Date: Tue, 26 Nov 2024 20:47:41 -0800 [thread overview]
Message-ID: <069be22d3643046173edbbe110218a9fd28a2e55.1732682344.git.jpoimboe@kernel.org> (raw)
In-Reply-To: <cover.1732682344.git.jpoimboe@kernel.org>
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.
If a noinstr static call only needs to be patched during boot, its key
can be made ro-after-init to ensure it will never be patched at runtime.
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
include/linux/static_call.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/include/linux/static_call.h b/include/linux/static_call.h
index 141e6b176a1b..34970e178fdf 100644
--- a/include/linux/static_call.h
+++ b/include/linux/static_call.h
@@ -190,6 +190,14 @@ extern long __static_call_return0(void);
}; \
ARCH_DEFINE_STATIC_CALL_TRAMP(name, _func)
+#define DEFINE_STATIC_CALL_RO(name, _func) \
+ DECLARE_STATIC_CALL(name, _func); \
+ struct static_call_key __ro_after_init STATIC_CALL_KEY(name) = {\
+ .func = _func, \
+ .type = 1, \
+ }; \
+ ARCH_DEFINE_STATIC_CALL_TRAMP(name, _func)
+
#define DEFINE_STATIC_CALL_NULL(name, _func) \
DECLARE_STATIC_CALL(name, _func); \
struct static_call_key STATIC_CALL_KEY(name) = { \
@@ -198,6 +206,14 @@ extern long __static_call_return0(void);
}; \
ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name)
+#define DEFINE_STATIC_CALL_NULL_RO(name, _func) \
+ DECLARE_STATIC_CALL(name, _func); \
+ struct static_call_key __ro_after_init STATIC_CALL_KEY(name) = {\
+ .func = NULL, \
+ .type = 1, \
+ }; \
+ ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name)
+
#define DEFINE_STATIC_CALL_RET0(name, _func) \
DECLARE_STATIC_CALL(name, _func); \
struct static_call_key STATIC_CALL_KEY(name) = { \
--
2.47.0
next prev parent reply other threads:[~2024-11-27 4:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-27 4:47 [PATCH v2 0/3] objtool: noinstr validation for static branches/calls Josh Poimboeuf
2024-11-27 4:47 ` [PATCH v2 1/3] jump_label: Add annotations for validating noinstr usage Josh Poimboeuf
2024-11-27 4:47 ` Josh Poimboeuf [this message]
2024-11-27 4:47 ` [PATCH v2 3/3] objtool: Add noinstr validation for static branches/calls Josh Poimboeuf
2024-12-03 12:02 ` Valentin Schneider
2024-12-13 6:21 ` Josh Poimboeuf
2024-11-27 9:38 ` [PATCH v2 0/3] objtool: " Valentin Schneider
2024-11-28 1:35 ` Josh Poimboeuf
2024-12-03 12:00 ` Valentin Schneider
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=069be22d3643046173edbbe110218a9fd28a2e55.1732682344.git.jpoimboe@kernel.org \
--to=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®