Hacker News new | ask | show | jobs
by zippie 2893 days ago
This release of NetBSD disables eagerfpu on vulnerable FPU’s.

Often overlooked while discussing performance impact of context switching; context switching also applies to the FPU. There are two modes in which the OS performs FPU context switching: lazy and eager.

“lazy” FPU context switching leaves the previous context on the FPU until a different context gives it a set of instructions. This saves an unload on the FPU, since not all time splices require the FPU, you may see some performance gains under some application workloads.

“Eager” FPU context switching unloads FPU context whenever a time splice is finished. On a new time splice, the FPU context is reloaded. While this constant reloading of context sounds more expensive, it is optimized in hardware and almost never noticeable on modern architectures.

By default eager FPU is enabled in Linux. You can test its’ impact by passing the eagerfpu=on or eagerfpu=off boot flags (Linux).

Kudos to the NetBSD team for enabling/disabling eager FPU based on FPU model instead. This approach makes more sense to me.

2 comments

>This release of NetBSD disables eagerfpu.

Actually this release enables eagerfpu on all Intel CPUs, because of CVE-2018-3665 (lazyfpu side channel attack).

This is correct, thanks for fighting the disinformation!
Lazy FPU state restoration almost never makes sense on modern CPUs (regardless of security issues) because the cost of an interrupt for state restoration is so high and because "FPU" registers are used for a lot more than just FP calculations these days.