Skip to content

Commit c30eaf2

Browse files
committed
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: rust-lang/rust#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>
1 parent c670ecb commit c30eaf2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: scripts/generate_rust_target.rs

+8
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,14 @@ fn main() {
173173
features += ",+retpoline-indirect-branches";
174174
features += ",+retpoline-indirect-calls";
175175
}
176+
if cfg.has("MITIGATION_SLS") {
177+
// The kernel uses `-mharden-sls=all`, which Clang maps to both these target features in
178+
// `clang/lib/Driver/ToolChains/Arch/X86.cpp`. These should be eventually enabled via
179+
// `-Ctarget-feature` when `rustc` starts recognizing them (or via a new dedicated
180+
// flag); see https://github.com/rust-lang/rust/issues/116851.
181+
features += ",+harden-sls-ijmp";
182+
features += ",+harden-sls-ret";
183+
}
176184
ts.push("features", features);
177185
ts.push("llvm-target", "x86_64-linux-gnu");
178186
ts.push("target-pointer-width", "64");

0 commit comments

Comments
 (0)