Skip to content

Commit 84ea629

Browse files
ojedaintel-lab-lkp
authored andcommitted
x86/rust: support SLS
Support the `SLS` speculation mitigation by enabling the target features that Clang does. Without this, `objtool` would complain if enabled for individual object files (like it is planned in the future), e.g. rust/core.o: warning: objtool: _R...next_up+0x44: missing int3 after ret Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 0d59f60 commit 84ea629

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

scripts/generate_rust_target.rs

+8
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ fn main() {
165165
features += ",+retpoline-indirect-branches";
166166
features += ",+retpoline-indirect-calls";
167167
}
168+
if cfg.has("SLS") {
169+
// The kernel uses `-mharden-sls=all`, which Clang maps to both these target features in
170+
// `clang/lib/Driver/ToolChains/Arch/X86.cpp`. These should be eventually enabled via
171+
// `-Ctarget-feature` when `rustc` starts recognizing them (or via a new dedicated
172+
// flag); see https://github.com/rust-lang/rust/issues/116851.
173+
features += ",+harden-sls-ijmp";
174+
features += ",+harden-sls-ret";
175+
}
168176
ts.push("features", features);
169177
ts.push("llvm-target", "x86_64-linux-gnu");
170178
ts.push("target-pointer-width", "64");

0 commit comments

Comments
 (0)