0

I'm new to Kernel coding and have been going through the LINUX DEVICE DRIVERS book.

Here's an excerpt from the book:

Kernel code cannot do floating point arithmetic. Enabling floating point would require that the kernel save and restore the floating point processor’s state on each entry to, and exit from, kernel space—at least, on some architectures. Given that there really is no need for floating point in kernel code, the extra overhead is not worthwhile.

The first line kinda implies that context switching in kernel modules do not include code to store the FP context as a general rule of thumb. However, I tried running a few floating point assembly instructions in my kernel module and it seemed to work. Wouldn't this result in incorrect results for concurrently running processes that use floating point registers?

  • 1
    Right, it doesn't fault, it corrupts the FPU state for user-space processes, unless you tell the kernel to save/restore the state around your in-kernel use of the FPU. – Peter Cordes Aug 06 '23 at 14:09

0 Answers0