rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Maurer <mmaurer@google.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	 Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org,  Miguel Ojeda <ojeda@kernel.org>,
	Alex Gaynor <alex.gaynor@gmail.com>,
	 Wedson Almeida Filho <wedsonaf@gmail.com>
Cc: "Matthew Maurer" <mmaurer@google.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Andreas Hindborg" <a.hindborg@samsung.com>,
	"Alice Ryhl" <aliceryhl@google.com>,
	linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org
Subject: [PATCH] x86: rust: Disable entry padding with Rust
Date: Fri, 15 Dec 2023 19:39:57 +0000	[thread overview]
Message-ID: <20231215194828.2611213-1-mmaurer@google.com> (raw)

rustc-1.73.0 used by Linux does not support entry padding. Mark entry
padding support as explicitly incompatible with Rust.

Signed-off-by: Matthew Maurer <mmaurer@google.com>
---

This is temporary - upstream in the Rust compiler, I have:

* A MCP[1] to enable the feature as an unstable flag
* A RFC[2] to stabilize it and add the attribute
* An initial implementation[3] for the MCP and RFC once accepted

Once at least unstable support is merged, we can detect this in a future
patch.

Even once those are merged and Linux is using a newer rustc, we will
still want a separate HAVE_ENTRY_PADDING config, as Rust's gcc backend
will not initially support it.

While this is a temporary patch, I still think it's worth carrying
because it prevents us from selecting build configurations that will
fail at runtime.

[1]: https://github.com/rust-lang/compiler-team/issues/704
[2]: https://github.com/rust-lang/rfcs/pull/3543
[3]: https://github.com/maurer/rust/tree/patchable-function-entries
 arch/x86/Kconfig | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 18b9fb7df95b..a9d48709f7db 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2452,6 +2452,9 @@ config CC_HAS_RETURN_THUNK
 config CC_HAS_ENTRY_PADDING
 	def_bool $(cc-option,-fpatchable-function-entry=16,16)
 
+config HAVE_ENTRY_PADDING
+	def_bool CC_HAS_ENTRY_PADDING && !RUST
+
 config FUNCTION_PADDING_CFI
 	int
 	default 59 if FUNCTION_ALIGNMENT_64B
@@ -2469,17 +2472,17 @@ config FUNCTION_PADDING_BYTES
 
 config CALL_PADDING
 	def_bool n
-	depends on CC_HAS_ENTRY_PADDING && OBJTOOL
+	depends on HAVE_ENTRY_PADDING && OBJTOOL
 	select FUNCTION_ALIGNMENT_16B
 
 config FINEIBT
 	def_bool y
-	depends on X86_KERNEL_IBT && CFI_CLANG && RETPOLINE
+	depends on X86_KERNEL_IBT && CFI_CLANG && RETPOLINE && HAVE_ENTRY_PADDING
 	select CALL_PADDING
 
 config HAVE_CALL_THUNKS
 	def_bool y
-	depends on CC_HAS_ENTRY_PADDING && RETHUNK && OBJTOOL
+	depends on HAVE_ENTRY_PADDING && RETHUNK && OBJTOOL
 
 config CALL_THUNKS
 	def_bool n
-- 
2.43.0.472.g3155946c3a-goog


             reply	other threads:[~2023-12-15 19:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-15 19:39 Matthew Maurer [this message]
2023-12-16 14:09 ` [PATCH] x86: rust: Disable entry padding with Rust Martin Rodriguez Reboredo
2024-01-04  9:38 ` Alice Ryhl
2024-01-28 17:48 ` Miguel Ojeda
2024-01-30 23:46   ` Dave Hansen
2024-01-30 23:53     ` Miguel Ojeda
2024-01-30 23:54     ` Matthew Maurer
2024-01-31 20:31 ` Dave Hansen
2024-02-03 13:35   ` Miguel Ojeda

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=20231215194828.2611213-1-mmaurer@google.com \
    --to=mmaurer@google.com \
    --cc=a.hindborg@samsung.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=gary@garyguo.net \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wedsonaf@gmail.com \
    --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;
as well as URLs for NNTP newsgroup(s).