Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3-0]: src/sys/arch/xen/i386 Pull up following revision(s) (reques...



details:   https://anonhg.NetBSD.org/src/rev/75a80120867e
branches:  netbsd-3-0
changeset: 579221:75a80120867e
user:      tron <tron%NetBSD.org@localhost>
date:      Fri May 12 15:43:56 2006 +0000

description:
Pull up following revision(s) (requested by adrianp in ticket #1321):
        sys/arch/xen/i386/npx.c: revision 1.8
Apply fix from FreeBSD's advisory: fxrstor on AMD FPU's does not restore
FIP,FDP,FOP thus leaking other process's execution history.

diffstat:

 sys/arch/xen/i386/npx.c |  24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diffs (45 lines):

diff -r 7ca354ab4ece -r 75a80120867e sys/arch/xen/i386/npx.c
--- a/sys/arch/xen/i386/npx.c   Fri May 12 15:43:46 2006 +0000
+++ b/sys/arch/xen/i386/npx.c   Fri May 12 15:43:56 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npx.c,v 1.3.14.1.2.1 2006/01/11 17:10:44 tron Exp $    */
+/*     $NetBSD: npx.c,v 1.3.14.1.2.2 2006/05/12 15:43:56 tron Exp $    */
 /*     NetBSD: npx.c,v 1.103 2004/03/21 10:56:24 simonb Exp    */
 
 /*-
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.3.14.1.2.1 2006/01/11 17:10:44 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.3.14.1.2.2 2006/05/12 15:43:56 tron Exp $");
 
 #if 0
 #define IPRINTF(x)     printf x
@@ -590,6 +590,26 @@
                fldcw(&l->l_addr->u_pcb.pcb_savefpu.sv_xmm.sv_env.en_cw);
                l->l_md.md_flags |= MDL_USEDFPU;
        } else {
+               /*
+                * AMD FPU's do not restore FIP, FDP, and FOP on fxrstor,
+                * leaking other process's execution history. Clear them
+                * manually.
+                */
+               static const double zero = 0.0;
+               int status;
+               /*
+                * Clear the ES bit in the x87 status word if it is currently
+                * set, in order to avoid causing a fault in the upcoming load.
+                */
+               fnstsw(&status);
+               if (status & 0x80)
+                       fnclex();
+               /*
+                * Load the dummy variable into the x87 stack.  This mangles
+                * the x87 stack, but we don't care since we're about to call
+                * fxrstor() anyway.
+                */
+               __asm __volatile("ffree %%st(7)\n\tfld %0" : : "m" (zero));
                fxrstor(&l->l_addr->u_pcb.pcb_savefpu.sv_xmm);
        }
 



Home | Main Index | Thread Index | Old Index