-mno-sse -mno-sse2 -mno-mmx -mno-3dnow when compiling kernel

Peter Wemm peter at wemm.org
Thu Feb 17 13:49:31 PST 2005

On Sunday 13 February 2005 10:29 am, Thomas Krause -CI- wrote:
> Hello,
> why are the Switches "-mno-sse -mno-sse2 -mno-mmx -mno-3dnow" are set
> when compiling an amd64 kernel? I think, the CPU supports all thease
> features.
> I have no CPUTYPE specified in /etc/make.conf, as I could not
> find a matching option in /usr/src/share/examples/etc/make.conf.

For speed reasons, we restrict the kernel to using integer instructions 
only.  This means we can avoid the considerable expense of 
saving/restoring floating point context unnecessarily for syscalls, 
interrupts, etc.

On FreeBSD/i386, the compiler generally doesn't generate floating point 
instructions unless there is a reason to.  But on FreeBSD/amd64, the 
compiler will do it readily because things like MMX, SSE and SSE2 are 
*known* to exist on this family and are part of the function calling 
conventions, especially for things like varargs functions.

The upshot of this is that we are not in a lot of danger of the i386 
compiler accidently generating floating point code for the kernel, but 
on FreeBSD/amd64, it can and does if you give it the chance.

How the code for the kernel is generated has no bearing on the user code 
environment at all.  The floating point/mmx/sse/sse2 context is 
reserved entirely for the user.

Note that we *could* concievably set aside a few xmm registers for 
faster data copies inside the kernel, but we don't do it yet.  I 
believe linux makes %xmm0 and %xmm1 available in the kernel and saves 
them with every trap into kernel mode.
Peter Wemm - peter at wemm.org; peter at FreeBSD.org; peter at yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5

More information about the freebsd-amd64 mailing list