Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5455951imm; Tue, 12 Jun 2018 08:06:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI6Cl5Owx+GoFQ4Wor1fi2wloOyOaVt3qF04VddOQkre5ipVluUvX5yW7VRtunSWYZ3FCIj X-Received: by 2002:a63:86c8:: with SMTP id x191-v6mr667316pgd.2.1528815996234; Tue, 12 Jun 2018 08:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528815996; cv=none; d=google.com; s=arc-20160816; b=Jo+TylietnJJCnU47yRcDIJX9RfHl7RvEFPsXJKgDuPoJD9i7uhzH/hyUi7EFCxvwN skpIG/ngeUIhIy1pTVwJRrXSEODWXLDpVzbx3bjLrusWxox8t/5fXbjjftiteTmVAWkY GV+SpTAJltFj9CPRoYC3qauUCN9zZ2+wipkWGgqrdVhj7zcUFdPX4yz5Hpfc6yYW1nyp 5qrYF1tYIRXJjVOlg8RDqMXl2Tf1JuWe8pVC97ffrkcLHmNcuoWon6KbBmvH0PEbxXBE aoMZp0SNwOCaX9hqSsub2aKzT9I3tWaXela5BupNXZHWTZX/yGZBC6M6KKlaDKl+X+aW BJeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from :arc-authentication-results; bh=9sWxjSnqB285g2MlJ+DXBy+elb/Z8rvXWXDRNCqIG7g=; b=BrJ7Jf5aq9PykCDtXSIjQYUkLIffMreH+XOTSAQBquRD0UNiKuEzJvWj4sVDTx0WaL 3uQUYMHgcGaD2whnLz51qHD0K/7ZijIqtJP3g6gTPSsnKbtQ3WBeoFsit43rjE40Z4dn x737yT7RPaX/jX5KVVZdS8kVWABIZYgFmJHiyAhi3zYiFP9kTqwQ9Gkioliw2Wm+DCn/ cZKjNdZNLFWr9TfQCmr0yPiWK3kzMPJqb0NeTB0Kuz91LOyAoJ09ade/abci9tpmKLlv OfDUjb7onkDFDz/vcRVzuG5R/+6/XIPHHJY1mrNM/cTl5MKSehkQJpkTHSEu0Uz9041M X2mA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x15-v6si221062pgv.389.2018.06.12.08.06.21; Tue, 12 Jun 2018 08:06:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934297AbeFLPFl (ORCPT + 99 others); Tue, 12 Jun 2018 11:05:41 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58086 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932803AbeFLPFk (ORCPT ); Tue, 12 Jun 2018 11:05:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1B2B881A6D3A; Tue, 12 Jun 2018 15:05:40 +0000 (UTC) Received: from vitty.brq.redhat.com.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 79F4420284D6; Tue, 12 Jun 2018 15:05:38 +0000 (UTC) From: Vitaly Kuznetsov To: Tianyu Lan Cc: "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" , KY Srinivasan Subject: Re: [RFC Patch 3/3] KVM/x86: Add tlb_remote_flush callback support for vmcs References: <20180604090749.489-1-Tianyu.Lan@microsoft.com> <20180604090749.489-4-Tianyu.Lan@microsoft.com> Date: Tue, 12 Jun 2018 17:05:37 +0200 In-Reply-To: <20180604090749.489-4-Tianyu.Lan@microsoft.com> (Tianyu Lan's message of "Mon, 4 Jun 2018 09:08:34 +0000") Message-ID: <87lgbkqc3i.fsf@vitty.brq.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 12 Jun 2018 15:05:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 12 Jun 2018 15:05:40 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'vkuznets@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tianyu Lan writes: > Register tlb_remote_flush callback for vmcs when hyperv capability of > nested guest mapping flush is detected. The interface can help to reduce > overhead when flush ept table among vcpus for nested VM. The tradition way > is to send IPIs to all affected vcpus and executes INVEPT on each vcpus. > It will trigger several vmexits for IPI and INVEPT emulation. Hyperv provides > such hypercall to do flush for all vcpus. > > Signed-off-by: Lan Tianyu > --- > arch/x86/kvm/vmx.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index e50beb76d846..6cb241c05690 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -4737,6 +4737,17 @@ static inline void __vmx_flush_tlb(struct kvm_vcpu *vcpu, int vpid, > } > } > > +static int vmx_remote_flush_tlb(struct kvm *kvm) > +{ > + struct kvm_vcpu *vcpu = kvm_get_vcpu(kvm, 0); > + > + if (!VALID_PAGE(vcpu->arch.mmu.root_hpa)) > + return -1; > + > + return hyperv_flush_guest_mapping(construct_eptp(vcpu, > + vcpu->arch.mmu.root_hpa)); > +} > + > static void vmx_flush_tlb(struct kvm_vcpu *vcpu, bool invalidate_gpa) > { > __vmx_flush_tlb(vcpu, to_vmx(vcpu)->vpid, invalidate_gpa); > @@ -7495,6 +7506,10 @@ static __init int hardware_setup(void) > if (enable_ept && !cpu_has_vmx_ept_2m_page()) > kvm_disable_largepages(); > > + if (ms_hyperv.nested_features & HV_X64_NESTED_GUSET_MAPPING_FLUSH > + && enable_ept) > + kvm_x86_ops->tlb_remote_flush = vmx_remote_flush_tlb; > + You'll need to surround the above with #if IS_ENABLED(CONFIG_HYPERV) as ms_hyperv is otherwise unavailable. > if (!cpu_has_vmx_ple()) { > ple_gap = 0; > ple_window = 0; -- Vitaly