call splclock() around the FPU_LOCK().

XXX: pk suggests we can make the this a sleeping lock.
This commit is contained in:
mrg 2003-01-09 04:58:58 +00:00
parent 41e9687a33
commit 9b0c7030f5
3 changed files with 21 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.214 2003/01/06 18:32:31 pk Exp $ */
/* $NetBSD: machdep.c,v 1.215 2003/01/09 04:58:58 mrg Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -396,6 +396,7 @@ setregs(p, pack, stack)
struct trapframe *tf = p->p_md.md_tf;
struct fpstate *fs;
int psr;
int s;
/* Don't allow misaligned code by default */
p->p_md.md_flags &= ~MDP_FIXALIGN;
@ -415,6 +416,7 @@ setregs(p, pack, stack)
* we must get rid of it, and the only way to do that is
* to save it. In any case, get rid of our FPU state.
*/
s = splclock();
FPU_LOCK();
if ((cpi = p->p_md.md_fpu) != NULL) {
if (cpi->fpproc != p)
@ -430,6 +432,7 @@ setregs(p, pack, stack)
}
p->p_md.md_fpu = NULL;
FPU_UNLOCK();
splx(s);
free((void *)fs, M_SUBPROC);
p->p_md.md_fpstate = NULL;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.125 2003/01/07 16:20:14 mrg Exp $ */
/* $NetBSD: trap.c,v 1.126 2003/01/09 04:58:58 mrg Exp $ */
/*
* Copyright (c) 1996
@ -270,7 +270,7 @@ trap(type, psr, pc, tf)
{
struct proc *p;
struct pcb *pcb;
int n;
int n, s;
char bits[64];
u_quad_t sticks;
int sig;
@ -470,6 +470,9 @@ badtrap:
if (cpuinfo.fpproc != p) { /* we do not have it */
struct cpu_info *cpi;
int s;
s = splclock();
FPU_LOCK();
if (cpuinfo.fpproc != NULL) { /* someone else had it*/
savefpstate(cpuinfo.fpproc->p_md.md_fpstate);
@ -493,6 +496,7 @@ badtrap:
cpuinfo.fpproc = p; /* now we do have it */
p->p_md.md_fpu = curcpu();
FPU_UNLOCK();
splx(s);
}
tf->tf_psr |= PSR_EF;
break;
@ -593,11 +597,13 @@ badtrap:
*/
if (p != cpuinfo.fpproc)
panic("fpe without being the FP user");
s = splclock();
FPU_LOCK();
savefpstate(p->p_md.md_fpstate);
cpuinfo.fpproc = NULL;
p->p_md.md_fpu = NULL;
FPU_UNLOCK();
splx(s);
/* tf->tf_psr &= ~PSR_EF; */ /* share_fpu will do this */
fpu_cleanup(p, p->p_md.md_fpstate);
/* fpu_cleanup posts signals if needed */

View File

@ -1,4 +1,4 @@
/* $NetBSD: vm_machdep.c,v 1.67 2003/01/06 18:32:31 pk Exp $ */
/* $NetBSD: vm_machdep.c,v 1.68 2003/01/09 04:58:59 mrg Exp $ */
/*
* Copyright (c) 1996
@ -233,10 +233,12 @@ cpu_fork(p1, p2, stack, stacksize, func, arg)
bcopy((caddr_t)opcb, (caddr_t)npcb, sizeof(struct pcb));
if (p1->p_md.md_fpstate != NULL) {
struct cpu_info *cpi;
int s;
p2->p_md.md_fpstate = malloc(sizeof(struct fpstate),
M_SUBPROC, M_WAITOK);
s = splclock();
FPU_LOCK();
if ((cpi = p1->p_md.md_fpu) != NULL) {
if (cpi->fpproc != p1)
@ -253,10 +255,12 @@ cpu_fork(p1, p2, stack, stacksize, func, arg)
bcopy(p1->p_md.md_fpstate, p2->p_md.md_fpstate,
sizeof(struct fpstate));
FPU_UNLOCK();
splx(s);
} else
p2->p_md.md_fpstate = NULL;
p2->p_md.md_fpu = NULL;
p2->p_md.md_cpuset = 0;
/*
* Setup (kernel) stack frame that will by-pass the child
@ -317,6 +321,9 @@ cpu_exit(p)
if ((fs = p->p_md.md_fpstate) != NULL) {
struct cpu_info *cpi;
int s;
s = splclock();
FPU_LOCK();
if ((cpi = p->p_md.md_fpu) != NULL) {
if (cpi->fpproc != p)
@ -331,6 +338,7 @@ cpu_exit(p)
cpi->fpproc = NULL;
}
FPU_UNLOCK();
splx(s);
free((void *)fs, M_SUBPROC);
}
switchexit(p);