diff --git a/sys/arch/amd64/amd64/fpu.c b/sys/arch/amd64/amd64/fpu.c index c53cbe500cca..a286033ae979 100644 --- a/sys/arch/amd64/amd64/fpu.c +++ b/sys/arch/amd64/amd64/fpu.c @@ -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 -__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 @@ fpudna(struct cpu_info *ci) 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 @@ fpusave_cpu(bool save) 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 --git a/sys/arch/i386/i386/i386_trap.S b/sys/arch/i386/i386/i386_trap.S index 8104c3a064cb..b7abe1d03846 100644 --- a/sys/arch/i386/i386/i386_trap.S +++ b/sys/arch/i386/i386/i386_trap.S @@ -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 -__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 @@ IDTVEC(trap07) 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 --git a/sys/arch/i386/isa/npx.c b/sys/arch/i386/isa/npx.c index e6150ca3df4e..6e094ca484a4 100644 --- a/sys/arch/i386/isa/npx.c +++ b/sys/arch/i386/isa/npx.c @@ -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 -__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 @@ __KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.151 2014/02/03 23:00:32 dsl Exp $"); 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 @@ x86fpflags_to_ksiginfo(uint32_t flags) /* * 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 @@ fpudna(struct cpu_info *ci) ci->ci_fpused = 1; clts(); splx(s); - return 1; + return; } KASSERT(fl != l); fpusave_cpu(true); @@ -457,7 +454,6 @@ fpudna(struct cpu_info *ci) KASSERT(ci == curcpu()); splx(s); - return 1; } /* @@ -480,20 +476,12 @@ fpusave_cpu(bool save) 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 --git a/sys/arch/x86/include/cpu.h b/sys/arch/x86/include/cpu.h index a300c782e9a6..7c35459191b8 100644 --- a/sys/arch/x86/include/cpu.h +++ b/sys/arch/x86/include/cpu.h @@ -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 { 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;