Skip to content

Commit 0f20807

Browse files
committed
x86/rust: support MITIGATION_SLS
Support the `MITIGATION_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 c239e09 commit 0f20807

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
@@ -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)