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=-12.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable 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 CAFE0C43331 for ; Mon, 8 Mar 2021 11:51:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DA3865126 for ; Mon, 8 Mar 2021 11:51:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231417AbhCHLuo (ORCPT ); Mon, 8 Mar 2021 06:50:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:49391 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229972AbhCHLub (ORCPT ); Mon, 8 Mar 2021 06:50:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615204231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O0TFSYLha6a0vpq1M3uSXuHRS2yOwWaJYpG7AjZVTwo=; b=GvBDUw6woAkWCBS0LRJlgKqEyRkdNgLOfxfU9BVssErthj58H0VMiq0Pcv8JlwM/DmtFhz Ncom9CS2uKKO7VkwDuaZWCqCbv5qFsHzdYQFeeS6I7U9ANc7e1NMt4cGYtXYnvGRd4uvGv bmibKlZ+gqHiVIcpQCFDDtkafYY2ctU= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-536-j6ASyqCRN3iYLIo6JpnOkQ-1; Mon, 08 Mar 2021 06:50:29 -0500 X-MC-Unique: j6ASyqCRN3iYLIo6JpnOkQ-1 Received: by mail-wm1-f69.google.com with SMTP id s192so4856764wme.6 for ; Mon, 08 Mar 2021 03:50:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=O0TFSYLha6a0vpq1M3uSXuHRS2yOwWaJYpG7AjZVTwo=; b=Eyu2OeKdwsGyt1hoYMgMaP6ZywN7bJ70drMizwuGdsK9acedpf48RsNHJ1n3J0IQl1 lqzdP2TkAQV9Mg+pp24Uafu2XqNU1AwOFxB/vnwJMlzA3oMIuoLMlk8xXvlSH802+p/K ElRSpPfvamdrX9/opYRDFqYmWvizx+nwAG40CC6rOug8qQyNP6RXJadiyLOi2akLlwCs uQ0BcUzTzp7M8u9GlRvQ1j9AqjM5LFLi8y1d3GNh6nczdvRok0VslZ2qBkNZQR1k1gIs t9ebQASpcnRTq74UGAfmK26p3IH5PgWMr08cLDHSvmkA5LVLuvu9dTjOOrlekICjzO+L cE2g== X-Gm-Message-State: AOAM532J55wjK7uV7mfiKEK2YJQRwUpexCdhCaauEaAt0tDpqlw815Tb lLAJBl21zwyFgH5VdQpNcUWLurrhU1DwK/H2AW6tqYLqKISN9TM3b81y+1rCke8+orWyL1axwkI QG/7LS4JAkdcD6Zf4fyHKyE7l X-Received: by 2002:a5d:4dd2:: with SMTP id f18mr22511953wru.366.1615204228215; Mon, 08 Mar 2021 03:50:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJfXvs2sG6TtEy9A4UyNy1PtgCnl/jo51idx7hQhuh6QVMESxcW2SeBdv1/Mfl+RV0rw6hyw== X-Received: by 2002:a5d:4dd2:: with SMTP id f18mr22511935wru.366.1615204228004; Mon, 08 Mar 2021 03:50:28 -0800 (PST) Received: from ?IPv6:2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e? ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id e8sm19283591wme.14.2021.03.08.03.50.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Mar 2021 03:50:27 -0800 (PST) Subject: Re: [PATCH v4 00/11] KVM: VMX: Clean up Hyper-V PV TLB flush To: Sean Christopherson Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson References: <20210305183123.3978098-1-seanjc@google.com> From: Paolo Bonzini Message-ID: Date: Mon, 8 Mar 2021 12:50:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <20210305183123.3978098-1-seanjc@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/03/21 19:31, Sean Christopherson wrote: > Clean up KVM's PV TLB flushing when running with EPT on Hyper-V, i.e. as > a nested VMM. No real goal in mind other than the sole patch in v1, which > is a minor change to avoid a future mixup when TDX also wants to define > .remote_flush_tlb. Everything else is opportunistic clean up. > > NOTE: Based on my NPT+SME bug fix series[*] due to multiple conflicts with > non-trivial resolutions. > > [*] https://lkml.kernel.org/r/20210305011101.3597423-1-seanjc@google.com > > > Patch 1 legitimately tested on VMX and SVM (including i386). Patches 2+ > smoke tested by hacking usage of the relevant flows without actually > routing to the Hyper-V hypercalls (partial hack-a-patch below). > > -static inline int hv_remote_flush_root_ept(hpa_t root_ept, > +static inline int hv_remote_flush_root_ept(struct kvm *kvm, hpa_t root_ept, > struct kvm_tlb_range *range) > { > - if (range) > - return hyperv_flush_guest_mapping_range(root_ept, > - kvm_fill_hv_flush_list_func, (void *)range); > - else > - return hyperv_flush_guest_mapping(root_ept); > + if (range) { > + kvm_make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH); > + return 0; > + } > + > + return -ENOMEM; > } > > static int hv_remote_flush_tlb_with_range(struct kvm *kvm, > @@ -7753,8 +7754,7 @@ static __init int hardware_setup(void) > vmx_x86_ops.update_cr8_intercept = NULL; > > #if IS_ENABLED(CONFIG_HYPERV) > - if (ms_hyperv.nested_features & HV_X64_NESTED_GUEST_MAPPING_FLUSH > - && enable_ept) { > + if (enable_ept) { > vmx_x86_ops.tlb_remote_flush = hv_remote_flush_tlb; > vmx_x86_ops.tlb_remote_flush_with_range = > hv_remote_flush_tlb_with_range; > > v4: > - Rebased to kvm/queue, commit fe5f0041c026 ("KVM/SVM: Move vmenter.S > exception fixups out of line"), plus the aforementioned series. > - Don't grab PCID for nested_cr3 (NPT). [Paolo] > - Collect reviews. [Vitaly] > > v3: > - https://lkml.kernel.org/r/20201027212346.23409-1-sean.j.christopherson@intel.com > - Add a patch to pass the root_hpa instead of pgd to vmx_load_mmu_pgd() > and retrieve the active PCID only when necessary. [Vitaly] > - Selectively collects reviews (skipped a few due to changes). [Vitaly] > - Explicitly invalidate hv_tlb_eptp instead of leaving it valid when > the mismatch tracker "knows" it's invalid. [Vitaly] > - Change the last patch to use "hv_root_ept" instead of "hv_tlb_pgd" > to better reflect what is actually being tracked. > > v2: > - Rewrite everything. > - https://lkml.kernel.org/r/20201020215613.8972-1-sean.j.christopherson@intel.com > > v1: ??? > > Sean Christopherson (11): > KVM: x86: Get active PCID only when writing a CR3 value > KVM: VMX: Track common EPTP for Hyper-V's paravirt TLB flush > KVM: VMX: Stash kvm_vmx in a local variable for Hyper-V paravirt TLB > flush > KVM: VMX: Fold Hyper-V EPTP checking into it's only caller > KVM: VMX: Do Hyper-V TLB flush iff vCPU's EPTP hasn't been flushed > KVM: VMX: Invalidate hv_tlb_eptp to denote an EPTP mismatch > KVM: VMX: Don't invalidate hv_tlb_eptp if the new EPTP matches > KVM: VMX: Explicitly check for hv_remote_flush_tlb when loading pgd > KVM: VMX: Define Hyper-V paravirt TLB flush fields iff Hyper-V is > enabled > KVM: VMX: Skip additional Hyper-V TLB EPTP flushes if one fails > KVM: VMX: Track root HPA instead of EPTP for paravirt Hyper-V TLB > flush > > arch/x86/include/asm/kvm_host.h | 4 +- > arch/x86/kvm/mmu.h | 4 +- > arch/x86/kvm/svm/svm.c | 10 ++- > arch/x86/kvm/vmx/vmx.c | 134 ++++++++++++++++++-------------- > arch/x86/kvm/vmx/vmx.h | 19 ++--- > 5 files changed, 92 insertions(+), 79 deletions(-) > Huh, I was sure I had queued this already for 5.12. Well, done so now. Paolo