Date: Sat, 19 Sep 2009 21:23:11 -0700 From: Chuck Swiger <cswiger@mac.com> To: Ryan Stone <rysto32@gmail.com> Cc: Barney Cordoba <barney_cordoba@yahoo.com>, freebsd-current@freebsd.org, Ivan Voras <ivoras@freebsd.org> Subject: Re: SSE register return with SSE disabled on AMD64 Message-ID: <F28C7C66-0A31-4745-BAEC-66406C393D78@mac.com> In-Reply-To: <bc2d970909191844l6c61ba18hbdac20edad5be94e@mail.gmail.com> References: <h93ga5$frd$1@ger.gmane.org> <507613.41733.qm@web63907.mail.re1.yahoo.com> <bc2d970909191844l6c61ba18hbdac20edad5be94e@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F28C7C66-0A31-4745-BAEC-66406C393D78>