Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4724032pxv; Tue, 6 Jul 2021 07:43:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAdHDtgHe2veRRfbBXqB4yH0rVtzYEYge/NkpHVOG5MPoWEtFBbBatDd35HdaxJeQmpbai X-Received: by 2002:a17:906:ce59:: with SMTP id se25mr2375802ejb.418.1625582596675; Tue, 06 Jul 2021 07:43:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625582596; cv=none; d=google.com; s=arc-20160816; b=cHJ/jRJGhmq7mfIvda78qoe6rHT7RWnZ1bAEuKlNYWQLUDL6bs4Yx4Nd///RtqF8ot uE8taCkmnYFJ9vuJGMt50rE3tTSoq17U9+/l+knS4sny4dShsoPU0ga1rPSBz8+VuyEy enWGUQ5CiIAObdKoFlWmO3ogM1keL9vQVjMovgAWEvbZZIB5izb7ar83mFz4JRN3yfv0 P0T0x9avxzZyw/bcVDUB5nDThB/wnILR4yJEsbL6lB4n3eZ46XPpFvmvoZLKiNnhzaD9 zHlduQkcFYBRBGIZpM5fHW1P9llmoyYykJcC6OWQGxpg8R89Ge9teW90Dq0cgLhI9Q9U IiKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=FVD9TqsR7wtGDSSt+t/Z7VBCz1UEwKOtSU1PtxApYio=; b=vWgW6qhOBfLklA/Lxsa2NhlsEiyupz4WCxGtwZf7/3QAOAjFdkB/YS+A7R/AXmftJC nBF4LIa4+cY4SOB8OLVlhUISn12094zGy+OTur7MTTjzxz65HNoBwATD3XvBtC/6ZPaY XrRf0R/mqavkElmv0QR/reV1xMVNU/xuBdePlrTWrUDt7rc2L43UYxwwF62/L0qiNrLa aWgzEEKruwKDQly/9BQMKnPYp+4jLemZLnXZi4msPkbUJMwOL3/lNX2UHl7rQLBzfrh2 WT14UzoYXZPCzAzyZp8DFYB6B8kfNFIp43msmw/nSmo52oDj6aZNs4UECTUabbrCJVWm NMQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="K/vbmkpD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g2si14145490eds.536.2021.07.06.07.42.53; Tue, 06 Jul 2021 07:43:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="K/vbmkpD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232561AbhGFOmC (ORCPT + 99 others); Tue, 6 Jul 2021 10:42:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25061 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232540AbhGFOmB (ORCPT ); Tue, 6 Jul 2021 10:42:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625582362; 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=FVD9TqsR7wtGDSSt+t/Z7VBCz1UEwKOtSU1PtxApYio=; b=K/vbmkpDwm/BalC7v5xzYLGF7v+TkdhoQOX6mjkTwwCHe6iX/5Sm5M3FvaJsGDmECpAWJS F7YWELq6c7qvGkAPfrR1W1Od5Vtqw+lc5DzhgjRgQOP1iXJEhK+MUGJ5z2Q0tIOJAuGdVH iHK9NJlUe3h3RA9HYglhKXKS5raSSmI= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-340-hM__pBntPm2K0ibDJRdFBA-1; Tue, 06 Jul 2021 09:49:10 -0400 X-MC-Unique: hM__pBntPm2K0ibDJRdFBA-1 Received: by mail-ed1-f69.google.com with SMTP id w15-20020a05640234cfb02903951279f8f3so10849651edc.11 for ; Tue, 06 Jul 2021 06:49:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=FVD9TqsR7wtGDSSt+t/Z7VBCz1UEwKOtSU1PtxApYio=; b=jIkEK/dvKnuivf6tyGeMceG1+H5W7BArVcmIqh81plkzlk7qxcZj+3EqB0V2bXCHrt mzhloMthxESJ3vqZlAksRTODPvL/fGvzKVrJLJk9fBzW9gbpMq7Q15ruxX6M+i8aplvG d9BtF9mQegUf8IXX8eeMPIwzYKBRDQf2trZbpr2YYSDNF6WEj69wZyBMWOh3/8hUiGHM 9jwXwZA4NqOaS7zDu4q1ln2buhW6Uluor343istalAljn43F1DKCLq1FPMpXD8BiBkqq 06ICtKgVpGH6EJOorfZQugK85jWK/zHA9WApSQZUUrZTAgUYSlGT/t7LBZHcnIomj9f1 qEhQ== X-Gm-Message-State: AOAM533rJJyAqKaVC7w4rbwD8zWSDiVHO8Jk2CMEV9zPEmDjUi8GOKjc LKzh80oC7i//j61lG3TrkEXvKqXQ1WRKGptW3sq0veKdJiLW5ealpky+6f7Slp6+e/ZZDjlmyBx driimWQl3Ynd53As6IgbykwTM X-Received: by 2002:aa7:c352:: with SMTP id j18mr23030795edr.67.1625579349199; Tue, 06 Jul 2021 06:49:09 -0700 (PDT) X-Received: by 2002:aa7:c352:: with SMTP id j18mr23030760edr.67.1625579349029; Tue, 06 Jul 2021 06:49:09 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id ak16sm4357263ejc.17.2021.07.06.06.49.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Jul 2021 06:49:08 -0700 (PDT) Subject: Re: [RFC PATCH v2 21/69] KVM: Add max_vcpus field in common 'struct kvm' To: isaku.yamahata@intel.com, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , erdemaktas@google.com, Connor Kuehl , Sean Christopherson , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: isaku.yamahata@gmail.com, Sean Christopherson References: From: Paolo Bonzini Message-ID: Date: Tue, 6 Jul 2021 15:49:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Please replace "Add" with "Move" and add a couple lines to the commit message. Paolo On 03/07/21 00:04, isaku.yamahata@intel.com wrote: > From: Sean Christopherson > > Signed-off-by: Sean Christopherson > Signed-off-by: Isaku Yamahata > --- > arch/arm64/include/asm/kvm_host.h | 3 --- > arch/arm64/kvm/arm.c | 7 ++----- > arch/arm64/kvm/vgic/vgic-init.c | 6 +++--- > include/linux/kvm_host.h | 1 + > virt/kvm/kvm_main.c | 3 ++- > 5 files changed, 8 insertions(+), 12 deletions(-) > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index 7cd7d5c8c4bc..96a0dc3a8780 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -106,9 +106,6 @@ struct kvm_arch { > /* VTCR_EL2 value for this VM */ > u64 vtcr; > > - /* The maximum number of vCPUs depends on the used GIC model */ > - int max_vcpus; > - > /* Interrupt controller */ > struct vgic_dist vgic; > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index e720148232a0..a46306cf3106 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -145,7 +145,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) > kvm_vgic_early_init(kvm); > > /* The maximum number of VCPUs is limited by the host's GIC model */ > - kvm->arch.max_vcpus = kvm_arm_default_max_vcpus(); > + kvm->max_vcpus = kvm_arm_default_max_vcpus(); > > set_default_spectre(kvm); > > @@ -220,7 +220,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) > case KVM_CAP_MAX_VCPUS: > case KVM_CAP_MAX_VCPU_ID: > if (kvm) > - r = kvm->arch.max_vcpus; > + r = kvm->max_vcpus; > else > r = kvm_arm_default_max_vcpus(); > break; > @@ -299,9 +299,6 @@ int kvm_arch_vcpu_precreate(struct kvm *kvm, unsigned int id) > if (irqchip_in_kernel(kvm) && vgic_initialized(kvm)) > return -EBUSY; > > - if (id >= kvm->arch.max_vcpus) > - return -EINVAL; > - > return 0; > } > > diff --git a/arch/arm64/kvm/vgic/vgic-init.c b/arch/arm64/kvm/vgic/vgic-init.c > index 58cbda00e56d..089ac00c55d7 100644 > --- a/arch/arm64/kvm/vgic/vgic-init.c > +++ b/arch/arm64/kvm/vgic/vgic-init.c > @@ -97,11 +97,11 @@ int kvm_vgic_create(struct kvm *kvm, u32 type) > ret = 0; > > if (type == KVM_DEV_TYPE_ARM_VGIC_V2) > - kvm->arch.max_vcpus = VGIC_V2_MAX_CPUS; > + kvm->max_vcpus = VGIC_V2_MAX_CPUS; > else > - kvm->arch.max_vcpus = VGIC_V3_MAX_CPUS; > + kvm->max_vcpus = VGIC_V3_MAX_CPUS; > > - if (atomic_read(&kvm->online_vcpus) > kvm->arch.max_vcpus) { > + if (atomic_read(&kvm->online_vcpus) > kvm->max_vcpus) { > ret = -E2BIG; > goto out_unlock; > } > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index e87f07c5c601..ddd4d0f68cdf 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -544,6 +544,7 @@ struct kvm { > * and is accessed atomically. > */ > atomic_t online_vcpus; > + int max_vcpus; > int created_vcpus; > int last_boosted_vcpu; > struct list_head vm_list; > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index dc752d0bd3ec..52d40ea75749 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -910,6 +910,7 @@ static struct kvm *kvm_create_vm(unsigned long type) > mutex_init(&kvm->irq_lock); > mutex_init(&kvm->slots_lock); > INIT_LIST_HEAD(&kvm->devices); > + kvm->max_vcpus = KVM_MAX_VCPUS; > > BUILD_BUG_ON(KVM_MEM_SLOTS_NUM > SHRT_MAX); > > @@ -3329,7 +3330,7 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id) > return -EINVAL; > > mutex_lock(&kvm->lock); > - if (kvm->created_vcpus == KVM_MAX_VCPUS) { > + if (kvm->created_vcpus >= kvm->max_vcpus) { > mutex_unlock(&kvm->lock); > return -EINVAL; > } >