arch/x86/Makefile | 7 ++++++- rust/Makefile | 22 ++++++++++++-------- rust/macros/module.rs | 12 +++++++++++ scripts/Makefile.build | 9 +++++++-- scripts/generate_rust_target.rs | 15 ++++++++++++++ tools/objtool/check.c | 36 ++++++++++++++++++++++++++++++++- tools/objtool/noreturns.h | 2 ++ 7 files changed, 91 insertions(+), 12 deletions(-)
Hi,
This is an updated series to the CPU mitigations support for Rust. It
also has the patch to enable `objtool`, so that we can start running it
for Rust.
It would be nice to get this applied soon, so that we start being
warning-free (since we already get warnings under IBT builds via
`vmlinux.o`). I am happy to take it through the Rust tree if the x86 and
objtool maintainers give an Acked-by, or through any of the other trees,
as you prefer. Otherwise, I think at this point we would need to make
Rust exclusive to the mitigations, which isn't great.
With this series, again, x86_64 is warning-free with `objtool` enabled. I
tested `-O2`/`-Os` and the Rust versions we support under `-O2` (mainly
for the `noreturn` patch, which uses heuristics), as well as IBT vs. no
IBT (i.e. running on individual object files vs. in `vmlinux`). I also
did an arm64 build.
Testing is very welcome for this one!
Cheers,
Miguel
v2:
- Add patch to enable `objtool` for Rust.
- Add patch to list `noreturn` Rust functions (via heuristics) to avoid
warnings related to that.
- Make the `RETHUNK` patch not an RFC since the Rust compiler has
support for
it now.
- Update the names of the migitation config symbols, given the changes
at e.g.
commit 7b75782ffd82 ("x86/bugs: Rename CONFIG_MITIGATION_SLS =>
CONFIG_MITIGATION_SLS").
Miguel Ojeda (6):
rust: module: add static pointer to `{init,cleanup}_module()`
x86/rust: support MITIGATION_RETPOLINE
x86/rust: support MITIGATION_RETHUNK
x86/rust: support MITIGATION_SLS
objtool: list `noreturn` Rust functions
objtool/kbuild/rust: enable objtool for Rust
arch/x86/Makefile | 7 ++++++-
rust/Makefile | 22 ++++++++++++--------
rust/macros/module.rs | 12 +++++++++++
scripts/Makefile.build | 9 +++++++--
scripts/generate_rust_target.rs | 15 ++++++++++++++
tools/objtool/check.c | 36 ++++++++++++++++++++++++++++++++-
tools/objtool/noreturns.h | 2 ++
7 files changed, 91 insertions(+), 12 deletions(-)
base-commit: b1263411112305acf2af728728591465becb45b0
--
2.45.2
On Wed, Jul 24, 2024 at 6:15 PM Miguel Ojeda <ojeda@kernel.org> wrote: > > Hi, > > This is an updated series to the CPU mitigations support for Rust. It > also has the patch to enable `objtool`, so that we can start running it > for Rust. > > It would be nice to get this applied soon, so that we start being > warning-free (since we already get warnings under IBT builds via > `vmlinux.o`). I am happy to take it through the Rust tree if the x86 and > objtool maintainers give an Acked-by, or through any of the other trees, > as you prefer. Otherwise, I think at this point we would need to make > Rust exclusive to the mitigations, which isn't great. > > With this series, again, x86_64 is warning-free with `objtool` enabled. I > tested `-O2`/`-Os` and the Rust versions we support under `-O2` (mainly > for the `noreturn` patch, which uses heuristics), as well as IBT vs. no > IBT (i.e. running on individual object files vs. in `vmlinux`). I also > did an arm64 build. > > Testing is very welcome for this one! Verified that this eliminates the relevant warnings in an x86 build of the android-mainline kernel. Tested-by: Alice Ryhl <aliceryhl@google.com>
On Wed, Jul 24, 2024 at 06:14:53PM +0200, Miguel Ojeda wrote: > Hi, > > This is an updated series to the CPU mitigations support for Rust. It > also has the patch to enable `objtool`, so that we can start running it > for Rust. > > It would be nice to get this applied soon, so that we start being > warning-free (since we already get warnings under IBT builds via > `vmlinux.o`). I am happy to take it through the Rust tree if the x86 and > objtool maintainers give an Acked-by, or through any of the other trees, > as you prefer. Otherwise, I think at this point we would need to make > Rust exclusive to the mitigations, which isn't great. > > With this series, again, x86_64 is warning-free with `objtool` enabled. I > tested `-O2`/`-Os` and the Rust versions we support under `-O2` (mainly > for the `noreturn` patch, which uses heuristics), as well as IBT vs. no > IBT (i.e. running on individual object files vs. in `vmlinux`). I also > did an arm64 build. W00t :-) Aside from a small niggle about maybe doing a helper function for those Rust runtime things, I don't see anything objectionable here. Thanks!
On Thu, Jul 25, 2024 at 10:38 AM Peter Zijlstra <peterz@infradead.org> wrote: > > W00t :-) > > Aside from a small niggle about maybe doing a helper function for those > Rust runtime things, I don't see anything objectionable here. > > Thanks! Thanks for taking a look that quick, Peter, I appreciate it. Happy to move that to a helper. Cheers, Miguel
On 24.07.24 18:14, Miguel Ojeda wrote:
> Hi,
>
> This is an updated series to the CPU mitigations support for Rust. It
> also has the patch to enable `objtool`, so that we can start running it
> for Rust.
>
> It would be nice to get this applied soon, so that we start being
> warning-free (since we already get warnings under IBT builds via
> `vmlinux.o`). I am happy to take it through the Rust tree if the x86 and
> objtool maintainers give an Acked-by, or through any of the other trees,
> as you prefer. Otherwise, I think at this point we would need to make
> Rust exclusive to the mitigations, which isn't great.
>
> With this series, again, x86_64 is warning-free with `objtool` enabled. I
> tested `-O2`/`-Os` and the Rust versions we support under `-O2` (mainly
> for the `noreturn` patch, which uses heuristics), as well as IBT vs. no
> IBT (i.e. running on individual object files vs. in `vmlinux`). I also
> did an arm64 build.
>
> Testing is very welcome for this one!
>
> Cheers,
> Miguel
>
> v2:
> - Add patch to enable `objtool` for Rust.
>
> - Add patch to list `noreturn` Rust functions (via heuristics) to avoid
> warnings related to that.
>
> - Make the `RETHUNK` patch not an RFC since the Rust compiler has
> support for
> it now.
>
> - Update the names of the migitation config symbols, given the changes
> at e.g.
> commit 7b75782ffd82 ("x86/bugs: Rename CONFIG_MITIGATION_SLS =>
> CONFIG_MITIGATION_SLS").
>
> Miguel Ojeda (6):
> rust: module: add static pointer to `{init,cleanup}_module()`
> x86/rust: support MITIGATION_RETPOLINE
> x86/rust: support MITIGATION_RETHUNK
> x86/rust: support MITIGATION_SLS
> objtool: list `noreturn` Rust functions
> objtool/kbuild/rust: enable objtool for Rust
>
> arch/x86/Makefile | 7 ++++++-
> rust/Makefile | 22 ++++++++++++--------
> rust/macros/module.rs | 12 +++++++++++
> scripts/Makefile.build | 9 +++++++--
> scripts/generate_rust_target.rs | 15 ++++++++++++++
> tools/objtool/check.c | 36 ++++++++++++++++++++++++++++++++-
> tools/objtool/noreturns.h | 2 ++
> 7 files changed, 91 insertions(+), 12 deletions(-)
>
>
> base-commit: b1263411112305acf2af728728591465becb45b0
> --
> 2.45.2
>
I tested this series with a config that produces the objtool warnings on
b126341 and it worked flawlessly. I also tried `-O2` and `-Os`:
Tested-by: Benno Lossin <benno.lossin@proton.me>
---
Cheers,
Benno
© 2016 - 2025 Red Hat, Inc.