Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2461249rwi; Tue, 1 Nov 2022 08:00:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM76m3bT7HK5m7tnxdIFCDdNjnBBC9UOnHgzXRdj5PCrkzqzL/AyKQZtuXy5BnckWjI17HBd X-Received: by 2002:a17:906:dc8f:b0:7a5:8160:1995 with SMTP id cs15-20020a170906dc8f00b007a581601995mr18898029ejc.500.1667314830570; Tue, 01 Nov 2022 08:00:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667314830; cv=none; d=google.com; s=arc-20160816; b=Wjy3rb6rYIPvwdgQV3lRjKyF01DUzc+6s7UlpxWLt8nOSHkiBQsY7hcII/dCbZSNHB vc638x0HFoiGJYijjrYnpcmvHcwghN6CpVqa8FBY+H8l+SYSUbPNpbYilg5Epx1njYgb X8UgnDe5Yjo5JMcB7zUHZQHTaL+0eBfvik/1j7cXealBubmd6estSq3X0XamPtxBCGz+ 8hpkqHesb7XouU71QBGuoX9TO8kk1pjHeXEZfdc0zOyQx/l/zugxzNqpo80fOCX2a3Zx I+5vERoiHKD1MiR3zwittTv/p/yk/QXnbNi5RJ12f3hqaqyd6uQxaHDdD2/rgT7YaWS3 XCJw== 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=EwIDPaua6Yy34C32ji+3GN+Mv0Eg+tlMnWsZUq1Kxzc=; b=NYDIWybkuUipjg/84ow0xbpzcRXXnxuQa0YmzmKNY0S0U7sd5SlMRe7Ak5Cg5wVYQi p1FV92cQYeqxEg8PBxEZQ/V1Niho/x7+AEhtxaDT7q8fztnXeuGEKYMhRkBhkoBR1ROi JyVjhqKXZojO5JUrcGTyX3hfyGfPBHZyiy7JKXngUh1X6L2GCQR1mKch5HADAQeU1VQw eHXKCNnF4BLGeNdGV4k8Nfa31mV5ls9KJEAbY0HXTHblHnO5PV5ha5c16v/uC8Sr+Bmj HqGjnZukbGZOuPVwfxAJN26EvuOlDTfW1MNXeZPHzLxghEws+MvPE7gC1GOjsqyCBYar rP6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GRleuBlp; 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 ji20-20020a170907981400b00730aa841c5bsi13074260ejc.964.2022.11.01.08.00.04; Tue, 01 Nov 2022 08:00:30 -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=GRleuBlp; 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 S231304AbiKAO5s (ORCPT + 97 others); Tue, 1 Nov 2022 10:57:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbiKAO5G (ORCPT ); Tue, 1 Nov 2022 10:57:06 -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 E89771C93F for ; Tue, 1 Nov 2022 07:55:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667314549; 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=EwIDPaua6Yy34C32ji+3GN+Mv0Eg+tlMnWsZUq1Kxzc=; b=GRleuBlpjM/Ov9heB5suWEabf27mOPnFUQ4YmlW/GttgnHJmpqrU5RiKoECnDCgOW9v/rZ 8ROx9bBwCqA2m9fpZfoyZt8BCc8IFPpixw92MJz0KDyvnC2CL6oyWFswkIWLCyxQwumbVT DA3VL3V+k0zZcbPYPOrByA3eLMzYH80= 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-27-t6mxpqFXOSemj0Zb6Lt-6A-1; Tue, 01 Nov 2022 10:55:47 -0400 X-MC-Unique: t6mxpqFXOSemj0Zb6Lt-6A-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 681B986F143; Tue, 1 Nov 2022 14:55:46 +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 3AE69C15BA5; Tue, 1 Nov 2022 14:55:44 +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 24/48] KVM: x86: hyper-v: Introduce fast guest_hv_cpuid_has_l2_tlb_flush() check Date: Tue, 1 Nov 2022 15:54:02 +0100 Message-Id: <20221101145426.251680-25-vkuznets@redhat.com> In-Reply-To: <20221101145426.251680-1-vkuznets@redhat.com> References: <20221101145426.251680-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit 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=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 Introduce a helper to quickly check if KVM needs to handle VMCALL/VMMCALL from L2 in L0 to process L2 TLB flush requests. Reviewed-by: Maxim Levitsky Reviewed-by: Sean Christopherson Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kvm/hyperv.h b/arch/x86/kvm/hyperv.h index 7706e203ff43..bd698eb2bda1 100644 --- a/arch/x86/kvm/hyperv.h +++ b/arch/x86/kvm/hyperv.h @@ -174,6 +174,14 @@ static inline void kvm_hv_vcpu_purge_flush_tlb(struct kvm_vcpu *vcpu) kfifo_reset_out(&tlb_flush_fifo->entries); } +static inline bool guest_hv_cpuid_has_l2_tlb_flush(struct kvm_vcpu *vcpu) +{ + struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu); + + return hv_vcpu && + (hv_vcpu->cpuid_cache.nested_eax & HV_X64_NESTED_DIRECT_FLUSH); +} + static inline bool kvm_hv_is_tlb_flush_hcall(struct kvm_vcpu *vcpu) { struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu); -- 2.37.3