From: "tip-bot2 for Kees Cook" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Kees Cook <keescook@chromium.org>,
Thomas Gleixner <tglx@linutronix.de>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/entry] jump_label: Provide CONFIG-driven build state defaults
Date: Thu, 08 Apr 2021 12:13:42 -0000 [thread overview]
Message-ID: <161788402204.29796.3718117807122564028.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20210401232347.2791257-2-keescook@chromium.org>
The following commit has been merged into the x86/entry branch of tip:
Commit-ID: 0d66ccc1627013c95f1e7ef10b95b8451cd7834e
Gitweb: https://git.kernel.org/tip/0d66ccc1627013c95f1e7ef10b95b8451cd7834e
Author: Kees Cook <keescook@chromium.org>
AuthorDate: Thu, 01 Apr 2021 16:23:42 -07:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Thu, 08 Apr 2021 14:05:19 +02:00
jump_label: Provide CONFIG-driven build state defaults
As shown in the comment in jump_label.h, choosing the initial state of
static branches changes the assembly layout. If the condition is expected
to be likely it's inline, and if unlikely it is out of line via a jump.
A few places in the kernel use (or could be using) a CONFIG to choose the
default state, which would give a small performance benefit to their
compile-time declared default. Provide the infrastructure to do this.
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20210401232347.2791257-2-keescook@chromium.org
---
include/linux/jump_label.h | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index d926912..05f5554 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -382,6 +382,21 @@ struct static_key_false {
[0 ... (count) - 1] = STATIC_KEY_FALSE_INIT, \
}
+#define _DEFINE_STATIC_KEY_1(name) DEFINE_STATIC_KEY_TRUE(name)
+#define _DEFINE_STATIC_KEY_0(name) DEFINE_STATIC_KEY_FALSE(name)
+#define DEFINE_STATIC_KEY_MAYBE(cfg, name) \
+ __PASTE(_DEFINE_STATIC_KEY_, IS_ENABLED(cfg))(name)
+
+#define _DEFINE_STATIC_KEY_RO_1(name) DEFINE_STATIC_KEY_TRUE_RO(name)
+#define _DEFINE_STATIC_KEY_RO_0(name) DEFINE_STATIC_KEY_FALSE_RO(name)
+#define DEFINE_STATIC_KEY_MAYBE_RO(cfg, name) \
+ __PASTE(_DEFINE_STATIC_KEY_RO_, IS_ENABLED(cfg))(name)
+
+#define _DECLARE_STATIC_KEY_1(name) DECLARE_STATIC_KEY_TRUE(name)
+#define _DECLARE_STATIC_KEY_0(name) DECLARE_STATIC_KEY_FALSE(name)
+#define DECLARE_STATIC_KEY_MAYBE(cfg, name) \
+ __PASTE(_DECLARE_STATIC_KEY_, IS_ENABLED(cfg))(name)
+
extern bool ____wrong_branch_error(void);
#define static_key_enabled(x) \
@@ -482,6 +497,10 @@ extern bool ____wrong_branch_error(void);
#endif /* CONFIG_JUMP_LABEL */
+#define static_branch_maybe(config, x) \
+ (IS_ENABLED(config) ? static_branch_likely(x) \
+ : static_branch_unlikely(x))
+
/*
* Advanced usage; refcount, branch is enabled when: count != 0
*/
next prev parent reply other threads:[~2021-04-08 12:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-01 23:23 [PATCH v10 0/6] Optionally randomize kernel stack offset each syscall Kees Cook
2021-04-01 23:23 ` [PATCH v10 1/6] jump_label: Provide CONFIG-driven build state defaults Kees Cook
2021-04-08 12:13 ` tip-bot2 for Kees Cook [this message]
2021-04-01 23:23 ` [PATCH v10 2/6] init_on_alloc: Optimize static branches Kees Cook
2021-04-08 12:13 ` [tip: x86/entry] " tip-bot2 for Kees Cook
2021-04-01 23:23 ` [PATCH v10 3/6] stack: Optionally randomize kernel stack offset each syscall Kees Cook
2021-04-07 21:37 ` Will Deacon
2021-04-08 12:13 ` [tip: x86/entry] " tip-bot2 for Kees Cook
2021-04-01 23:23 ` [PATCH v10 4/6] x86/entry: Enable random_kstack_offset support Kees Cook
2021-04-08 12:13 ` [tip: x86/entry] " tip-bot2 for Kees Cook
2021-04-01 23:23 ` [PATCH v10 5/6] arm64: entry: " Kees Cook
2021-04-07 21:35 ` Will Deacon
2021-04-08 12:13 ` [tip: x86/entry] " tip-bot2 for Kees Cook
2021-04-01 23:23 ` [PATCH v10 6/6] lkdtm: Add REPORT_STACK for checking stack offsets Kees Cook
2021-04-08 12:13 ` [tip: x86/entry] " tip-bot2 for Kees Cook
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=161788402204.29796.3718117807122564028.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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
all inboxes | Powered by JetHome®