Re: [PATCH v3 0/6] Rust: support `CPU_MITIGATIONS` and enable `objtool`

From: Miguel Ojeda
Date: Sun Aug 18 2024 - 17:34:21 EST


On Thu, Jul 25, 2024 at 8:35 PM Miguel Ojeda <ojeda@xxxxxxxxxx> wrote:
>
> 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/rust: 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 | 48 ++++++++++++++++++++++++++++++++-
> tools/objtool/noreturns.h | 2 ++
> 7 files changed, 103 insertions(+), 12 deletions(-)

Applied to `rust-next` -- thanks everyone!

In the `noreturn` patch:

[ Kees agrees this should be automated and Peter says:

So it would be fairly simple to make objtool consume a magic section
emitted by the compiler.. I think we've asked the compiler folks
for that at some point even, but I don't have clear recollections.

We will ask upstream Rust about it. And if they agree, then perhaps
we can get Clang/GCC to implement something similar too -- for this
sort of thing we can take advantage of the shorter cycles of `rustc`
as well as their unstable features concept to experiment.

Gary proposed using DWARF (though it would need to be available), and
wrote a proof of concept script using the `object` and `gimli` crates:
https://gist.github.com/nbdd0121/449692570622c2f46a29ad9f47c3379a

- Miguel ]

[ Added `len_mismatch_fail` symbol for new `kernel` crate code merged
since then as well as 3 more `core::panicking` symbols that appear
in `RUST_DEBUG_ASSERTIONS=y` builds. - Miguel ]

Cheers,
Miguel