Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp224785iof; Mon, 6 Jun 2022 02:02:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwncr4ziC+HjvXbyDBrLPBOADQINW5321pyEF+yCKC1OZ4oFtUe7Qm2YhD1RXcV80+enkyk X-Received: by 2002:a17:902:f710:b0:15f:165f:b50b with SMTP id h16-20020a170902f71000b0015f165fb50bmr23959185plo.158.1654506143557; Mon, 06 Jun 2022 02:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654506143; cv=none; d=google.com; s=arc-20160816; b=bLL1wFR2Ik8ys10portnQ2UyitGQIukp629h3NTxweojPbr/UKVdYqOPhHcXvwCz1Y BHzth4VFFOVVLxTL3natvTzL5+B08SDNBM8V2SUQR+yoAxpKqO4KiYsKEmrG7ZIh/aMC ZeRjlXuLXUHiZ0i9yhiWGqPIQF3llU9X0WUVKyNY8m4mtmoDflogKIuAc/Orn0XEMJT7 nmVZ5zj/65eL7e0fSmnUFOcNnmm6xrhG+17YjpgXW4o65frhywVzuv2bq4rSDNjIaboB c+F1g2UTNEgNv1T+e861j5FUtp2lFZhep3M0aaW/zAN6fwobPE3bpukiYqg2mlfFj2YQ +MBA== 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=6EbOQEM4KSVA9gLlPa9QlR/SHY818DTJV2naZEjUXSk=; b=gr9+KFPlqge4cR4KBstcfa/xgTU9Wou4Juu9p7R0C2jwliJq4APou+IA51hekJGR2R BqGfGTPPzHRWmV1w6Na1ZXRsy/ku4zQlTWdR0k6BhaxGoaCVW2l0lnP2Kdf+cP5kHy1c J0W3aWMJLB6c+WW1k1vCDZxpKKQFSkLMrQVDyTwYFts4ZvxEtsjZZldvz4UyANb5AIWI h0ks5YXbLutdZLJJWxoWHpU2ErCLSiuSvCpycilrKgcCcP44yUleayw+AYtumL4LRDFC mAQQVaj1ztl48RyUUhPB+m4iY5zg5H3XryDR6GX4+1HmotOD9+eUKfdCOciY7ZgLi+Cw MYYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UBlghtJi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id g6-20020a636b06000000b003fd8db87697si5974405pgc.441.2022.06.06.02.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 02:02:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UBlghtJi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A10DF32EE9; Mon, 6 Jun 2022 01:38:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232108AbiFFIiQ (ORCPT + 99 others); Mon, 6 Jun 2022 04:38:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231959AbiFFIhc (ORCPT ); Mon, 6 Jun 2022 04:37:32 -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 5996F1EC43 for ; Mon, 6 Jun 2022 01:37:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654504650; 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=6EbOQEM4KSVA9gLlPa9QlR/SHY818DTJV2naZEjUXSk=; b=UBlghtJi100n5ctg/1SzzRGd6qIuzsX/aX3WBYIqyWg2SbhucVFq3icocPCTvjSFoAYh3C dmSzq4i3A9DqeovQvZYbIdRQdA7FG72f84BrNTIxcF1gjtL2XBxJpUymzN2D2H341VZpLt 8Y/3+gNFJs7NEiJbDCYTpEkCs3kyNec= 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-549-ywz5UZUEOZmluqHa3N9zwg-1; Mon, 06 Jun 2022 04:37:21 -0400 X-MC-Unique: ywz5UZUEOZmluqHa3N9zwg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 12D3B1C16B42; Mon, 6 Jun 2022 08:37:21 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.193.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBACA1121314; Mon, 6 Jun 2022 08:37:18 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , Michael Kelley , Siddharth Chandrasekaran , Yuan Yao , Maxim Levitsky , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 09/38] KVM: x86: hyper-v: Use HV_MAX_SPARSE_VCPU_BANKS/HV_VCPUS_PER_SPARSE_BANK instead of raw '64' Date: Mon, 6 Jun 2022 10:36:26 +0200 Message-Id: <20220606083655.2014609-10-vkuznets@redhat.com> In-Reply-To: <20220606083655.2014609-1-vkuznets@redhat.com> References: <20220606083655.2014609-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 It may not be clear from where the '64' limit for the maximum sparse bank number comes from, use HV_MAX_SPARSE_VCPU_BANKS define instead. Use HV_VCPUS_PER_SPARSE_BANK in KVM_HV_MAX_SPARSE_VCPU_SET_BITS's definition. Opportunistically adjust the comment around BUILD_BUG_ON(). No functional change. Reviewed-by: Maxim Levitsky Suggested-by: Sean Christopherson Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 992972e0f5de..c43355cb60bc 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -43,7 +43,7 @@ /* "Hv#1" signature */ #define HYPERV_CPUID_SIGNATURE_EAX 0x31237648 -#define KVM_HV_MAX_SPARSE_VCPU_SET_BITS DIV_ROUND_UP(KVM_MAX_VCPUS, 64) +#define KVM_HV_MAX_SPARSE_VCPU_SET_BITS DIV_ROUND_UP(KVM_MAX_VCPUS, HV_VCPUS_PER_SPARSE_BANK) static void stimer_mark_pending(struct kvm_vcpu_hv_stimer *stimer, bool vcpu_kick); @@ -1799,7 +1799,7 @@ static u64 kvm_get_sparse_vp_set(struct kvm *kvm, struct kvm_hv_hcall *hc, u64 *sparse_banks, int consumed_xmm_halves, gpa_t offset) { - if (hc->var_cnt > 64) + if (hc->var_cnt > HV_MAX_SPARSE_VCPU_BANKS) return -EINVAL; /* Cap var_cnt to ignore banks that cannot contain a legal VP index. */ @@ -1909,12 +1909,11 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc) gpa_t data_offset; /* - * The Hyper-V TLFS doesn't allow more than 64 sparse banks, e.g. the - * valid mask is a u64. Fail the build if KVM's max allowed number of - * vCPUs (>4096) would exceed this limit, KVM will additional changes - * for Hyper-V support to avoid setting the guest up to fail. + * The Hyper-V TLFS doesn't allow more than HV_MAX_SPARSE_VCPU_BANKS + * sparse banks. Fail the build if KVM's max allowed number of + * vCPUs (>4096) exceeds this limit. */ - BUILD_BUG_ON(KVM_HV_MAX_SPARSE_VCPU_SET_BITS > 64); + BUILD_BUG_ON(KVM_HV_MAX_SPARSE_VCPU_SET_BITS > HV_MAX_SPARSE_VCPU_BANKS); if (!hc->fast && is_guest_mode(vcpu)) { hc->ingpa = translate_nested_gpa(vcpu, hc->ingpa, 0, NULL); -- 2.35.3