Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp409372rwb; Tue, 4 Oct 2022 05:54:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM44zoU+TQeTeh4y/OvRzA53ISX9KE23GYDgd0qtk9k6DHQ83KfW7tPGFuD5bYo2w3OTV3BV X-Received: by 2002:a17:902:dad1:b0:17a:940:9c81 with SMTP id q17-20020a170902dad100b0017a09409c81mr26724544plx.93.1664888041098; Tue, 04 Oct 2022 05:54:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664888041; cv=none; d=google.com; s=arc-20160816; b=EZYfvwcY0Gs0XQPT3V9Z4Br1Zq9qqQgE7G6F1e7JYo7r2c9LSdAMoYOkbVr2q/5ruW 3jAXbO4qdAIUR6Hu9wfeh5urPwZH8ndnltNiVgnHJfTN3Rl3xDYTXrv0F1yFKPfVofNJ LfUsBM+Ejz3yQHCbyX5fitBj6RZQOkEIFDAsYYxnhmGFiB9KeYHFajf9C54RguR9UH3N 8moo5RVIX63xHsLXEd8sOYhO1Jym3RLe4Eb0PnLRsw8VVELXZTfXDD8WBMbDJQ/kzCOO d+wLOSkz72Z1rAYNgmVJbdu64DEvldi+XbN0Sp/Q5+hevyTilVzgofbJanmNiAzzoltK +7lw== 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=hf23owwXyl4mzv8DXKFj7XQPTlriWIPQsbBxFbBqkTQ=; b=R9OrZH4k99QQZ54KS+/+wEF2W928iqgDV7CysfdDJEXZoez+xYqeEy05vK6SQPDvOj sJ9vALpqvqcuu/S8tCho7zxtYpC8BG7wrpBHlfbFZqTRhUVn17HsHdIZsjWZ30fekBHL 6cLp/aB97sYjEb+hbha4TnOW4b7p1KGU4TermPPId6HZPLOot9YtZsqKi0/ct/cA/KsI 5Z8EfRKgG0GmPd39NF4az/Pp7GfYcT4q2vkK0LpzDZMgOB85loEEVADplPON/FvXV7FN 3vdOD9WaClztQfrwA0zjQb5T6dFMYbPPnjIr7cCFpw15Uv32aLnUv4Y/MsuIuccMA+TA r5BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=am8eITCm; 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 bg4-20020a1709028e8400b00177e951fefbsi12303542plb.372.2022.10.04.05.53.48; Tue, 04 Oct 2022 05:54:01 -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=am8eITCm; 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 S230186AbiJDMne (ORCPT + 99 others); Tue, 4 Oct 2022 08:43:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230088AbiJDMmv (ORCPT ); Tue, 4 Oct 2022 08:42:51 -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 ESMTPS id 450BF5E540 for ; Tue, 4 Oct 2022 05:41:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664887262; 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=hf23owwXyl4mzv8DXKFj7XQPTlriWIPQsbBxFbBqkTQ=; b=am8eITCmhcuNHoZiE6116zk1R9/y0BjHgvqCRsl+4ANzXZZtEWnmmdRy4zDAlELWDbW19N dftVzd69sZW/HdfEa1Z6zFKrG4za60LBxdGOairmiZP3cDgLy5p0hkNEbl613a/hSmhNI5 vvIeLuHVMR7xVO1ff6reGMhtW06zv+w= 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-184-IcepnKkxM4C4B6vydlEl9Q-1; Tue, 04 Oct 2022 08:40:59 -0400 X-MC-Unique: IcepnKkxM4C4B6vydlEl9Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B174B85A59D; Tue, 4 Oct 2022 12:40:58 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.192.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFF2D7AE5; Tue, 4 Oct 2022 12:40:56 +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 v11 24/46] KVM: x86: hyper-v: Introduce fast guest_hv_cpuid_has_l2_tlb_flush() check Date: Tue, 4 Oct 2022 14:39:34 +0200 Message-Id: <20221004123956.188909-25-vkuznets@redhat.com> In-Reply-To: <20221004123956.188909-1-vkuznets@redhat.com> References: <20221004123956.188909-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.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 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 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