From 88461eb3949700079c8bd4bc3db46d6a263c3bcd Mon Sep 17 00:00:00 2001 From: Mike Larkin Date: Fri, 28 Apr 2017 07:44:37 +0000 Subject: vmm: don't use invvpid if we didn't detect vpid capability during vcpu setup --- sys/arch/amd64/amd64/vmm.c | 16 ++++++++++------ sys/arch/amd64/include/vmmvar.h | 3 ++- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'sys') diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c index b98c2f080d6..d3954f8912b 100644 --- a/sys/arch/amd64/amd64/vmm.c +++ b/sys/arch/amd64/amd64/vmm.c @@ -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 * @@ -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(); diff --git a/sys/arch/amd64/include/vmmvar.h b/sys/arch/amd64/include/vmmvar.h index fcc0224171a..b3d6ec39622 100644 --- a/sys/arch/amd64/include/vmmvar.h +++ b/sys/arch/amd64/include/vmmvar.h @@ -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 * @@ -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; -- cgit v1.2.3