Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp225103iof; Mon, 6 Jun 2022 02:02:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweN/LhNLXVKUJKGh0gWOdaEa3sEW9ml5bJH7kiGcyEfj3U2fvrgAVYvXdEx8EJ4a3OEh8q X-Received: by 2002:a17:902:d481:b0:167:770b:67c with SMTP id c1-20020a170902d48100b00167770b067cmr6133983plg.77.1654506172101; Mon, 06 Jun 2022 02:02:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654506172; cv=none; d=google.com; s=arc-20160816; b=Glo4RwEhcuj1KGhSnXbt+U6IKJraFg8mg3C0GfSQxKiZLDO67qikd7ztuIGj3C7Vgl gyvp1uljlEKEzUs02UEaShs1wqvqGFXoAO4heR/xeyGM72EmOy6Ueh5xSM/PZuNfBhTr tTBfeZEjF2qdQkzXw+WUEb5Lv+LRPBxENBP75/fEdYWJzhAlQ6OT6DQkrsPe44QGX8so JrPXIgLbjSwIqbw6rzgUW3Sc3Eee96z86PbbHK5aQhhhMqFoZ8HWJZ148lkJHlsttWbY 0nklPbn1CKT7JYB1YNyu87YejY01XYQTFuijppNK/K3nb37Ci6mmM4QZHGUAiF0D04T5 nOvQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pDMtuQHCKDck2X6AJwzMNfVZUyOuSlNQEZTxeqxbFoc=; b=Xr5z5emMaSzoWP7KX18Goyp9WG197Ri5sQ7dM81/fFU9ekm+niC7RJ7GiZ4PrhXfY1 1Jtx0l6Q0vVBEgZh/diJ2vKuVlqrg392ERszCrR3QvvJ92Zs3loP6wlHPXFVDQi+FXb8 fdgHCfXbU0N/9PyhXrXclufAyZVEfbGw1eimyzzl+vVLCJyLk/kU4i7OJXDWWcGk/BJe FAP7BtJAX2mJcHYGBSrnWBjHLD/NEsjzozN54kSHTFWeVmiJf7UaWF7LcDl8MLZDimii dpN45C3bMnDCtP7gll3zeSQqIJY7t4PhLAhf7UTxBG+xoDquQbwUx4jxINDGqWSJZB0g BRhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JWzTuMoP; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j9-20020a170902758900b00163ed0ec590si20657581pll.538.2022.06.06.02.02.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 02:02:52 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JWzTuMoP; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A804E50463; Mon, 6 Jun 2022 01:39:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232303AbiFFIjF (ORCPT + 99 others); Mon, 6 Jun 2022 04:39:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231995AbiFFIhu (ORCPT ); Mon, 6 Jun 2022 04:37:50 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B635621261 for ; Mon, 6 Jun 2022 01:37:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654504660; 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=pDMtuQHCKDck2X6AJwzMNfVZUyOuSlNQEZTxeqxbFoc=; b=JWzTuMoPpNfoww/rWTbdtBSQ0FiEsb46srSAUbjhTVSGnmnlcIh3BfGdkQWl4FuuiY6U6H Ycc6z41ZDtsUxCk9YJEG0mkaF0xy+RfcjrHdo2SKaNvzG41nLF35kywt7nQKrbx5ErGk4K JCjUxTLokpAsNQEfC9k/8DE0Fc9FMGU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-284-POGzVxiwOoWt3_bKz-TBQA-1; Mon, 06 Jun 2022 04:37:37 -0400 X-MC-Unique: POGzVxiwOoWt3_bKz-TBQA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0A6A7811E76; Mon, 6 Jun 2022 08:37:37 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.193.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC26D1121314; Mon, 6 Jun 2022 08:37:34 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , Michael Kelley , Siddharth Chandrasekaran , Yuan Yao , Maxim Levitsky , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 16/38] KVM: x86: hyper-v: Introduce kvm_hv_is_tlb_flush_hcall() Date: Mon, 6 Jun 2022 10:36:33 +0200 Message-Id: <20220606083655.2014609-17-vkuznets@redhat.com> In-Reply-To: <20220606083655.2014609-1-vkuznets@redhat.com> References: <20220606083655.2014609-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The newly introduced helper checks whether vCPU is performing a Hyper-V TLB flush hypercall. This is required to filter out L2 TLB flush hypercalls for processing. Reviewed-by: Maxim Levitsky Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/x86/kvm/hyperv.h b/arch/x86/kvm/hyperv.h index 207d24efdc5a..dc46c5ed5d18 100644 --- a/arch/x86/kvm/hyperv.h +++ b/arch/x86/kvm/hyperv.h @@ -171,6 +171,24 @@ static inline void kvm_hv_vcpu_empty_flush_tlb(struct kvm_vcpu *vcpu) kfifo_reset_out(&tlb_flush_fifo->entries); } + +static inline bool kvm_hv_is_tlb_flush_hcall(struct kvm_vcpu *vcpu) +{ + struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu); + u16 code; + + if (!hv_vcpu) + return false; + + code = is_64_bit_hypercall(vcpu) ? kvm_rcx_read(vcpu) : + kvm_rax_read(vcpu); + + return (code == HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE || + code == HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST || + code == HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX || + code == HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX); +} + void kvm_hv_vcpu_flush_tlb(struct kvm_vcpu *vcpu); -- 2.35.3