fix lazy fpu state saving

This commit is contained in:
cl 2004-05-07 13:48:32 +00:00
parent 5090104da8
commit f61d1b4cce
3 changed files with 20 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.7 2004/04/26 22:05:04 cl Exp $ */
/* $NetBSD: machdep.c,v 1.8 2004/05/07 13:48:32 cl Exp $ */
/* NetBSD: machdep.c,v 1.552 2004/03/24 15:34:49 atatat Exp */
/*-
@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.7 2004/04/26 22:05:04 cl Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.8 2004/05/07 13:48:32 cl Exp $");
#include "opt_beep.h"
#include "opt_compat_ibcs2.h"
@ -449,9 +449,13 @@ void
i386_switch_context(struct pcb *new)
{
dom0_op_t op;
struct cpu_info *ci;
if (new->pcb_cr0 & CR0_TS)
ci = curcpu();
if (ci->ci_fpused) {
HYPERVISOR_fpu_taskswitch();
ci->ci_fpused = 0;
}
HYPERVISOR_stack_switch(new->pcb_tss.tss_ss0, new->pcb_tss.tss_esp0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: npx.c,v 1.2 2004/04/06 16:23:33 cl Exp $ */
/* $NetBSD: npx.c,v 1.3 2004/05/07 13:48:32 cl 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.2 2004/04/06 16:23:33 cl Exp $");
__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.3 2004/05/07 13:48:32 cl Exp $");
#if 0
#define IPRINTF(x) printf x
@ -611,10 +611,13 @@ npxdna_s87(struct cpu_info *ci)
KDASSERT(i386_use_fxsave == 0);
if (ci->ci_fpsaving) {
printf("recursive npx trap; cr0=%x\n", rcr0());
return (0);
}
/*
* Because we don't have clts() we will trap on the fnsave in
* fpu_save, if we're saving the FPU state not from interrupt
* context (f.i. during fork()). Just return in this case.
*/
if (ci->ci_fpsaving)
return (1);
s = splipi(); /* lock out IPI's while we clean house.. */
#ifdef MULTIPROCESSOR
@ -653,6 +656,7 @@ npxdna_s87(struct cpu_info *ci)
s = splipi();
ci->ci_fpcurlwp = l;
l->l_addr->u_pcb.pcb_fpcpu = ci;
ci->ci_fpused = 1;
splx(s);
@ -727,6 +731,7 @@ npxsave_cpu (struct cpu_info *ci, int save)
s = splipi();
l->l_addr->u_pcb.pcb_fpcpu = NULL;
ci->ci_fpcurlwp = NULL;
ci->ci_fpused = 1;
splx(s);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.h,v 1.5 2004/04/26 23:54:42 cl Exp $ */
/* $NetBSD: cpu.h,v 1.6 2004/05/07 13:48:32 cl Exp $ */
/* NetBSD: cpu.h,v 1.113 2004/02/20 17:35:01 yamt Exp */
/*-
@ -91,6 +91,7 @@ struct cpu_info {
*/
struct lwp *ci_fpcurlwp; /* current owner of the FPU */
int ci_fpsaving; /* save in progress */
int ci_fpused; /* FPU was used by curlwp */
volatile u_int32_t ci_tlb_ipi_mask;