Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Add fpu_set_default_cw() and use it in the emulatio...



details:   https://anonhg.NetBSD.org/src/rev/8d0c997fe127
branches:  trunk
changeset: 793698:8d0c997fe127
user:      dsl <dsl%NetBSD.org@localhost>
date:      Sun Feb 23 22:35:27 2014 +0000

description:
Add fpu_set_default_cw() and use it in the emulations to set the default
  x87 control word.
This means that nothing outside fpu.c cares about the internals of the
  fpu save area.
New kernel modules won't load with the old kernel - but that won't matter.

diffstat:

 sys/arch/i386/i386/freebsd_machdep.c |  10 +++-------
 sys/arch/i386/i386/ibcs2_machdep.c   |  11 ++++-------
 sys/arch/i386/i386/svr4_machdep.c    |  13 ++++++-------
 sys/arch/x86/include/fpu.h           |   4 +++-
 sys/arch/x86/x86/fpu.c               |  16 ++++++++++++++--
 5 files changed, 30 insertions(+), 24 deletions(-)

diffs (167 lines):

diff -r 3ec6723ce89b -r 8d0c997fe127 sys/arch/i386/i386/freebsd_machdep.c
--- a/sys/arch/i386/i386/freebsd_machdep.c      Sun Feb 23 21:19:06 2014 +0000
+++ b/sys/arch/i386/i386/freebsd_machdep.c      Sun Feb 23 22:35:27 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: freebsd_machdep.c,v 1.59 2014/02/12 23:24:09 dsl Exp $ */
+/*     $NetBSD: freebsd_machdep.c,v 1.60 2014/02/23 22:35:27 dsl Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: freebsd_machdep.c,v 1.59 2014/02/12 23:24:09 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: freebsd_machdep.c,v 1.60 2014/02/23 22:35:27 dsl Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vm86.h"
@@ -60,13 +60,9 @@
 void
 freebsd_setregs(struct lwp *l, struct exec_package *epp, vaddr_t stack)
 {
-       struct pcb *pcb = lwp_getpcb(l);
 
        setregs(l, epp, stack);
-       if (i386_use_fxsave)
-               pcb->pcb_savefpu.sv_xmm.fx_cw = __FreeBSD_NPXCW__;
-       else
-               pcb->pcb_savefpu.sv_87.s87_cw = __FreeBSD_NPXCW__;
+       fpu_set_default_cw(l, __FreeBSD_NPXCW__);
 }
 
 /*
diff -r 3ec6723ce89b -r 8d0c997fe127 sys/arch/i386/i386/ibcs2_machdep.c
--- a/sys/arch/i386/i386/ibcs2_machdep.c        Sun Feb 23 21:19:06 2014 +0000
+++ b/sys/arch/i386/i386/ibcs2_machdep.c        Sun Feb 23 22:35:27 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ibcs2_machdep.c,v 1.43 2014/02/12 23:24:09 dsl Exp $   */
+/*     $NetBSD: ibcs2_machdep.c,v 1.44 2014/02/23 22:35:27 dsl Exp $   */
 
 /*-
  * Copyright (c) 1997, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ibcs2_machdep.c,v 1.43 2014/02/12 23:24:09 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ibcs2_machdep.c,v 1.44 2014/02/23 22:35:27 dsl Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vm86.h"
@@ -64,14 +64,11 @@
 void
 ibcs2_setregs(struct lwp *l, struct exec_package *epp, vaddr_t stack)
 {
-       struct pcb *pcb = lwp_getpcb(l);
        struct trapframe *tf;
 
        setregs(l, epp, stack);
-       if (i386_use_fxsave)
-               pcb->pcb_savefpu.sv_xmm.fx_cw = __iBCS2_NPXCW__;
-       else
-               pcb->pcb_savefpu.sv_87.s87_cw = __iBCS2_NPXCW__;
+       fpu_set_default_cw(l, __iBCS2_NPXCW__);
+
        tf = l->l_md.md_regs;
        tf->tf_eax = 0x2000000;         /* XXX base of heap */
        tf->tf_cs = GSEL(GUCODEBIG_SEL, SEL_UPL);
