vkernel - Fix FP corruption in VMX/EPT mode
authorMatthew Dillon <dillon@backplane.com>
Mon, 10 Oct 2016 17:22:12 +0000 (10:22 -0700)
committerMatthew Dillon <dillon@backplane.com>
Mon, 10 Oct 2016 17:22:12 +0000 (10:22 -0700)
commit9563660691a2555c0df275f9dbd4d9dcfcb9df56
tree563efa248fcd9f83a65f1a9c95ac64568178e2ed
parent54ea00b82d152a53ab88ac074ccc89b7790dc4a8
vkernel - Fix FP corruption in VMX/EPT mode

* Properly invalidating the EPT TLB cache when it potentially becomes
  stale.

* When destroying a VMX context, make sure the EPT TLB cache has been
  invalidated for that context as a safety.

* Fix a bug in vmx_vminit() where it was losing track of the currently
  loaded VMX.

* Setup the VMX to clear the host CR0_TS, and the host makes sure the FP
  state is correct prior to vmlaunch.

* Make sure the GUEST_CR0's CR0_TS reflects the vkernel says it should
  reflect.

* The vkernel has a choice of asking the guest user context to #NM fault
  on FP use or not.  Both mechanics work, but its probably better for it
  to ensure that the FP state is valid and tell the user context to not
  fault.  However, this commit makes sure that both mechanics work.

* Document why we shouldn't vmclear the old current context when loading
  a different context.

* Cleanup some of the vkernel's pmap handling.  This isn't perfect and
  probably needs to be rewritten (we need a more powerful guest pmap
  adjustment system call to properly synchronize changes).  For now
  we try to avoid races against detecting the (M)odified flag by clearing
  the RW flag first.
sys/platform/pc64/vmm/vmx.c
sys/platform/pc64/vmm/vmx.h
sys/platform/vkernel64/platform/pmap.c
sys/platform/vkernel64/platform/pmap_inval.c
sys/platform/vkernel64/x86_64/mp.c
sys/platform/vkernel64/x86_64/trap.c