]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
KVM: s390: Do not report unusabled IDs via KVM_CAP_MAX_VCPU_ID
authorThomas Huth <thuth@redhat.com>
Thu, 23 May 2019 16:43:08 +0000 (18:43 +0200)
committerChristian Borntraeger <borntraeger@de.ibm.com>
Tue, 28 May 2019 13:52:19 +0000 (15:52 +0200)
KVM_CAP_MAX_VCPU_ID is currently always reporting KVM_MAX_VCPU_ID on all
architectures. However, on s390x, the amount of usable CPUs is determined
during runtime - it is depending on the features of the machine the code
is running on. Since we are using the vcpu_id as an index into the SCA
structures that are defined by the hardware (see e.g. the sca_add_vcpu()
function), it is not only the amount of CPUs that is limited by the hard-
ware, but also the range of IDs that we can use.
Thus KVM_CAP_MAX_VCPU_ID must be determined during runtime on s390x, too.
So the handling of KVM_CAP_MAX_VCPU_ID has to be moved from the common
code into the architecture specific code, and on s390x we have to return
the same value here as for KVM_CAP_MAX_VCPUS.
This problem has been discovered with the kvm_create_max_vcpus selftest.
With this change applied, the selftest now passes on s390x, too.

Reviewed-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20190523164309.13345-9-thuth@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
arch/mips/kvm/mips.c
arch/powerpc/kvm/powerpc.c
arch/s390/kvm/kvm-s390.c
arch/x86/kvm/x86.c
virt/kvm/arm/arm.c
virt/kvm/kvm_main.c

index 6d0517ac18e5012ea255082dbf4595091a105890..0369f26ab96d6aeb934d7f6e084e9789419fd03e 100644 (file)
@@ -1122,6 +1122,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
        case KVM_CAP_MAX_VCPUS:
                r = KVM_MAX_VCPUS;
                break;
+       case KVM_CAP_MAX_VCPU_ID:
+               r = KVM_MAX_VCPU_ID;
+               break;
        case KVM_CAP_MIPS_FPU:
                /* We don't handle systems with inconsistent cpu_has_fpu */
                r = !!raw_cpu_has_fpu;
index 3393b166817a859a371bd95bf5664e1a0788944f..aa3a678711beecfa99b544d182cb6af021141c8e 100644 (file)
@@ -657,6 +657,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
        case KVM_CAP_MAX_VCPUS:
                r = KVM_MAX_VCPUS;
                break;
+       case KVM_CAP_MAX_VCPU_ID:
+               r = KVM_MAX_VCPU_ID;
+               break;
 #ifdef CONFIG_PPC_BOOK3S_64
        case KVM_CAP_PPC_GET_SMMU_INFO:
                r = 1;
index e5e8eb29e68e116e8d5f6e0d6db7d8cc91289943..28ebd647784c93b784bf625dc5063f02c5df3c30 100644 (file)
@@ -539,6 +539,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
                break;
        case KVM_CAP_NR_VCPUS:
        case KVM_CAP_MAX_VCPUS:
+       case KVM_CAP_MAX_VCPU_ID:
                r = KVM_S390_BSCA_CPU_SLOTS;
                if (!kvm_s390_use_sca_entries())
                        r = KVM_MAX_VCPUS;
index acb179f78fdcd2c9a512888da00e34832326cf29..83aefd759846e1942066e53b016e420fd39d8a7d 100644 (file)
@@ -3122,6 +3122,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
        case KVM_CAP_MAX_VCPUS:
                r = KVM_MAX_VCPUS;
                break;
+       case KVM_CAP_MAX_VCPU_ID:
+               r = KVM_MAX_VCPU_ID;
+               break;
        case KVM_CAP_PV_MMU:    /* obsolete */
                r = 0;
                break;
index 90cedebaeb9418cb830dbd33cf58fa51840d4d00..7eeebe5e9da2b123f6b26e07e2e52ac404c15eb6 100644 (file)
@@ -224,6 +224,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
        case KVM_CAP_MAX_VCPUS:
                r = KVM_MAX_VCPUS;
                break;
+       case KVM_CAP_MAX_VCPU_ID:
+               r = KVM_MAX_VCPU_ID;
+               break;
        case KVM_CAP_MSI_DEVID:
                if (!kvm)
                        r = -EINVAL;
index 301089a462c4c0a545b22240787ffc2ddaef41b8..ca54b09adf5b7876dd1b102262d562e6d5c3f2dd 100644 (file)
@@ -3151,8 +3151,6 @@ static long kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg)
        case KVM_CAP_MULTI_ADDRESS_SPACE:
                return KVM_ADDRESS_SPACE_NUM;
 #endif
-       case KVM_CAP_MAX_VCPU_ID:
-               return KVM_MAX_VCPU_ID;
        case KVM_CAP_NR_MEMSLOTS:
                return KVM_USER_MEM_SLOTS;
        default: