From owner-svn-src-head@FreeBSD.ORG Wed Mar 25 22:08:31 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 44A041065670; Wed, 25 Mar 2009 22:08:31 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 184028FC1D; Wed, 25 Mar 2009 22:08:31 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2PM8UBH090770; Wed, 25 Mar 2009 22:08:30 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2PM8Uwj090768; Wed, 25 Mar 2009 22:08:30 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200903252208.n2PM8Uwj090768@svn.freebsd.org> From: John Baldwin Date: Wed, 25 Mar 2009 22:08:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190426 - in head/sys: amd64/amd64 i386/isa X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Mar 2009 22:08:31 -0000 Author: jhb Date: Wed Mar 25 22:08:30 2009 New Revision: 190426 URL: http://svn.freebsd.org/changeset/base/190426 Log: Fix a few nits in the earlier changes to prevent local information leakage in AMD FPUs: - Do not clear the affected state in the case that the FPU registers for the thread that already owns the FPU are changed via fpu_setregs(). The only local information the thread would see is its own state in that case. - Fix a type mismatch for the dummy variable used in a "fld". It accepts a float, not a double. Reviewed by: bde Approved by: so (cperciva) MFC after: 1 month Modified: head/sys/amd64/amd64/fpu.c head/sys/i386/isa/npx.c Modified: head/sys/amd64/amd64/fpu.c ============================================================================== --- head/sys/amd64/amd64/fpu.c Wed Mar 25 21:20:15 2009 (r190425) +++ head/sys/amd64/amd64/fpu.c Wed Mar 25 22:08:30 2009 (r190426) @@ -480,7 +480,6 @@ fpusetregs(struct thread *td, struct sav s = intr_disable(); if (td == PCPU_GET(fpcurthread)) { - fpu_clean_state(); fxrstor(addr); intr_restore(s); } else { @@ -499,10 +498,10 @@ fpusetregs(struct thread *td, struct sav * In order to avoid leaking this information across processes, we clean * these values by performing a dummy load before executing fxrstor(). */ -static double dummy_variable = 0.0; static void fpu_clean_state(void) { + static float dummy_variable = 0.0; u_short status; /* Modified: head/sys/i386/isa/npx.c ============================================================================== --- head/sys/i386/isa/npx.c Wed Mar 25 21:20:15 2009 (r190425) +++ head/sys/i386/isa/npx.c Wed Mar 25 22:08:30 2009 (r190426) @@ -794,6 +794,11 @@ npxdna(void) PCPU_SET(fpcurthread, curthread); pcb = PCPU_GET(curpcb); +#ifdef CPU_ENABLE_SSE + if (cpu_fxsr) + fpu_clean_state(); +#endif + if ((pcb->pcb_flags & PCB_NPXINITDONE) == 0) { /* * This is the first time this thread has used the FPU or @@ -976,10 +981,10 @@ fpusave(addr) * In order to avoid leaking this information across processes, we clean * these values by performing a dummy load before executing fxrstor(). */ -static double dummy_variable = 0.0; static void fpu_clean_state(void) { + static float dummy_variable = 0.0; u_short status; /* @@ -1005,10 +1010,9 @@ fpurstor(addr) { #ifdef CPU_ENABLE_SSE - if (cpu_fxsr) { - fpu_clean_state(); + if (cpu_fxsr) fxrstor(addr); - } else + else #endif frstor(addr); }