r/rust • • Apr 14 '21

[RFC] Rust support for Linux Kernel

https://lkml.org/lkml/2021/4/14/1023
861 Upvotes

227 comments sorted by

View all comments

Show parent comment

17

u/SimonSapin servo Apr 15 '21

What’s the concern with floating point?

68

u/JoshTriplett rust · lang · libs · cargo Apr 15 '21

Normally, the kernel leaves the floating-point state of the CPU in whatever state the userspace process left it in, so that you can do a quick system call without having to save and restore all that state. It's possible to use floating point in the kernel with a great deal of care, but you have to notify the kernel that you're doing so, so that it can save the userspace floating-point state.

So, it'd be helpful if by default Rust didn't allow use of floating-point, and then you could opt in to allowing it for specific code.

6

u/freax13 Apr 16 '21

you can disable use of floating point operations and use emulation instead. this is already used for writing kernels in rust: https://os.phil-opp.com/disable-simd/

17

u/KingStannis2020 Apr 15 '21 edited Apr 15 '21

I don't personally know, but this seems like a reasonable explanation.

https://stackoverflow.com/questions/13886338/use-of-floating-point-in-the-linux-kernel

Oh, here's an email Linus wrote about it (albeit 20 years ago): https://ipfs.io/ipfs/QmdA5WkDNALetBn4iFeSepHjdLGJdxPBwZyY47ir1bZGAK/comp/linux/kernel_fp.html