summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMiguel Ojeda <ojeda@kernel.org>2024-07-25 20:33:21 +0200
committerMiguel Ojeda <ojeda@kernel.org>2024-08-18 23:34:37 +0200
commitfc582dfc1f20476cab9d43d0ee8ec0a6bfe13485 (patch)
treee828411671b9b82b80c0e3ff1681a522056c7833 /scripts
parentd7868550d5731e05148c881f035423f009a2b4d5 (diff)
downloadlinux-fc582dfc1f20476cab9d43d0ee8ec0a6bfe13485.tar.gz
linux-fc582dfc1f20476cab9d43d0ee8ec0a6bfe13485.tar.bz2
linux-fc582dfc1f20476cab9d43d0ee8ec0a6bfe13485.zip
x86/rust: support MITIGATION_SLS
Support `MITIGATION_SLS` by enabling the target features that Clang does. Without this, `objtool` would complain if enabled for Rust, e.g.: rust/core.o: warning: objtool: _R...next_up+0x44: missing int3 after ret These should be eventually enabled via `-Ctarget-feature` when `rustc` starts recognizing them (or via a new dedicated flag) [1]. Link: https://github.com/rust-lang/rust/issues/116851 [1] Reviewed-by: Gary Guo <gary@garyguo.net> Tested-by: Alice Ryhl <aliceryhl@google.com> Tested-by: Benno Lossin <benno.lossin@proton.me> Link: https://lore.kernel.org/r/20240725183325.122827-5-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/generate_rust_target.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target.rs
index 836fdf622c2d..863720777313 100644
--- a/scripts/generate_rust_target.rs
+++ b/scripts/generate_rust_target.rs
@@ -173,6 +173,14 @@ fn main() {
features += ",+retpoline-indirect-branches";
features += ",+retpoline-indirect-calls";
}
+ if cfg.has("MITIGATION_SLS") {
+ // The kernel uses `-mharden-sls=all`, which Clang maps to both these target features in
+ // `clang/lib/Driver/ToolChains/Arch/X86.cpp`. These should be eventually enabled via
+ // `-Ctarget-feature` when `rustc` starts recognizing them (or via a new dedicated
+ // flag); see https://github.com/rust-lang/rust/issues/116851.
+ features += ",+harden-sls-ijmp";
+ features += ",+harden-sls-ret";
+ }
ts.push("features", features);
ts.push("llvm-target", "x86_64-linux-gnu");
ts.push("target-pointer-width", "64");