Re: [PATCH v3] arm: rust: Enable Rust support for ARMv7

From: Miguel Ojeda
Date: Wed Feb 05 2025 - 08:18:18 EST


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

Cc'ing Catalin in case he wants to be in the loop, since I discussed
it with him recently.

Cheers,
Miguel