Source-Changes-HG archive

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

[src/trunk]: src/sys/arch There is no need to check for recursive calls into ...



details:   https://anonhg.NetBSD.org/src/rev/9c24685a6a74
branches:  trunk
changeset: 793320:9c24685a6a74
user:      dsl <dsl%NetBSD.org@localhost>
date:      Tue Feb 04 21:09:23 2014 +0000

description:
There is no need to check for recursive calls into fpudna().
Rename the associated ci_fpsaving field to 'unused'.
I'm not sure they could ever happen, you could get unwanted calls into
  the fpu trap code while saving state when using INT13 - but these are
  different.
The return value from the i386 fpudna() was always 1 - possibly a historic
  relic of the kernel fp emulation. Remove and don't check in trap.S.
The amd64 and i386 fpudna() code is now almost identical.

diffstat:

 sys/arch/amd64/amd64/fpu.c     |  18 ++----------------
 sys/arch/i386/i386/i386_trap.S |   6 ++----
 sys/arch/i386/isa/npx.c        |  26 +++++++-------------------
 sys/arch/x86/include/cpu.h     |   4 ++--
 4 files changed, 13 insertions(+), 41 deletions(-)

diffs (184 lines):

diff -r 3ce4533b997a -r 9c24685a6a74 sys/arch/amd64/amd64/fpu.c
--- a/sys/arch/amd64/amd64/fpu.c        Tue Feb 04 19:48:48 2014 +0000
+++ b/sys/arch/amd64/amd64/fpu.c        Tue Feb 04 21:09:23 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu.c,v 1.44 2013/12/11 22:06:51 dsl Exp $     */
+/*     $NetBSD: fpu.c,v 1.45 2014/02/04 21:09:23 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.44 2013/12/11 22:06:51 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.45 2014/02/04 21:09:23 dsl Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -256,12 +256,6 @@
        struct pcb *pcb;
        int s;
 
-       if (ci->ci_fpsaving) {
-               /* Recursive trap. */
-               x86_enable_intr();
-               return;
-       }
-
        /* Lock out IPIs and disable preemption. */
        s = splhigh();
        x86_enable_intr();
@@ -361,16 +355,8 @@
        pcb = lwp_getpcb(l);
 
        if (save) {
-                /*
-                 * Set ci->ci_fpsaving, so that any pending exception will
-                 * be thrown away.  It will be caught again if/when the
-                 * FPU state is restored.
-                 */
-               KASSERT(ci->ci_fpsaving == 0);
                clts();
-               ci->ci_fpsaving = 1;
                fxsave(&pcb->pcb_savefpu);
-               ci->ci_fpsaving = 0;
        }
 
        stts();
diff -r 3ce4533b997a -r 9c24685a6a74 sys/arch/i386/i386/i386_trap.S
--- a/sys/arch/i386/i386/i386_trap.S    Tue Feb 04 19:48:48 2014 +0000
+++ b/sys/arch/i386/i386/i386_trap.S    Tue Feb 04 21:09:23 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i386_trap.S,v 1.3 2014/02/02 22:41:20 dsl Exp $        */
+/*     $NetBSD: i386_trap.S,v 1.4 2014/02/04 21:09:23 dsl Exp $        */
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -66,7 +66,7 @@
 
 #if 0
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.3 2014/02/02 22:41:20 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.4 2014/02/04 21:09:23 dsl Exp $");
 #endif
 
 /*
@@ -165,8 +165,6 @@
        pushl   CPUVAR(SELF)
        call    _C_LABEL(fpudna)
        addl    $4,%esp
-       testl   %eax,%eax
-       jz      calltrap
        jmp     _C_LABEL(trapreturn)
 IDTVEC_END(trap07)
 IDTVEC(trap08)
diff -r 3ce4533b997a -r 9c24685a6a74 sys/arch/i386/isa/npx.c
--- a/sys/arch/i386/isa/npx.c   Tue Feb 04 19:48:48 2014 +0000
+++ b/sys/arch/i386/isa/npx.c   Tue Feb 04 21:09:23 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npx.c,v 1.151 2014/02/03 23:00:32 dsl Exp $    */
+/*     $NetBSD: npx.c,v 1.152 2014/02/04 21:09:23 dsl Exp $    */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.151 2014/02/03 23:00:32 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.152 2014/02/04 21:09:23 dsl Exp $");
 
 #if 0
 #define IPRINTF(x)     printf x
@@ -151,7 +151,7 @@
 
 static int     x86fpflags_to_ksiginfo(uint32_t flags);
 /* Called directly from i386_trap.S */
-int    fpudna(struct cpu_info *);
+void   fpudna(struct cpu_info *);
 
 #ifdef XEN
 #define        clts() HYPERVISOR_fpu_taskswitch(0)
@@ -358,22 +358,19 @@
 /*
  * Implement device not available (DNA) exception
  *
+ * Called directly from i386_trap.S with interrupts still disabled
+ *
  * If we were the last lwp to use the FPU, we can simply return.
  * Otherwise, we save the previous state, if necessary, and restore
  * our last saved state.
  */
-int
+void
 fpudna(struct cpu_info *ci)
 {
        struct lwp *l, *fl;
        struct pcb *pcb;
        int s;
 
-       if (ci->ci_fpsaving) {
-               /* Recursive trap. */
-               return 1;
-       }
-
        /* Lock out IPIs and disable preemption. */
        s = splhigh();
 #ifndef XEN
@@ -394,7 +391,7 @@
                        ci->ci_fpused = 1;
                        clts();
                        splx(s);
-                       return 1;
+                       return;
                }
                KASSERT(fl != l);
                fpusave_cpu(true);
@@ -457,7 +454,6 @@
 
        KASSERT(ci == curcpu());
        splx(s);
-       return 1;
 }
 
 /*
@@ -480,20 +476,12 @@
        pcb = lwp_getpcb(l);
 
        if (save) {
-                /*
-                 * Set ci->ci_fpsaving, so that any pending exception will
-                 * be thrown away.  It will be caught again if/when the
-                 * FPU state is restored.
-                 */
-               KASSERT(ci->ci_fpsaving == 0);
                clts();
-               ci->ci_fpsaving = 1;
                if (i386_use_fxsave) {
                        fxsave(&pcb->pcb_savefpu.sv_xmm);
                } else {
                        fnsave(&pcb->pcb_savefpu.sv_87);
                }
-               ci->ci_fpsaving = 0;
        }
 
        stts();
diff -r 3ce4533b997a -r 9c24685a6a74 sys/arch/x86/include/cpu.h
--- a/sys/arch/x86/include/cpu.h        Tue Feb 04 19:48:48 2014 +0000
+++ b/sys/arch/x86/include/cpu.h        Tue Feb 04 21:09:23 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.59 2014/01/26 19:16:17 dsl Exp $     */
+/*     $NetBSD: cpu.h,v 1.60 2014/02/04 21:09:24 dsl Exp $     */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -101,7 +101,7 @@
        struct cpu_info *ci_next;       /* next cpu */
        struct lwp *ci_curlwp;          /* current owner of the processor */
        struct lwp *ci_fpcurlwp;        /* current owner of the FPU */
-       int     ci_fpsaving;            /* save in progress */
+       int     _unused1;
        int     ci_fpused;              /* XEN: FPU was used by curlwp */
        cpuid_t ci_cpuid;               /* our CPU ID */
        int     _unused;



Home | Main Index | Thread Index | Old Index