From owner-freebsd-current@FreeBSD.ORG Sun Sep 20 04:23:12 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7566F106568D for ; Sun, 20 Sep 2009 04:23:12 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from asmtpout015.mac.com (asmtpout015.mac.com [17.148.16.90]) by mx1.freebsd.org (Postfix) with ESMTP id 5EF4E8FC14 for ; Sun, 20 Sep 2009 04:23:12 +0000 (UTC) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Received: from [17.151.87.7] by asmtp015.mac.com (Sun Java(tm) System Messaging Server 6.3-8.01 (built Dec 16 2008; 32bit)) with ESMTPSA id <0KQ900LED5INK840@asmtp015.mac.com>; Sat, 19 Sep 2009 21:23:12 -0700 (PDT) Message-id: From: Chuck Swiger To: Ryan Stone In-reply-to: Date: Sat, 19 Sep 2009 21:23:11 -0700 References: <507613.41733.qm@web63907.mail.re1.yahoo.com> X-Mailer: Apple Mail (2.936) Cc: Barney Cordoba , freebsd-current@freebsd.org, Ivan Voras Subject: Re: SSE register return with SSE disabled on AMD64 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Sep 2009 04:23:12 -0000 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