From patchwork Tue Nov 1 14:54:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Kuznetsov X-Patchwork-Id: 13711 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3021101wru; Tue, 1 Nov 2022 07:58:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5qRYeOD3TDzNmGtL/waMzIrSJ6K0v952WxRY3ouMhrVp8JiTVwYX7ingL2hWIXXRHY4OhY X-Received: by 2002:a17:906:cc5b:b0:7a9:e58d:bad9 with SMTP id mm27-20020a170906cc5b00b007a9e58dbad9mr18456483ejb.237.1667314737269; Tue, 01 Nov 2022 07:58:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667314737; cv=none; d=google.com; s=arc-20160816; b=rzUIY3uaHXRiv1STKzDZaMtJ9dVwDpcQJD/NZN8pVxRe0ZJKj7kgkwAoG6qBUXzZK6 JTWIktv2VWfXAJrQ5imUqutqvKV2IUD5QP1z2IWN9D2Iy/Yt5HcstMRwl+lF2sebBHA0 k8Yy6yl2zTnBTgn301VA8TsmG1DyxQsF3f4y/2LlQ2Ixh7qeIebPzxOTlqXU6NY6g1qY mZvC9nHhwcYIgfcrvpXGagqwnqCIwmz6fjV6HGqbRb5+Uswj5bJe0Y3yekd5xM8ohqsG /JDdA+D3Yj1F1TkbWjwi4QSe2Lf9PLUg2AREoDjbdrWi+MBGIH1vnfZ8WxM1g62ZFpRA 5CTQ== 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=BXXbLgwdgUkN7FSSlfy+wa5/rPUmeVnPXj9kxjAQ1x4=; b=eclpzymhI1L4luKn2MFXfBkrMCHkqKwKkB51X3CjcDP2nSC0w3FkAvey/yQabL6/Hy UWzQJ8NfxNQoyfbicPo9QaRMMpOl7Q32A3rhyX0kGjjF/51rsSwrXlCM0oifMNnpH/oc 3fBGmr41wYIh7i4KhbUt3mM5bcbFsF2Ql5KSWB/2aarcFXO/CWS9yjCruP7b8NMRntW5 1o1Ge8EBqxjBk50wZbePoTMCyFQqxF2EHudMaOtBmrsyGUQmDRDavOIypBCScD6Svx/X G7AjMAeJ2V/11rUirfebowHyubnovoW9NiqNY5M+F1o3DNLVa5CaE+EesRYpK2PfIaUp 7uWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HNJF4kqn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m17-20020a056402511100b00459b0141076si12790234edd.465.2022.11.01.07.58.33; Tue, 01 Nov 2022 07:58:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HNJF4kqn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231292AbiKAO5m (ORCPT + 99 others); Tue, 1 Nov 2022 10:57:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231193AbiKAO4s (ORCPT ); Tue, 1 Nov 2022 10:56:48 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07A9F1C918 for ; Tue, 1 Nov 2022 07:55:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667314543; 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=BXXbLgwdgUkN7FSSlfy+wa5/rPUmeVnPXj9kxjAQ1x4=; b=HNJF4kqnUFbWrGS3Mgms/4pseNBy8W9Nxev87ZCpS9irEM/5qmI0K1s1BkCjRE6tdvaKJH ZpqaIF8xEhI5bf3Ad0drK/YNbq6XnoJ5UUBVumF5htbkmR8FPnV/HZtDfGRBf21yz9nuMa 7+9X9kTdFYOJal8nzAlh7fYPeDlIOFY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-299--P9Y9Hl0OT2gGGUIcNIkQg-1; Tue, 01 Nov 2022 10:55:42 -0400 X-MC-Unique: -P9Y9Hl0OT2gGGUIcNIkQg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 971B53C32C52; Tue, 1 Nov 2022 14:55:41 +0000 (UTC) Received: from ovpn-194-149.brq.redhat.com (ovpn-194-149.brq.redhat.com [10.40.194.149]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DF76C15BB9; Tue, 1 Nov 2022 14:55:39 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson Cc: Wanpeng Li , Jim Mattson , Michael Kelley , Siddharth Chandrasekaran , Yuan Yao , Maxim Levitsky , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v13 22/48] KVM: x86: hyper-v: Introduce kvm_hv_is_tlb_flush_hcall() Date: Tue, 1 Nov 2022 15:54:00 +0100 Message-Id: <20221101145426.251680-23-vkuznets@redhat.com> In-Reply-To: <20221101145426.251680-1-vkuznets@redhat.com> References: <20221101145426.251680-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748306218213498792?= X-GMAIL-MSGID: =?utf-8?q?1748306218213498792?= 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 Reviewed-by: Sean Christopherson Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/x86/kvm/hyperv.h b/arch/x86/kvm/hyperv.h index 8942e8c6c912..5f9c76b45f46 100644 --- a/arch/x86/kvm/hyperv.h +++ b/arch/x86/kvm/hyperv.h @@ -177,6 +177,23 @@ static inline void kvm_hv_vcpu_purge_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); +} + int kvm_hv_vcpu_flush_tlb(struct kvm_vcpu *vcpu); #endif