diff -r 3ec6723ce89b -r 8d0c997fe127 sys/arch/i386/i386/svr4_machdep.c
--- a/sys/arch/i386/i386/svr4_machdep.c Sun Feb 23 21:19:06 2014 +0000
+++ b/sys/arch/i386/i386/svr4_machdep.c Sun Feb 23 22:35:27 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: svr4_machdep.c,v 1.98 2014/01/19 14:30:37 dsl Exp $     */
+/*     $NetBSD: svr4_machdep.c,v 1.99 2014/02/23 22:35:27 dsl Exp $     */
 
 /*-
  * Copyright (c) 1994, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svr4_machdep.c,v 1.98 2014/01/19 14:30:37 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_machdep.c,v 1.99 2014/02/23 22:35:27 dsl Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vm86.h"
@@ -69,6 +69,8 @@
 #include <machine/vmparam.h>
 #include <machine/svr4_machdep.h>
 
+#include <x86/fpu.h>
+
 static void svr4_getsiginfo(union svr4_siginfo *, int, u_long, void *);
 extern void (*svr4_fasttrap_vec)(void);
 void svr4_fasttrap(struct trapframe);
@@ -111,14 +113,11 @@
 void
 svr4_setregs(struct lwp *l, struct exec_package *epp, vaddr_t stack)
 {
-       struct pcb *pcb = lwp_getpcb(l);
        struct trapframe *tf = l->l_md.md_regs;
 
        setregs(l, epp, stack);
-       if (i386_use_fxsave)
-               pcb->pcb_savefpu.sv_xmm.fx_cw = __SVR4_NPXCW__;
-       else
-               pcb->pcb_savefpu.sv_87.s87_cw = __SVR4_NPXCW__;
+       fpu_set_default_cw(l, __SVR4_NPXCW__);
+
        tf->tf_cs = GSEL(GUCODEBIG_SEL, SEL_UPL);
 }
 
diff -r 3ec6723ce89b -r 8d0c997fe127 sys/arch/x86/include/fpu.h
--- a/sys/arch/x86/include/fpu.h        Sun Feb 23 21:19:06 2014 +0000
+++ b/sys/arch/x86/include/fpu.h        Sun Feb 23 22:35:27 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu.h,v 1.4 2014/02/15 22:20:42 dsl Exp $      */
+/*     $NetBSD: fpu.h,v 1.5 2014/02/23 22:35:27 dsl Exp $      */
 
 #ifndef        _X86_FPU_H_
 #define        _X86_FPU_H_
@@ -15,6 +15,8 @@
 void fpusave_lwp(struct lwp *, bool);
 void fpusave_cpu(bool);
 
+void fpu_set_default_cw(struct lwp *, unsigned int);
+
 void fputrap(struct trapframe *);
 void fpudna(struct trapframe *);
 
diff -r 3ec6723ce89b -r 8d0c997fe127 sys/arch/x86/x86/fpu.c
--- a/sys/arch/x86/x86/fpu.c    Sun Feb 23 21:19:06 2014 +0000
+++ b/sys/arch/x86/x86/fpu.c    Sun Feb 23 22:35:27 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu.c,v 1.7 2014/02/23 12:56:40 dsl Exp $      */
+/*     $NetBSD: fpu.c,v 1.8 2014/02/23 22:35:28 dsl Exp $      */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.  All
@@ -100,7 +100,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.7 2014/02/23 12:56:40 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.8 2014/02/23 22:35:28 dsl Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -249,6 +249,18 @@
        stts();
 }
 
+void
+fpu_set_default_cw(struct lwp *lwp, unsigned int x87_cw)
+{
+       union savefpu *fpu_save = process_fpframe(lwp);
+
+       if (i386_use_fxsave)
+               fpu_save->sv_xmm.fx_cw = x87_cw;
+       else
+               fpu_save->sv_87.s87_cw = x87_cw;
+       fpu_save->sv_os.fxo_dflt_cw = x87_cw;
+}
+
 static void
 send_sigill(void *rip)
 {



Home | Main Index | Thread Index | Old Index