Another major mmx/xmm/FP commit. This is a combination of several patches
authorMatthew Dillon <dillon@dragonflybsd.org>
Wed, 5 May 2004 19:26:44 +0000 (19:26 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Wed, 5 May 2004 19:26:44 +0000 (19:26 +0000)
commita02705a988a3f5c7e674cdeefef21dbfa552f027
tree386ef02e806f95b951e6a4c26c0bc933b68711c5
parent07d2fd358b3ca7d39ca36e0a8c7ed67b090075f7
Another major mmx/xmm/FP commit.  This is a combination of several patches
but since the earlier patches didn't actually fix the crashing and corruption
issues we were seeing everything has been rolled into one well tested commit.

Make the FP more deterministic by requiring that npxthread and the FP state
be properly synchronized, and that the FP be in a 'safe' state (meaning
that mmx/xmm registers be useable) when npxthread is NULL.  Allow the FP
save area to be revectored.  Kernel entities which use the FP unit,
such as the bcopy code, must save the app state if it hasn't already been
saved, then revector the save area.

Note that combinations of operations must be protected by a critical section
or interrupt disablement.  Any clearing or setting npxthread combined with
an fxsave/fnsave/frstor/fxrstor/fninit must be protected as an atomic entity.
Since interrupts are threads and can preempt, such preemption will cause
a thread switch to occur and thus cause npxthread and the FP state to be
manipulated.  The kernel can only depend on the FP state being stable for its
use after it has revectored the FP save area.

This commit fixes a number of issues, including potential filesystem
corruption and kernel crashes.
23 files changed:
sys/cpu/i386/include/asmacros.h
sys/cpu/i386/include/npx.h
sys/i386/i386/bcopy.s
sys/i386/i386/genassym.c
sys/i386/i386/globals.s
sys/i386/i386/machdep.c
sys/i386/i386/pmap.c
sys/i386/i386/swtch.s
sys/i386/i386/trap.c
sys/i386/include/asmacros.h
sys/i386/include/globaldata.h
sys/i386/include/npx.h
sys/i386/isa/npx.c
sys/platform/pc32/i386/bcopy.s
sys/platform/pc32/i386/genassym.c
sys/platform/pc32/i386/globals.s
sys/platform/pc32/i386/machdep.c
sys/platform/pc32/i386/pmap.c
sys/platform/pc32/i386/swtch.s
sys/platform/pc32/i386/trap.c
sys/platform/pc32/include/globaldata.h
sys/platform/pc32/isa/npx.c
sys/platform/vkernel/i386/genassym.c