Re: SSE register return with SSE disabled on AMD64

[ Available lists | Index of freebsd-current | Month of Sep 2009 | Week of 20 Sep 2009 | Raw email | View thread | Wrap long lines | Reply | Tag ]
From
Chuck Swiger <cswiger@mac.com>
Date
20 Sep 2009 04:23:12
Subject
Re: SSE register return with SSE disabled on AMD64
Message-ID
F28C7C66-0A31-4745-BAEC-66406C393D78@mac.com

In reply to

[ Hide this part ]
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



Elapsed time: 0.141 seconds