From: Tianyu Lan Subject: [PATCH V3 12/13] KVM/VMX: Change hv flush logic when ept tables are mismatched. Date: Thu, 27 Sep 2018 03:50:00 +0000 Message-ID: <20180927034829.2230-13-Tianyu.Lan@microsoft.com> References: <20180927034829.2230-1-Tianyu.Lan@microsoft.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: Tianyu Lan , "pbonzini@redhat.com" , "rkrcmar@redhat.com" , "tglx@linutronix.de" , "mingo@redhat.com" , "hpa@zytor.com" , "x86@kernel.org" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Michael Kelley (EOSG)" , KY Srinivasan , vkuznets , Jork Loeser To: unlisted-recipients:; (no To-header on input) Return-path: In-Reply-To: <20180927034829.2230-1-Tianyu.Lan@microsoft.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org If ept table pointers are mismatched, flushing tlb for each vcpus via hv flush interface still helps to reduce vmexits which are triggered by IPI and INEPT emulation. Signed-off-by: Lan Tianyu --- arch/x86/kvm/vmx.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 533a327372c8..2869c3e78168 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -1557,7 +1557,8 @@ static void check_ept_pointer_match(struct kvm *kvm) =20 static int vmx_hv_remote_flush_tlb(struct kvm *kvm) { - int ret; + struct kvm_vcpu *vcpu; + int ret =3D -ENOTSUPP, i; =20 spin_lock(&to_kvm_vmx(kvm)->ept_pointer_lock); =20 @@ -1565,14 +1566,14 @@ static int vmx_hv_remote_flush_tlb(struct kvm *kvm) check_ept_pointer_match(kvm); =20 if (to_kvm_vmx(kvm)->ept_pointers_match !=3D EPT_POINTERS_MATCH) { - ret =3D -ENOTSUPP; - goto out; + kvm_for_each_vcpu(i, vcpu, kvm) + ret |=3D hyperv_flush_guest_mapping( + to_vmx(kvm_get_vcpu(kvm, i))->ept_pointer); + } else { + ret =3D hyperv_flush_guest_mapping( + to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer); } =20 - ret =3D hyperv_flush_guest_mapping( - to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer); - -out: spin_unlock(&to_kvm_vmx(kvm)->ept_pointer_lock); return ret; } --=20 2.14.4