summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2014-09-21 09:06:50 +0000
committerkib <kib@FreeBSD.org>2014-09-21 09:06:50 +0000
commitf2d3c32e1b3ea344f36b0f7ee2e19e238e8e6fc2 (patch)
tree93b8eea7f0727ed040c9a85eb90456bbee5b9aa3 /sys/amd64
parent3eeeb7c9a391b35a2fb7e62b35297caa52657c6b (diff)
downloadFreeBSD-src-f2d3c32e1b3ea344f36b0f7ee2e19e238e8e6fc2.zip
FreeBSD-src-f2d3c32e1b3ea344f36b0f7ee2e19e238e8e6fc2.tar.gz
Update and clarify comments. Remove the useless counter for impossible, but
seen in wild situation (on buggy hypervisors). In collaboration with: bde MFC after: 1 week
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/amd64/fpu.c21
-rw-r--r--sys/amd64/amd64/trap.c4
2 files changed, 13 insertions, 12 deletions
diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c
index 0d59df4..5c61859 100644
--- a/sys/amd64/amd64/fpu.c
+++ b/sys/amd64/amd64/fpu.c
@@ -602,29 +602,30 @@ fputrap_sse(void)
return (fpetable[(mxcsr & (~mxcsr >> 7)) & 0x3f]);
}
-static int err_count = 0;
-
/*
* Device Not Available (DNA, #NM) exception handler.
*
* It would be better to switch FP context here (if curthread !=
* fpcurthread) and not necessarily for every context switch, but it
* is too hard to access foreign pcb's.
- *
- * The handler is entered with interrupts enabled, which allows the
- * context switch to happen before critical enter() is executed, and
- * causes restoration of FPU context on CPU other than that caused
- * DNA. It is fine, since context switch started emulation on the
- * current CPU as well.
*/
void
fpudna(void)
{
+ /*
+ * This handler is entered with interrupts enabled, so context
+ * switches may occur before critical_enter() is executed. If
+ * a context switch occurs, then when we regain control, our
+ * state will have been completely restored. The CPU may
+ * change underneath us, but the only part of our context that
+ * lives in the CPU is CR0.TS and that will be "restored" by
+ * setting it on the new CPU.
+ */
critical_enter();
+
if (PCPU_GET(fpcurthread) == curthread) {
- printf("fpudna: fpcurthread == curthread %d times\n",
- ++err_count);
+ printf("fpudna: fpcurthread == curthread\n");
stop_emulating();
critical_exit();
return;
diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index f6459f4..4880c91 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -436,8 +436,8 @@ trap(struct trapframe *frame)
case T_XMMFLT: /* SIMD floating-point exception */
case T_FPOPFLT: /* FPU operand fetch fault */
/*
- * XXXKIB for now disable any FPU traps in kernel
- * handler registration seems to be overkill
+ * For now, supporting kernel handler
+ * registration for FPU traps is overkill.
*/
trap_fatal(frame, 0);
goto out;
OpenPOWER on IntegriCloud