vkernel - Fix FP corruption in VMX/EPT mode v4.6.1
authorMatthew Dillon <dillon@backplane.com>
Mon, 10 Oct 2016 17:22:12 +0000 (10:22 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 16 Oct 2016 21:49:34 +0000 (14:49 -0700)
commit068a77b8cef786dbd156738965090790c7c02719
tree7aab487d3d8aff313caca2236d5b0f46e4964b99
parent9fb6182a431801bf588fe53fcb7ce94a7f8f3553
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