mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-31 14:23:49 +01:00
x86/rust: support MITIGATION_RETHUNK
The Rust compiler added support for `-Zfunction-return=thunk-extern` [1]
in 1.76.0 [2], i.e. the equivalent of `-mfunction-return=thunk-extern`.
Thus add support for `MITIGATION_RETHUNK`.
Without this, `objtool` would warn if enabled for Rust and already warns
under IBT builds, e.g.:
samples/rust/rust_print.o: warning: objtool:
_R...init+0xa5c: 'naked' return found in RETHUNK build
Link: https://github.com/rust-lang/rust/issues/116853 [1]
Link: https://github.com/rust-lang/rust/pull/116892 [2]
Reviewed-by: Gary Guo <[email protected]>
Tested-by: Alice Ryhl <[email protected]>
Tested-by: Benno Lossin <[email protected]>
Reviewed-by: Thomas Gleixner <[email protected]>
Link: https://github.com/Rust-for-Linux/linux/issues/945
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Miguel Ojeda <[email protected]>
This commit is contained in:
1 parent
284a3ac4a9
commit
d7868550d5
1 file changed
+5
@@ -24,11 +24,15 @@ RETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch-cs-prefix)
|
||||
|
||||
ifdef CONFIG_MITIGATION_RETHUNK
|
||||
RETHUNK_CFLAGS := -mfunction-return=thunk-extern
|
||||
RETHUNK_RUSTFLAGS := -Zfunction-return=thunk-extern
|
||||
RETPOLINE_CFLAGS += $(RETHUNK_CFLAGS)
|
||||
RETPOLINE_RUSTFLAGS += $(RETHUNK_RUSTFLAGS)
|
||||
endif
|
||||
|
||||
export RETHUNK_CFLAGS
|
||||
export RETHUNK_RUSTFLAGS
|
||||
export RETPOLINE_CFLAGS
|
||||
export RETPOLINE_RUSTFLAGS
|
||||
export RETPOLINE_VDSO_CFLAGS
|
||||
|
||||
# For gcc stack alignment is specified with -mpreferred-stack-boundary,
|
||||
@@ -218,6 +222,7 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
|
||||
# Avoid indirect branches in kernel to deal with Spectre
|
||||
ifdef CONFIG_MITIGATION_RETPOLINE
|
||||
KBUILD_CFLAGS += $(RETPOLINE_CFLAGS)
|
||||
KBUILD_RUSTFLAGS += $(RETPOLINE_RUSTFLAGS)
|
||||
# Additionally, avoid generating expensive indirect jumps which
|
||||
# are subject to retpolines for small number of switch cases.
|
||||
# LLVM turns off jump table generation by default when under
|
||||
|
||||
Reference in new issue
Block a user