[v13,24/48] KVM: x86: hyper-v: Introduce fast guest_hv_cpuid_has_l2_tlb_flush() check
Message ID | 20221101145426.251680-25-vkuznets@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3021203wru; Tue, 1 Nov 2022 07:59:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Z7IhC60111K5BwbQKq7k/B2TBDxm9Fs+w+hpc9fEj83MPQThj9cUy9AOZ1pcbIEEfo7ct X-Received: by 2002:aa7:d710:0:b0:463:bd7b:2b44 with SMTP id t16-20020aa7d710000000b00463bd7b2b44mr2722441edq.385.1667314753726; Tue, 01 Nov 2022 07:59:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667314753; cv=none; d=google.com; s=arc-20160816; b=HEfUA3F//PHMT78W+6relnuPEPXiaEjBScJ13MEq3UmtI47rrkoixNmbSlfG8u0hQg /EpbKENSqhu2YbY/DE24ChEnU6RasjWLhoNCOjMJfbnarHDxyQIKP0ixtsLFZ/9o7DwF 240WoSW1nCrAlqQMwjHSgAZw5Y9/yTOTn54PeAHGaUPdErTDHwRWU8eSmqfMAy03iEvQ H0t+hcgZ9ev0itH5uPfUuRcEwjvakNluyMlHPi+2foR710xM4Vq3OwhT+l/IWz7xA0Lv lV0fHv6A7CQUGkzPo3rZK6hgg9DwwPCBQVNEmffn0A9nuyIRLv3a2vHAqEovXB8yTG/x M6og== 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 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.07.58.49; Tue, 01 Nov 2022 07:59:13 -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 <rfc822;kartikey406@gmail.com> + 99 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <vkuznets@redhat.com> To: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>, Sean Christopherson <seanjc@google.com> Cc: Wanpeng Li <wanpengli@tencent.com>, Jim Mattson <jmattson@google.com>, Michael Kelley <mikelley@microsoft.com>, Siddharth Chandrasekaran <sidcha@amazon.de>, Yuan Yao <yuan.yao@linux.intel.com>, Maxim Levitsky <mlevitsk@redhat.com>, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748306235335904363?= X-GMAIL-MSGID: =?utf-8?q?1748306235335904363?= |
Series |
KVM: x86: hyper-v: Fine-grained TLB flush + L2 TLB flush features
|
|
Commit Message
Vitaly Kuznetsov
Nov. 1, 2022, 2:54 p.m. UTC
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 <mlevitsk@redhat.com> Reviewed-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> --- 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);