Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp476467rwb; Tue, 4 Oct 2022 06:41:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7hfffxaJempxg+cjdPGkf6Z4EgCIi5rzXr9QYtXgiIq4VkO/TFxIKpX1mH7ijI8cSjeNnP X-Received: by 2002:a05:6402:5419:b0:457:c955:a40f with SMTP id ev25-20020a056402541900b00457c955a40fmr23159746edb.391.1664890866749; Tue, 04 Oct 2022 06:41:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664890866; cv=none; d=google.com; s=arc-20160816; b=kqiz8e2Ad9yFda+gSC/rmXtBEr/r8OWB07XQPwZB7iIE9vacYaETiSGk+KOQyGEs7A wwHctSwmnLULHF74BJwbtaHRiJQTProM0YdHQRoLFI9AktVwtKzET06HpXnr9FWlC/2o 7kItNpabLJwT48F0+VBaI+omUqMta5KiyZQTvL8d9GHS4QCEIc6IzVmEQqvwMPuCmO7/ Yq2LZ5QC0mQAdNZFfNLP0C+nULslzUIv5Z7BCmC5i08odLu0uZll689peoKgsbtI/OM3 con4XTjhbIMBE88ay25cZqF6NDbsKj19ZSiFDnCvQzuImgUgWu8r1bA/s9bmyyt7kLyG U8mw== 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=yaXEESHGoq9RoVEizrRigE3wllqpogFFYY4kz9RISoI=; b=fvh5pG14X7CRuJJWgqvtNnguIKlsxaNqcdQVG+5uq0zFLzLLVLwyvY+yA4CkFFgzde aJmTDQWUm7tztqlygSdRAjOclIjLEu1JKTyZSEkaTQgz0tj24QIlmFn+2T5zQIjOLAUx bVPUNK0yWWqoAhH4/3aMc9e/9twKflAPZ3PzZ9a/LJ9LUeg2pTwmBqCK0fBGFN0h/utY NubQUGyMPNYPB0NOmuBwRP7uj0tvve9yGJNoQBLTtIYr+RNZKE23uXt8dEljITX0BUOX 2tM6J+474/WrSDY3vXMgLxWyfXTMsNGujnSlWeLUNy2VBfqCxrV7BKNvIYW4SF1J9w5F qIWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=T9oSgnMZ; 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 dn12-20020a17090794cc00b0078c6a12ff3dsi4516010ejc.215.2022.10.04.06.40.41; Tue, 04 Oct 2022 06:41:06 -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=T9oSgnMZ; 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 S229992AbiJDMm3 (ORCPT + 99 others); Tue, 4 Oct 2022 08:42:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230018AbiJDMlv (ORCPT ); Tue, 4 Oct 2022 08:41: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 F28E65BC26 for ; Tue, 4 Oct 2022 05:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664887242; 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=yaXEESHGoq9RoVEizrRigE3wllqpogFFYY4kz9RISoI=; b=T9oSgnMZ5Dw+AksoIDMSuYuipmINOgXz6qRj2qHp30fBiWXiG4MXWXliaQ3LjpaZu2wich w2J10nHk2b4+kIp0p/dCWkDGRIa3vSZ/ZaU/+3qSPj8wR3D4mNER79UOKZhSIayevQDD7b +c7isRYn2ncH45igh5ZUEqA8ewyyA0s= 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-60-WNNAf467PAyRt1owxCMNxA-1; Tue, 04 Oct 2022 08:40:38 -0400 X-MC-Unique: WNNAf467PAyRt1owxCMNxA-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 2BCA885A5B6; Tue, 4 Oct 2022 12:40:37 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.192.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC65B17583; Tue, 4 Oct 2022 12:40:34 +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 15/46] KVM: x86: hyper-v: Use HV_MAX_SPARSE_VCPU_BANKS/HV_VCPUS_PER_SPARSE_BANK instead of raw '64' Date: Tue, 4 Oct 2022 14:39:25 +0200 Message-Id: <20221004123956.188909-16-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=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 215d6cf09f21..d7671af8d754 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -40,7 +40,7 @@ #include "irq.h" #include "fpu.h" -#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); @@ -1793,7 +1793,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. */ @@ -1903,12 +1903,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.37.3