Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A353FC433EF for ; Thu, 11 Nov 2021 16:29:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B99F61252 for ; Thu, 11 Nov 2021 16:29:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234175AbhKKQcK (ORCPT ); Thu, 11 Nov 2021 11:32:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43951 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234267AbhKKQcH (ORCPT ); Thu, 11 Nov 2021 11:32:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636648158; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m5C/utbR+RY6tkUQ1/OF5lvFnSyvv5qyaKbzbIqaS0s=; b=iLmLZPtwfQTsxgQnSI2lPZId8MeOIAmXH19xpA15kQtfPNGfAlXlfjpehJBsE9q/Wocza1 JnK0KOzzh3C3R+uNW7I16ckTDfn4jCsXoz6ubhrc9YeicLHIAZCOqKntwyYGDzIGSL2tby w0/S9N2M2GI0fnArNb4vqbeS8JWcvGo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-375-Axrk8TiMP4G46J18ExwKZA-1; Thu, 11 Nov 2021 11:29:14 -0500 X-MC-Unique: Axrk8TiMP4G46J18ExwKZA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 143C187D558; Thu, 11 Nov 2021 16:29:12 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.192.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE4FF1017E37; Thu, 11 Nov 2021 16:28:22 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , Eduardo Habkost , Marc Zyngier , Andrew Jones , Huacai Chen , Aleksandar Markovic , Anup Patel , Paul Mackerras , Michael Ellerman , kvm-ppc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/5] KVM: PPC: Cap KVM_CAP_NR_VCPUS by KVM_CAP_MAX_VCPUS Date: Thu, 11 Nov 2021 17:27:44 +0100 Message-Id: <20211111162746.100598-4-vkuznets@redhat.com> In-Reply-To: <20211111162746.100598-1-vkuznets@redhat.com> References: <20211111162746.100598-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It doesn't make sense to return the recommended maximum number of vCPUs which exceeds the maximum possible number of vCPUs. Signed-off-by: Vitaly Kuznetsov --- arch/powerpc/kvm/powerpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 8ab90ce8738f..ccac8d5686ff 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -641,9 +641,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) * implementations just count online CPUs. */ if (hv_enabled) - r = num_present_cpus(); + r = min_t(unsigned int, num_present_cpus(), KVM_MAX_VCPUS); else - r = num_online_cpus(); + r = min_t(unsigned int, num_online_cpus(), KVM_MAX_VCPUS); break; case KVM_CAP_MAX_VCPUS: r = KVM_MAX_VCPUS; -- 2.33.1