SSE register return with SSE disabled on AMD64
Chuck Swiger
cswiger at mac.com
Sun Sep 20 04:23:12 UTC 2009
On Sep 19, 2009, at 6:44 PM, Ryan Stone wrote:
> You must not use SSE or floating point operations in the kernel. The
> state of the floating point and SSE registers is *not* saved upon
> entry to the kernel. If the kernel executes SSE or floating point
> instructions it will corrupt the state of a userland program.
Unless you make an effort to save and restore the floating point/SSE
state-- which could be done for you automagically if the FreeBSD
kernel trapped floating point when/if you needed to use such in the
kernel (see sys/i386/i386/trap.c and http://en.wikipedia.org/wiki/Context_switch#Software_vs_hardware_context_switching
about TSS). It would add some extra latency to context switching--
supposedly around 2 microseconds for P3-grade hardware.
The recommendation for FreeBSD platform typically seems to be to use
integer fixed-point math instead or have a userland process in tight
communication with the kernel (via kqueue or maybe a socket like
divert(4) used by IPFW/dummynet) for handling heavy math-oriented
stuff which needed FP/MMX/SSE.
Regards,
--
-Chuck
More information about the freebsd-current
mailing list