From: "tip-bot2 for Peter Zijlstra" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: David Kaplan <David.Kaplan@amd.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Andrew Cooper <andrew.cooper3@citrix.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/urgent] x86/ibt: Suppress spurious ENDBR
Date: Tue, 12 Sep 2023 11:08:32 -0000 [thread overview]
Message-ID: <169451691250.27769.12189082412488879527.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20230802110323.016197440@infradead.org>
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 70524a25365bab3dfe968691aa436fff765a8dde
Gitweb: https://git.kernel.org/tip/70524a25365bab3dfe968691aa436fff765a8dde
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Wed, 02 Aug 2023 12:55:46 +02:00
Committer: root <root@noisy.programming.kicks-ass.net>
CommitterDate: Tue, 12 Sep 2023 12:40:28 +02:00
x86/ibt: Suppress spurious ENDBR
It was reported that under certain circumstances GCC emits ENDBR
instructions for _THIS_IP_ usage. Specifically, when it appears at the
start of a basic block -- but not elsewhere.
Since _THIS_IP_ is never used for control flow, these ENDBR
instructions are completely superfluous. Override the _THIS_IP_
definition for x86_64 to avoid this.
Less ENDBR instructions is better.
Fixes: 156ff4a544ae ("x86/ibt: Base IBT bits")
Reported-by: David Kaplan <David.Kaplan@amd.com>
Signed-off-by: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20230802110323.016197440@infradead.org
---
arch/x86/include/asm/linkage.h | 8 ++++++++
include/linux/instruction_pointer.h | 5 +++++
2 files changed, 13 insertions(+)
diff --git a/arch/x86/include/asm/linkage.h b/arch/x86/include/asm/linkage.h
index 97a3de7..5ff49fd 100644
--- a/arch/x86/include/asm/linkage.h
+++ b/arch/x86/include/asm/linkage.h
@@ -8,6 +8,14 @@
#undef notrace
#define notrace __attribute__((no_instrument_function))
+#ifdef CONFIG_64BIT
+/*
+ * The generic version tends to create spurious ENDBR instructions under
+ * certain conditions.
+ */
+#define _THIS_IP_ ({ unsigned long __here; asm ("lea 0(%%rip), %0" : "=r" (__here)); __here; })
+#endif
+
#ifdef CONFIG_X86_32
#define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0)))
#endif /* CONFIG_X86_32 */
diff --git a/include/linux/instruction_pointer.h b/include/linux/instruction_pointer.h
index cda1f70..aa0b3ff 100644
--- a/include/linux/instruction_pointer.h
+++ b/include/linux/instruction_pointer.h
@@ -2,7 +2,12 @@
#ifndef _LINUX_INSTRUCTION_POINTER_H
#define _LINUX_INSTRUCTION_POINTER_H
+#include <asm/linkage.h>
+
#define _RET_IP_ (unsigned long)__builtin_return_address(0)
+
+#ifndef _THIS_IP_
#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
+#endif
#endif /* _LINUX_INSTRUCTION_POINTER_H */
next prev parent reply other threads:[~2023-09-12 11:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 10:55 [PATCH 0/2] x86/ibt: Fix some spurious ENDBR instances Peter Zijlstra
2023-08-02 10:55 ` [PATCH 1/2] x86/ibt: Suppress spurious ENDBR Peter Zijlstra
2023-09-12 11:08 ` tip-bot2 for Peter Zijlstra [this message]
2023-09-12 15:54 ` [tip: x86/urgent] " tip-bot2 for Peter Zijlstra
2023-08-02 10:55 ` [PATCH 2/2] x86/ibt: Avoid duplicate ENDBR in __put_user_nocheck*() Peter Zijlstra
2023-08-02 20:33 ` Peter Zijlstra
2023-09-12 11:08 ` [tip: x86/urgent] " tip-bot2 for Peter Zijlstra
2023-09-12 15:54 ` tip-bot2 for Peter Zijlstra
2023-08-02 11:25 ` [PATCH 0/2] x86/ibt: Fix some spurious ENDBR instances andrew.cooper3
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=169451691250.27769.12189082412488879527.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=David.Kaplan@amd.com \
--cc=andrew.cooper3@citrix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=peterz@infradead.org \
--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®