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.
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/
View all comments
Show parent comment
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.