Re: [PATCH v3] arm: rust: Enable Rust support for ARMv7
From: Alice Ryhl
Date: Wed Feb 05 2025 - 08:18:44 EST
On Wed, Feb 5, 2025 at 2:12 PM Miguel Ojeda
<miguel.ojeda.sandonis@xxxxxxxxx> wrote:
>
> On Fri, Jan 31, 2025 at 5:05 PM Andrew Lunn <andrew@xxxxxxx> wrote:
> >
> > Floating point is banned within the kernel, except for in very narrow
> > conditions, because the floating point registers are lazy saved on
> > context switch. If the kernel uses the floating point registers, you
> > can break user space in bad ways.
> >
> > I expect this has been discussed, since it is well known kernel
> > restriction. Maybe go see what happened to that discussion within RfL?
>
> Yeah, it has been discussed, including in the last couple weeks in the
> Rust Zulip due to the upcoming move to the aarch64 `softfloat` target
> (the disallowing of disabling `neon` in the hardfloat one).
>
> Ideally, I think upstream Rust could perhaps give us a way to do
> something like `-mgeneral-regs-only` or `-march=...+nofp` (in the form
> GCC does it, i.e. a hard error if one even tries to use the floating
> point types even within a function implementation, not just in
> interfaces like in Clang), i.e. a way to avoid unintended use of
> floating point facilities:
>
> https://godbolt.org/z/o1E5nrrzc
>
> Currently it is unclear what form that could take (e.g. whether a
> `-nofloat` target could be possible, "disabling" the `f*` types, just
> Clippy...).
Seems like we already have a warning for it:
warning: floating-point arithmetic detected
--> /home/aliceryhl/rust-for-linux/rust/kernel/lib.rs:89:5
|
89 | a + b
| ^^^^^
|
= help: for further information visit
https://rust-lang.github.io/rust-clippy/master/index.html#float_arithmetic
= note: requested on the command line with `-W clippy::float-arithmetic`
> Cc'ing Catalin in case he wants to be in the loop, since I discussed
> it with him recently.
>
> Cheers,
> Miguel