vmm: don't use invvpid if we didn't detect vpid capability during
authormlarkin <mlarkin@openbsd.org>
Fri, 28 Apr 2017 07:44:36 +0000 (07:44 +0000)
committermlarkin <mlarkin@openbsd.org>
Fri, 28 Apr 2017 07:44:36 +0000 (07:44 +0000)
vcpu setup

sys/arch/amd64/amd64/vmm.c
sys/arch/amd64/include/vmmvar.h

index b98c2f0..d3954f8 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: vmm.c,v 1.135 2017/04/27 06:49:05 mlarkin Exp $       */
+/*     $OpenBSD: vmm.c,v 1.136 2017/04/28 07:44:36 mlarkin Exp $       */
 /*
  * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
  *
@@ -2055,8 +2055,10 @@ vcpu_reset_regs_vmx(struct vcpu *vcpu, struct vcpu_reg_state *vrs)
        if (vcpu_vmx_check_cap(vcpu, IA32_VMX_PROCBASED_CTLS,
            IA32_VMX_ACTIVATE_SECONDARY_CONTROLS, 1)) {
                if (vcpu_vmx_check_cap(vcpu, IA32_VMX_PROCBASED2_CTLS,
-                   IA32_VMX_ENABLE_VPID, 1))
+                   IA32_VMX_ENABLE_VPID, 1)) {
                        want1 |= IA32_VMX_ENABLE_VPID;
+                       vcpu->vc_vmx_vpid_enabled = 1;
+               }
        }
 
        if (vmm_softc->mode == VMM_MODE_EPT)
@@ -3565,10 +3567,12 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *vrp)
                        }
                }
 
-               /* Invalidate old TLB mappings */
-               vid.vid_vpid = vcpu->vc_parent->vm_id;
-               vid.vid_addr = 0;
-               invvpid(IA32_VMX_INVVPID_SINGLE_CTX_GLB, &vid);
+               if (vcpu->vc_vmx_vpid_enabled) {
+                       /* Invalidate old TLB mappings */
+                       vid.vid_vpid = vcpu->vc_parent->vm_id;
+                       vid.vid_addr = 0;
+                       invvpid(IA32_VMX_INVVPID_SINGLE_CTX_GLB, &vid);
+               }
 
                /* Start / resume the VCPU */
                KERNEL_ASSERT_LOCKED();
index fcc0224..b3d6ec3 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: vmmvar.h,v 1.34 2017/04/27 07:15:35 mlarkin Exp $     */
+/*     $OpenBSD: vmmvar.h,v 1.35 2017/04/28 07:44:36 mlarkin Exp $     */
 /*
  * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
  *
@@ -704,6 +704,7 @@ struct vcpu {
        paddr_t vc_vmx_msr_exit_load_pa;
        vaddr_t vc_vmx_msr_entry_load_va;
        paddr_t vc_vmx_msr_entry_load_pa;
+       uint8_t vc_vmx_vpid_enabled;
 
        /* SVM only */
        vaddr_t vc_svm_hsa_va;