Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp375428imn; Wed, 3 Aug 2022 07:36:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR65laUMxrkpGvzCUwAEJYfpKWZI6zDnWyZ4OUq7ziuBH1tXXnUba00vFW5PyXHK/w9A+fez X-Received: by 2002:a17:902:ba91:b0:16c:6b8e:cd06 with SMTP id k17-20020a170902ba9100b0016c6b8ecd06mr26164683pls.33.1659537402764; Wed, 03 Aug 2022 07:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659537402; cv=none; d=google.com; s=arc-20160816; b=ARi9MDd5WXaQY+cOgZmhH/D5WotnpZ698Ds7aq03SU56le/y1BC+xc3JELfaBHmjA3 mxTUlYXl2QRR/k16LKYv68+aw9NZlciRks9m1gnNhpCHu8ksu+1ID7jOhJBgQ8OLQjY5 CIcvaG4w/U/ROIiiQWmZapclAqyhbiUdGJ6sxQ0jOcn0WF+he/tdri2gTzBU+wihCujD LYJjCwXihe6yFJd7IwqLXRG9mft1/ZG2t6jt65s0K67m6q3CwkveXnT6bNR52GRa9mjw txKpWac/Yh0Ltd4mcsCDF+RB9R8y/sFHwVtHRnYzc+rKq0CG1yV149BPbuQj4PJ1QVII uRbw== 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=czVSfgeJdT0ENI1O87zKlSMPq/hlgeK5s27AHY9iFeg=; b=omnwCNxGxkgQes5R6lHrNXf9SpLiwHyvPJ5LyC4A9e46/G/17aGe2QG5gtyJ7wCQeJ hP+XzOpM9cc5CAaBPG8yigAnbHIG9fPwGQi4HWdQFOcun5WnPitOFpyqSFMW6QepXToG b6VJ44Cq01vpel2gpbaOgbPIL2q9XWGbuTTEEWpRS7PKLuGq6YvOW0kk/xcmOUAXMWFx 4A9cwFtWQP2kv6XsN9RiCQWH/h6J8IX73zgS8xlnar2xCkh1et56p+CV+817Gz5sT9sn tuK17BxtSGwwBmz6PzT9rlcU1FNmVEBC+RCpMa5SfYEfHPykDFVDMfObCMEr3en2CfjZ ApZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WhtV+tjr; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o9-20020a170902778900b0016ef089881bsi2265262pll.252.2022.08.03.07.36.27; Wed, 03 Aug 2022 07:36:42 -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=WhtV+tjr; 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 S238273AbiHCNq0 (ORCPT + 99 others); Wed, 3 Aug 2022 09:46:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238232AbiHCNqM (ORCPT ); Wed, 3 Aug 2022 09:46:12 -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 ESMTP id DB24C1EEC9 for ; Wed, 3 Aug 2022 06:46:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659534361; 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=czVSfgeJdT0ENI1O87zKlSMPq/hlgeK5s27AHY9iFeg=; b=WhtV+tjrKmbu9Kvkag4O7rD+LPKeUssIin/niRB6g8vBTcUDHqx1nLyCwncjqDYTAtrfGU 3PutempUDo0EF44CCUlHV+UY5BK1xsdm4dIIoe31di37nu1sitXASfd2ejeQdIxvZKsKV8 9q4ANKvDMzUCR+ZLMNKlH2O4Myur8RU= 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-85-X-Zt0wjnPreaLsEv7C-wtA-1; Wed, 03 Aug 2022 09:45:57 -0400 X-MC-Unique: X-Zt0wjnPreaLsEv7C-wtA-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 0AB1483DE57; Wed, 3 Aug 2022 13:45:57 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.195.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id A878DC27D95; Wed, 3 Aug 2022 13:45:54 +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 v9 16/40] KVM: x86: hyper-v: Introduce kvm_hv_is_tlb_flush_hcall() Date: Wed, 3 Aug 2022 15:45:54 +0200 Message-Id: <20220803134554.399275-1-vkuznets@redhat.com> In-Reply-To: <20220803134110.397885-1-vkuznets@redhat.com> References: <20220803134110.397885-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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 8a902b59aa46..239946ea483b 100644 --- a/arch/x86/kvm/hyperv.h +++ b/arch/x86/kvm/hyperv.h @@ -172,6 +172,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