Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4821028pxu; Wed, 21 Oct 2020 06:17:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0E0C+RYiXVgqwOYWBrNZxfLJN4Ov3VuBFLRpxVg3V/XKeejN0rTN4d8Jqzgx+FdNRYIvY X-Received: by 2002:a17:907:4301:: with SMTP id nh1mr3230661ejb.397.1603286227124; Wed, 21 Oct 2020 06:17:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603286227; cv=none; d=google.com; s=arc-20160816; b=cBiQ/b/bidRDAnRtHEnk76mo80L+xe4fnPAClj9ksEEsXyT20DkX3zNGxr8CIz2QKM OX5Iv+KCY8XfmccRLNJBLY3X4xMyArXfpbbs2wqYvxTZicTKp4H1gQJnl3HubCG4N9VF 0kkPLnwaV4TCbKaRjVyolp6zvdTNooRTMBn+cWLgCQGNlk9vyNIgoBn1tv5ZjlI1ac+T Xpi0Mqd0ZHiRo1Kzr0x0sIXzIekTG73OSuXpS+DkXP1XNnzgn2eky2JOwcvNQUyl7OXM IpQ5UiIZRrU3+lL/6RbOSB2+6oTEdjlj4uQHNDNhLkuZFVO402iTAevukW6XmAFdTrtA ttoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=BuwkUAjLlfFrMB6xaXRKIQfvGDBRzOXmT/8rwImt4Tc=; b=tB4F27vRmUIzw9DjqpvmRh4t83RHVjGl/+AS+FXk2INwuUT43TOADNKD7LuZVtReiq 7JXFhqldHdBuvr4l1v+DgVAMtP5R3ZULItzX0z1j0/OlkX78XqF5gBhKQiA3lN+7LG3z EEkgtW6O2yt54y+lAlYwbRBCGbNckKAOTE4IqIf3y3ts6YRiDW8taOZcIruPcnUND2zl tqEiX1YXUtyaIvROVJ2IemkqePDa6RJv/5cx0MMSgjQtP1mcMIND1zoDruBGYfvbaNGR ZX7+DeUFdbwA39d0msB6X8d5mqyyPHsLwi3VPoHm3gZf+tHtlQkzPHf9utwC9/igyTLY CYzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XGDROQ2b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e4si1353248edv.228.2020.10.21.06.16.44; Wed, 21 Oct 2020 06:17:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XGDROQ2b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437739AbgJUJSd (ORCPT + 99 others); Wed, 21 Oct 2020 05:18:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56035 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437623AbgJUJSc (ORCPT ); Wed, 21 Oct 2020 05:18:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603271910; 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=BuwkUAjLlfFrMB6xaXRKIQfvGDBRzOXmT/8rwImt4Tc=; b=XGDROQ2b9LP9Auj2eouSrz4DmFP7lvxWAc+sQybxzUzXLsry73PzfpnsUX1m26f43VwqgJ AnQ06kPP1Yc6sKmNQeDRo3JPTFcujNgY+HLm+jtKuTjQR322AS/2JRSEhy6cANeV2mJjEH 80jkP5cJLyKuVSIG0EzUmcGbxMvz5y4= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-482-XMsFoiQYNgehE3m6EyhvNw-1; Wed, 21 Oct 2020 05:18:28 -0400 X-MC-Unique: XMsFoiQYNgehE3m6EyhvNw-1 Received: by mail-ej1-f69.google.com with SMTP id p19so1518556ejy.11 for ; Wed, 21 Oct 2020 02:18:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=BuwkUAjLlfFrMB6xaXRKIQfvGDBRzOXmT/8rwImt4Tc=; b=e6KuYCvpw11bvPl4vH0s8Vt5+2lwlmQxSepsLfeV8fo9wOMqxIngCSw+QlLllvVf34 yCqyCOFEH+OPXGaLzmfoVImaQ1Ar34/cOHmk7nLIB4ngEhZzuXjR0wMcyF0dHjRbBLqd UvSQh/CBLf7drw00jEuuZF/o3cE6aoZSuYBm6h13ASghhtpBeT4jdY3DlvIgFHNoOOf+ YRI2RUYMJDt1TtHlNX0SOJBjqMUhsxOCSjyfp3yj5o+6vtTqLU7o3+Vf6lssX1PygWiy /lOxwM/wQKs/NRehWMWEN4Ypb17ThsCfj43SWiZNXppua/eZkKwK1lRWjJ0aWkjVBgWR kESQ== X-Gm-Message-State: AOAM531MkaX9VEgCvrIfuImaS3bk8tH/VDVRWj0pL9ymAyi2TgDYxZuC JhZw3KnR8CAmHkC8CBBDCnthlXMAUeeBrQOfkAVmGhPiDWrdrEn81istu6R/KKS3qFl0dvBXh7/ RJLVCaIuqLVJni4nbvocc0N5H X-Received: by 2002:a17:906:395a:: with SMTP id g26mr2442206eje.147.1603271907185; Wed, 21 Oct 2020 02:18:27 -0700 (PDT) X-Received: by 2002:a17:906:395a:: with SMTP id g26mr2442191eje.147.1603271906947; Wed, 21 Oct 2020 02:18:26 -0700 (PDT) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id e17sm1886517ejh.64.2020.10.21.02.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 02:18:26 -0700 (PDT) From: Vitaly Kuznetsov To: Sean Christopherson Cc: Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini Subject: Re: [PATCH v2 00/10] KVM: VMX: Clean up Hyper-V PV TLB flush In-Reply-To: <20201020215613.8972-1-sean.j.christopherson@intel.com> References: <20201020215613.8972-1-sean.j.christopherson@intel.com> Date: Wed, 21 Oct 2020 11:18:25 +0200 Message-ID: <87d01c544e.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sean Christopherson writes: > Clean up KVM's PV TLB flushing when running with EPT on Hyper-V, i.e. as > a nested VMM. The terminology we use is a bit confusing and I'd like to use the opportunity to enlighten myself on how to call "PV TLB flushing" properly :-) Hyper-V supports two types of 'PV TLB flushing': HvFlushVirtualAddressSpace/HvFlushVirtualAddressList[,Ex] which is described in TLFS as ".. hypercall invalidates ... virtual TLB entries that belong to a specified address space." HvFlushGuestPhysicalAddressSpace/HvFlushGuestPhysicalAddressList which in TLFS is referred to as "... hypercall invalidates cached L2 GPA to GPA mappings within a second level address space... hypercall is like the execution of an INVEPT instruction with type “single-context” on all processors" and INVEPT is defined in SDM as "Invalidates mappings in the translation lookaside buffers (TLBs) and paging-structure caches that were derived from extended page tables (EPT)." (and that's what this series is about) and every time I see e.g. 'hv_remote_flush_tlb.*' it takes me some time to recall which flushing is this related to. Do you by any chance have any suggestions on how things can be improved? > 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. > Looks like a nice cleanup, thanks! > Ran Hyper-V KVM unit tests (if those are even relevant?) No, they aren't. KVM doesn't currently implement HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_LIST so we can't test this feature outside of a real Hyper-V environment. We also don't yet test KVM-on-KVM with Enlightened VMCS ... > but haven't actually tested on top of Hyper-V. Just in case you are interested in doing so and there's no Hyper-V server around, you can either search for a Win10 desktop around or just spin an Azure VM where modern instance types (e.g. Dv3/v4, Ev3/v4 families, Intel only - so no Ea/Da/...) have VMX and PV Hyper-V features exposed. I'm going to give this a try today and I will also try to review individual patches, thanks again! > > v2: Rewrite everything. > > Sean Christopherson (10): > 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 PGD instead of EPTP for paravirt Hyper-V TLB flush > > arch/x86/kvm/vmx/vmx.c | 102 ++++++++++++++++++++--------------------- > arch/x86/kvm/vmx/vmx.h | 16 +++---- > 2 files changed, 57 insertions(+), 61 deletions(-) -- Vitaly