Re: SSE register return with SSE disabled on AMD64

From: Chuck Swiger <cswiger_at_mac.com>
Date: Sat, 19 Sep 2009 21:23:11 -0700
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
Received on Sun Sep 20 2009 - 02:23:12 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:55 UTC