Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86/x86 When using EagerFPU, create the fpu state i...
details: https://anonhg.NetBSD.org/src/rev/d4e6b67fb3bb
branches: trunk
changeset: 362646:d4e6b67fb3bb
user: maxv <maxv%NetBSD.org@localhost>
date: Tue Jun 19 09:25:13 2018 +0000
description:
When using EagerFPU, create the fpu state in execve at IPL_HIGH.
A preemption could occur in the middle, and we don't want that to happen,
because the context switch would use the partially-constructed fpu state.
The procedure becomes:
splhigh
unbusy the current cpu's fpu
create a new fpu state in memory
install the state on the current cpu's fpu
splx
Disabling preemption also ensures that x86_fpu_eager doesn't change in
the middle.
In LazyFPU mode we drop IPL_HIGH right away.
Add more KASSERTs.
diffstat:
sys/arch/x86/x86/fpu.c | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
diffs (58 lines):
diff -r da56dc21adf6 -r d4e6b67fb3bb sys/arch/x86/x86/fpu.c
--- a/sys/arch/x86/x86/fpu.c Tue Jun 19 09:20:46 2018 +0000
+++ b/sys/arch/x86/x86/fpu.c Tue Jun 19 09:25:13 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu.c,v 1.38 2018/06/18 20:20:27 maxv Exp $ */
+/* $NetBSD: fpu.c,v 1.39 2018/06/19 09:25:13 maxv Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc. All
@@ -96,7 +96,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.38 2018/06/18 20:20:27 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.39 2018/06/19 09:25:13 maxv Exp $");
#include "opt_multiprocessor.h"
@@ -624,10 +624,22 @@
{
union savefpu *fpu_save;
struct pcb *pcb;
+ int s;
- fpusave_lwp(l, false);
+ KASSERT(l == curlwp);
+ KASSERT((l->l_flag & LW_SYSTEM) == 0);
fpu_save = process_fpframe(l);
pcb = lwp_getpcb(l);
+
+ s = splhigh();
+ if (x86_fpu_eager) {
+ KASSERT(pcb->pcb_fpcpu == NULL ||
+ pcb->pcb_fpcpu == curcpu());
+ fpusave_cpu(false);
+ } else {
+ splx(s);
+ fpusave_lwp(l, false);
+ }
KASSERT(pcb->pcb_fpcpu == NULL);
if (i386_use_fxsave) {
@@ -650,13 +662,9 @@
}
pcb->pcb_fpu_dflt_cw = x87_cw;
- /*
- * If using eager-switch, install the FPU state on the current
- * CPU.
- */
if (x86_fpu_eager) {
- KASSERT(l == curlwp);
- fpu_eagerswitch(NULL, l);
+ fpu_eagerrestore(l);
+ splx(s);
}
}
Home |
Main Index |
Thread Index |
Old Index