diff options
author | kib <kib@FreeBSD.org> | 2014-09-18 09:13:20 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2014-09-18 09:13:20 +0000 |
commit | 433c60fe4542d02babe6dd3cd5c0a50b3fdaef3f (patch) | |
tree | 1d86c54009bb2ef0eae9c52e2982d874231c9abc /sys/amd64 | |
parent | b30be52a0a3ea6fed3ef65b6ac0920a4eb5bdbee (diff) | |
download | FreeBSD-src-433c60fe4542d02babe6dd3cd5c0a50b3fdaef3f.zip FreeBSD-src-433c60fe4542d02babe6dd3cd5c0a50b3fdaef3f.tar.gz |
- Use NULL instead of 0 for fpcurthread.
- Note the quirk with the interrupt enabled state of the dna handler.
- Use just panic() instead of printf() and panic(). Print tid instead
of pid, the fpu state is per-thread.
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Diffstat (limited to 'sys/amd64')
-rw-r--r-- | sys/amd64/amd64/fpu.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c index fef47a0..0d59df4 100644 --- a/sys/amd64/amd64/fpu.c +++ b/sys/amd64/amd64/fpu.c @@ -362,7 +362,7 @@ fpuexit(struct thread *td) stop_emulating(); fpusave(curpcb->pcb_save); start_emulating(); - PCPU_SET(fpcurthread, 0); + PCPU_SET(fpcurthread, NULL); } critical_exit(); } @@ -602,16 +602,21 @@ fputrap_sse(void) return (fpetable[(mxcsr & (~mxcsr >> 7)) & 0x3f]); } +static int err_count = 0; + /* - * Implement device not available (DNA) exception + * 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. * - * 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. */ - -static int err_count = 0; - void fpudna(void) { @@ -625,11 +630,9 @@ fpudna(void) return; } if (PCPU_GET(fpcurthread) != NULL) { - printf("fpudna: fpcurthread = %p (%d), curthread = %p (%d)\n", - PCPU_GET(fpcurthread), - PCPU_GET(fpcurthread)->td_proc->p_pid, - curthread, curthread->td_proc->p_pid); - panic("fpudna"); + panic("fpudna: fpcurthread = %p (%d), curthread = %p (%d)\n", + PCPU_GET(fpcurthread), PCPU_GET(fpcurthread)->td_tid, + curthread, curthread->td_tid); } stop_emulating(); /* |