git: vkernel - Fix FP corruption in VMX/EPT mode

Matthew Dillon dillon at
Mon Oct 10 10:29:24 PDT 2016

commit 9563660691a2555c0df275f9dbd4d9dcfcb9df56
Author: Matthew Dillon <dillon at>
Date:   Mon Oct 10 10:22:12 2016 -0700

    vkernel - Fix FP corruption in VMX/EPT mode
    * Properly invalidating the EPT TLB cache when it potentially becomes
    * 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
    * 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.

Summary of changes:
 sys/platform/pc64/vmm/vmx.c                  | 131 ++++++++++++++++++---------
 sys/platform/pc64/vmm/vmx.h                  |   2 +
 sys/platform/vkernel64/platform/pmap.c       |   7 +-
 sys/platform/vkernel64/platform/pmap_inval.c |  25 +++--
 sys/platform/vkernel64/x86_64/mp.c           |   4 +-
 sys/platform/vkernel64/x86_64/trap.c         |  17 +++-
 6 files changed, 125 insertions(+), 61 deletions(-)

DragonFly BSD source repository

More information about the Commits mailing list