From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C317CC1975A for ; Tue, 17 Mar 2020 18:22:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D90C20674 for ; Tue, 17 Mar 2020 18:22:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726623AbgCQSWx (ORCPT ); Tue, 17 Mar 2020 14:22:53 -0400 Received: from mga04.intel.com ([192.55.52.120]:30210 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726189AbgCQSWx (ORCPT ); Tue, 17 Mar 2020 14:22:53 -0400 IronPort-SDR: 7c1EC2KIzUAwU6HcZeWRhvsfqTkhjR/AHdzdvGcHeej+/uSQ9nHh3kiQ6Lks9mbqcraVh2Xzr+ kRG372nkY8tQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2020 11:22:52 -0700 IronPort-SDR: wfhquiynLjI52JTnso+EMzRHDns9uNj7cZE3ex2Z0u/q8HwyXcRl3UAcbQu3HtPmznTB4qd1Wv MaZn8sNfMiPg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,565,1574150400"; d="scan'208";a="247911240" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.202]) by orsmga006.jf.intel.com with ESMTP; 17 Mar 2020 11:22:52 -0700 Date: Tue, 17 Mar 2020 11:22:52 -0700 From: Sean Christopherson To: Paolo Bonzini Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Ben Gardon , Junaid Shahid , Liran Alon , Boris Ostrovsky , John Haxby , Miaohe Lin , Tom Lendacky Subject: Re: [PATCH v2 31/32] KVM: nVMX: Don't flush TLB on nested VM transition with EPT enabled Message-ID: <20200317182251.GD12959@linux.intel.com> References: <20200317045238.30434-1-sean.j.christopherson@intel.com> <20200317045238.30434-32-sean.j.christopherson@intel.com> <97f91b27-65ac-9187-6b60-184e1562d228@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <97f91b27-65ac-9187-6b60-184e1562d228@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 17, 2020 at 06:18:37PM +0100, Paolo Bonzini wrote: > On 17/03/20 05:52, Sean Christopherson wrote: > > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c > > index d816f1366943..a77eab5b0e8a 100644 > > --- a/arch/x86/kvm/vmx/nested.c > > +++ b/arch/x86/kvm/vmx/nested.c > > @@ -1123,7 +1123,7 @@ static int nested_vmx_load_cr3(struct kvm_vcpu *vcpu, unsigned long cr3, bool ne > > } > > > > if (!nested_ept) > > - kvm_mmu_new_cr3(vcpu, cr3, false); > > + kvm_mmu_new_cr3(vcpu, cr3, enable_ept); > > Even if enable_ept == false, we could have already scheduled or flushed > the TLB soon due to one of 1) nested_vmx_transition_tlb_flush 2) > vpid_sync_context in prepare_vmcs02 3) the processor doing it for > !enable_vpid. > > So for !enable_ept only KVM_REQ_MMU_SYNC is needed, not > KVM_REQ_TLB_FLUSH_CURRENT I think. Worth adding a TODO? Now that you point it out, I think it makes sense to unconditionally pass %true here, i.e. rely 100% on nested_vmx_transition_tlb_flush() to do the right thing.