mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
UPSTREAM: KVM: arm64: Cap KVM_CAP_NR_VCPUS by kvm_arm_default_max_vcpus()
Generally, it doesn't make sense to return the recommended maximum number
of vCPUs which exceeds the maximum possible number of vCPUs.
Note: ARM64 is special as the value returned by KVM_CAP_MAX_VCPUS differs
depending on whether it is a system-wide ioctl or a per-VM one. Previously,
KVM_CAP_NR_VCPUS didn't have this difference and it seems preferable to
keep the status quo. Cap KVM_CAP_NR_VCPUS by kvm_arm_default_max_vcpus()
which is what gets returned by system-wide KVM_CAP_MAX_VCPUS.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20211116163443.88707-2-vkuznets@redhat.com>
Acked-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit f60a00d729)
Bug: 204960018
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I8f4470d8a79d111b8f4a2730f97ec1bde4d76935
This commit is contained in:
committed by
Will Deacon
parent
ae4825a553
commit
398d6e9fa6
@@ -223,7 +223,14 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
|
||||
r = 1;
|
||||
break;
|
||||
case KVM_CAP_NR_VCPUS:
|
||||
r = num_online_cpus();
|
||||
/*
|
||||
* ARM64 treats KVM_CAP_NR_CPUS differently from all other
|
||||
* architectures, as it does not always bound it to
|
||||
* KVM_CAP_MAX_VCPUS. It should not matter much because
|
||||
* this is just an advisory value.
|
||||
*/
|
||||
r = min_t(unsigned int, num_online_cpus(),
|
||||
kvm_arm_default_max_vcpus());
|
||||
break;
|
||||
case KVM_CAP_MAX_VCPUS:
|
||||
case KVM_CAP_MAX_VCPU_ID:
|
||||
|
||||
Reference in New Issue
Block a user