Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp246420pxb; Thu, 12 Nov 2020 02:46:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzSV6IXrCg/bT1KszkbCUwDWVQHkO1fqFQ2S15GkG07Tw3jqoEYko8K0OyeunEzDYb/x9LS X-Received: by 2002:a17:906:a195:: with SMTP id s21mr28595793ejy.146.1605177967879; Thu, 12 Nov 2020 02:46:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605177967; cv=none; d=google.com; s=arc-20160816; b=F7RIp24sJkLPE4xpc4QCoLBjhOjiaPgRSCAc+vis9j46yFEgKTGjroalpucylaQAKD qORJ7l8tAAFFcyl2cN8bGoXqsnSN7cOx6XknF0yGYPnKK3C9gYAbqjhf1bI8ZGvq5bTU 3zvPxmDR2pYgf0WiJ1eDSOkGozddQ/h7yBpRMIqcikp5QFEdoxdU/ZQMWjTEv1gyEzCi nFHDGRnP/Ojm2+IpHe/2hLPU36jSfkr4xRJlUIX2pkTQBZ3sqDSVV5L9iACurJ2lfFix h7Ug6sBqmoxQvbxDcJnEssy5b1Cp/h3/kz6m3WmsAo11i/v52qyxK8YMqtXzGUEmO0S0 0v6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=vKVFV4JnJGFcIAEtfnBGX30mXa0QZSGIDA3Q1iebpuY=; b=nrEn3sXasb1V0G9JuFgcGTTgpQCwcXNdSNXnBNa449haZINyCepRsVmRCPBr/HJ8a0 ZbidRRgwtIu/WJoNPyxalS5p7cwwEHiDlW1oSA0Eniiki3fVGw2343AbeTTAY4YPYWyk V0HkAwcGnFvvG1W+ONpO90mUfdvNRrhuWsKqTpQ5Mylin3FQSfqmGvrOb0v9sPlkg4zm 92TwoXUhRvWbIht+j1t4iXkkZv6HErbv6Ea3u/i9fI6Pb2SwXyPp5Xxt1znIlrqy+Eqc kQRj5GyY9XAlezsEtkjXzUqiS4eFkh99jnyAwOEvEOxLpBafdUGKls2/T6OAjy0awla3 UtXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bbbLtVk+; 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 f13si3600400edv.212.2020.11.12.02.45.45; Thu, 12 Nov 2020 02:46:07 -0800 (PST) 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=bbbLtVk+; 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 S1727960AbgKLKlq (ORCPT + 99 others); Thu, 12 Nov 2020 05:41:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38359 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727814AbgKLKlp (ORCPT ); Thu, 12 Nov 2020 05:41:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605177703; 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: in-reply-to:in-reply-to:references:references; bh=vKVFV4JnJGFcIAEtfnBGX30mXa0QZSGIDA3Q1iebpuY=; b=bbbLtVk+cm0UoluockYPyXOEzzVX6eCuv9U63f3oVylpOenqQdA+BTLMZFHeFCSe/92+GH TwPcOd2tsv7sHknL94Xnr72W/pVxjVyfy1abT332tKCQazcPRPBQKSNkSuQ2aDM6lOZpfs h3yzuu1vlevvd3ezMtDLByrBehPQI5s= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-27-yz_wXYYaMjO2bzRrJ_Dm1A-1; Thu, 12 Nov 2020 05:41:42 -0500 X-MC-Unique: yz_wXYYaMjO2bzRrJ_Dm1A-1 Received: by mail-wm1-f72.google.com with SMTP id y1so1983218wma.5 for ; Thu, 12 Nov 2020 02:41:41 -0800 (PST) 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; bh=vKVFV4JnJGFcIAEtfnBGX30mXa0QZSGIDA3Q1iebpuY=; b=tCUHOlVFYvuk8ona75N3relgs50KgMjkzLTrrgMu2V6NUYGaXQDwFREDT+GynmpduS r/SzYhZakzDYqtKt+YRg3zIK1MdTHYasCTP2LXSUSsNiiA4zATb8c/o57QmHg3FnoiEl ZOlM3Dx1eD1buPMxbfJ8e39ZU3M1B0fAs0IFcR4tBXfWzWgeOrrnObNt1PeBgJ17UfGS 1t6AWwIjyq0BOwg7dO9ozTuKbdH92T5ul9jAi/xJaArDMyNIMH4E21dWRka1x867ybMm HbQC9R+hcpCcYrMsUGOl69sZFV1U6MOJAQz+bILqw/Yd3pi4zHf7EJXjWNgypg7w4Pv/ Smeg== X-Gm-Message-State: AOAM531ARzzpC3x6pZZzVU5hWYJ/gxBbcwokQQA6aAK3Qftun4PcxBxs tz0DWrCMyacSNx+AdhgK0PQkXmI45DbHdk/c+OBO077hFK0PGLbYzXJ4QitFMlYVA3CH7V/wSK5 NV0ZFZoSJM/Y+J/fZjOTVX23MUo+W0dUl7BhDlQh34UpfN8cPoFEPhGLUjtKJSeYDvvJNsmq6X6 L1 X-Received: by 2002:a1c:dd41:: with SMTP id u62mr8664719wmg.78.1605177700625; Thu, 12 Nov 2020 02:41:40 -0800 (PST) X-Received: by 2002:a1c:dd41:: with SMTP id u62mr8664702wmg.78.1605177700427; Thu, 12 Nov 2020 02:41:40 -0800 (PST) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id s9sm7105814wrf.90.2020.11.12.02.41.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2020 02:41:39 -0800 (PST) From: Vitaly Kuznetsov To: Sean Christopherson Cc: Paolo Bonzini , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 04/11] KVM: VMX: Fold Hyper-V EPTP checking into it's only caller In-Reply-To: <20201027212346.23409-5-sean.j.christopherson@intel.com> References: <20201027212346.23409-1-sean.j.christopherson@intel.com> <20201027212346.23409-5-sean.j.christopherson@intel.com> Date: Thu, 12 Nov 2020 11:41:38 +0100 Message-ID: <87blg2zwkd.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sean Christopherson writes: > Fold check_ept_pointer_match() into hv_remote_flush_tlb_with_range() in > preparation for combining the kvm_for_each_vcpu loops of the ==CHECK and > !=MATCH statements. > > No functional change intended. > > Signed-off-by: Sean Christopherson > --- > arch/x86/kvm/vmx/vmx.c | 44 +++++++++++++++++++----------------------- > 1 file changed, 20 insertions(+), 24 deletions(-) > > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index a6442a861ffc..f5e9e2f61e10 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -472,28 +472,6 @@ static const u32 vmx_uret_msrs_list[] = { > static bool __read_mostly enlightened_vmcs = true; > module_param(enlightened_vmcs, bool, 0444); > > -/* check_ept_pointer() should be under protection of ept_pointer_lock. */ > -static void check_ept_pointer_match(struct kvm *kvm) > -{ > - struct kvm_vcpu *vcpu; > - u64 tmp_eptp = INVALID_PAGE; > - int i; > - > - kvm_for_each_vcpu(i, vcpu, kvm) { > - if (!VALID_PAGE(tmp_eptp)) { > - tmp_eptp = to_vmx(vcpu)->ept_pointer; > - } else if (tmp_eptp != to_vmx(vcpu)->ept_pointer) { > - to_kvm_vmx(kvm)->hv_tlb_eptp = INVALID_PAGE; > - to_kvm_vmx(kvm)->ept_pointers_match > - = EPT_POINTERS_MISMATCH; > - return; > - } > - } > - > - to_kvm_vmx(kvm)->hv_tlb_eptp = tmp_eptp; > - to_kvm_vmx(kvm)->ept_pointers_match = EPT_POINTERS_MATCH; > -} > - > static int kvm_fill_hv_flush_list_func(struct hv_guest_mapping_flush_list *flush, > void *data) > { > @@ -523,11 +501,29 @@ static int hv_remote_flush_tlb_with_range(struct kvm *kvm, > struct kvm_vmx *kvm_vmx = to_kvm_vmx(kvm); > struct kvm_vcpu *vcpu; > int ret = 0, i; > + u64 tmp_eptp; > > spin_lock(&kvm_vmx->ept_pointer_lock); > > - if (kvm_vmx->ept_pointers_match == EPT_POINTERS_CHECK) > - check_ept_pointer_match(kvm); > + if (kvm_vmx->ept_pointers_match == EPT_POINTERS_CHECK) { > + kvm_vmx->ept_pointers_match = EPT_POINTERS_MATCH; > + kvm_vmx->hv_tlb_eptp = INVALID_PAGE; > + > + kvm_for_each_vcpu(i, vcpu, kvm) { > + tmp_eptp = to_vmx(vcpu)->ept_pointer; > + if (!VALID_PAGE(tmp_eptp)) > + continue; > + > + if (!VALID_PAGE(kvm_vmx->hv_tlb_eptp)) { > + kvm_vmx->hv_tlb_eptp = tmp_eptp; > + } else if (kvm_vmx->hv_tlb_eptp != tmp_eptp) { > + kvm_vmx->hv_tlb_eptp = INVALID_PAGE; > + kvm_vmx->ept_pointers_match > + = EPT_POINTERS_MISMATCH; > + break; > + } > + } > + } > > if (kvm_vmx->ept_pointers_match != EPT_POINTERS_MATCH) { > kvm_for_each_vcpu(i, vcpu, kvm) { Reviewed-by: Vitaly Kuznetsov -- Vitaly