From: Ard Biesheuvel <ardb@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org,
Ard Biesheuvel <ardb@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Jason Baron <jbaron@akamai.com>,
Steven Rostedt <rostedt@goodmis.org>,
Mark Rutland <mark.rutland@arm.com>,
Kees Cook <keescook@chromium.org>
Subject: [RFC PATCH 7/7] static_call: add generic support for non-exported keys
Date: Tue, 9 Nov 2021 17:45:49 +0100 [thread overview]
Message-ID: <20211109164549.1724710-8-ardb@kernel.org> (raw)
In-Reply-To: <20211109164549.1724710-1-ardb@kernel.org>
The static_call feature where only the static call target is exposed to
modules while access to the key is withheld is only implemented for the
inline and out-of-line varieties, but not for the generic indirect call
based variety.
Let's use static_call_query() to obtain the call target address if the
key is not exported. Note that this means we can do the converse as
well, i.e., implement static_call_query() in terms of the key struct if
the key is exported, so we only need to export one of the two.
Note that this adds an additional load and potentially a direct call to
the instantiations of static_call residing in module code.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
include/linux/static_call.h | 4 ++--
include/linux/static_call_types.h | 3 +--
tools/include/linux/static_call_types.h | 3 +--
3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/include/linux/static_call.h b/include/linux/static_call.h
index 21929147879a..d88fd613f06d 100644
--- a/include/linux/static_call.h
+++ b/include/linux/static_call.h
@@ -302,8 +302,8 @@ static inline int static_call_text_reserved(void *start, void *end)
return 0;
}
-#define EXPORT_STATIC_CALL(name) EXPORT_SYMBOL(STATIC_CALL_KEY(name))
-#define EXPORT_STATIC_CALL_GPL(name) EXPORT_SYMBOL_GPL(STATIC_CALL_KEY(name))
+#define EXPORT_STATIC_CALL(name) EXPORT_STATIC_CALL_QUERY(name,)
+#define EXPORT_STATIC_CALL_GPL(name) EXPORT_STATIC_CALL_QUERY(name, _GPL)
#define EXPORT_STATIC_CALL_FOR_UPDATE(name) EXPORT_SYMBOL(STATIC_CALL_KEY(name))
#define EXPORT_STATIC_CALL_FOR_UPDATE_GPL(name) EXPORT_SYMBOL_GPL(STATIC_CALL_KEY(name))
diff --git a/include/linux/static_call_types.h b/include/linux/static_call_types.h
index eae11c5b015d..920828ad1d69 100644
--- a/include/linux/static_call_types.h
+++ b/include/linux/static_call_types.h
@@ -106,8 +106,7 @@ struct static_call_key {
void *func;
};
-#define static_call(name) \
- ((typeof(STATIC_CALL_QUERY(name)()))(STATIC_CALL_KEY(name).func))
+#define static_call(name) static_call_query(name)
#endif /* CONFIG_HAVE_STATIC_CALL */
diff --git a/tools/include/linux/static_call_types.h b/tools/include/linux/static_call_types.h
index eae11c5b015d..920828ad1d69 100644
--- a/tools/include/linux/static_call_types.h
+++ b/tools/include/linux/static_call_types.h
@@ -106,8 +106,7 @@ struct static_call_key {
void *func;
};
-#define static_call(name) \
- ((typeof(STATIC_CALL_QUERY(name)()))(STATIC_CALL_KEY(name).func))
+#define static_call(name) static_call_query(name)
#endif /* CONFIG_HAVE_STATIC_CALL */
--
2.30.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2021-11-09 16:50 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-09 16:45 [RFC PATCH 0/7] static call updates Ard Biesheuvel
2021-11-09 16:45 ` [RFC PATCH 1/7] static_call: get rid of static_call_cond() Ard Biesheuvel
2021-11-09 18:38 ` Peter Zijlstra
2021-11-09 18:41 ` Ard Biesheuvel
2021-11-09 19:22 ` Peter Zijlstra
2021-11-09 19:32 ` Peter Zijlstra
2021-11-09 16:45 ` [RFC PATCH 2/7] static_call: deal with unexported keys without cluttering up the API Ard Biesheuvel
2021-11-09 18:49 ` Peter Zijlstra
2021-11-09 18:53 ` Ard Biesheuvel
2021-11-09 19:41 ` Peter Zijlstra
2021-11-09 16:45 ` [RFC PATCH 3/7] static_call: use helper to access non-exported key Ard Biesheuvel
2021-11-09 18:53 ` Peter Zijlstra
2021-11-09 18:54 ` Ard Biesheuvel
2021-11-09 19:42 ` Peter Zijlstra
2021-11-09 19:45 ` Ard Biesheuvel
2021-11-09 16:45 ` [RFC PATCH 4/7] static_call: fix broken static_call_query() for non-exported keys Ard Biesheuvel
2021-11-09 18:56 ` Peter Zijlstra
2021-11-09 16:45 ` [RFC PATCH 5/7] static_call: use non-function types to refer to the trampolines Ard Biesheuvel
2021-11-09 16:45 ` [RFC PATCH 6/7] static_call: rename EXPORT_ macros to be more self-explanatory Ard Biesheuvel
2021-11-09 19:00 ` Peter Zijlstra
2021-11-09 19:03 ` Ard Biesheuvel
2021-11-09 16:45 ` Ard Biesheuvel [this message]
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=20211109164549.1724710-8-ardb@kernel.org \
--to=ardb@kernel.org \
--cc=jbaron@akamai.com \
--cc=jpoimboe@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
/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