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.
This commit is contained in:
dsl 2014-02-04 21:09:23 +00:00
parent 47c7c18d7f
commit b2f9af25a4
4 changed files with 13 additions and 41 deletions

View File

@ -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 @@ 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();

View File

@ -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 @@ 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)

View File

@ -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 @@ __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();

View File

@ -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;