Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/d29e76a27488
branches:  netbsd-2-0
changeset: 564966:d29e76a27488
user:      tron <tron%NetBSD.org@localhost>
date:      Fri May 12 15:51:13 2006 +0000

description:
Pull up following revision(s) (requested by adrianp in ticket #10553):
        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 ecada3460bc2 -r d29e76a27488 sys/arch/xen/i386/npx.c
--- a/sys/arch/xen/i386/npx.c   Fri May 12 15:51:02 2006 +0000
+++ b/sys/arch/xen/i386/npx.c   Fri May 12 15:51:13 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npx.c,v 1.1.2.1 2004/05/22 15:59:58 he Exp $   */
+/*     $NetBSD: npx.c,v 1.1.2.2 2006/05/12 15:51:13 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.1.2.1 2004/05/22 15:59:58 he Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.1.2.2 2006/05/12 15:51:13 tron Exp $");
 
 #if 0
 #define IPRINTF(x)     printf x
@@ -596,6 +596,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