]> git.itanic.dy.fi Git - linux-stable/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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 9 Jun 2019 07:17:18 +0000 (09:17 +0200)
commit a86cb413f4bf273a9d341a3ab2c2ca44e12eb317 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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 f7ea8e21656b168fbd16a57a46851c0ab78b0129..e7f5ef6bed0fe8a86e39497f8c1791690c3b0bc6 100644 (file)
@@ -1099,6 +1099,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 79b79408d92ea49cd13836e813bcee9d14cc8cbf..578174a33d229732c0fef060ef95d3a1f0176b81 100644 (file)
@@ -632,6 +632,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 ac5da6b0b862a3d725297890b7feb6cae6d06788..f538e3fac7ade9ad7a6635b9b28ee6f149e30bc1 100644 (file)
@@ -489,6 +489,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 be4ba0975a0f69ab2ee5103f12d2eefa1617e22b..7fed1d6dd1a13b0052263f803b58a0cdd832a199 100644 (file)
@@ -2987,6 +2987,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_NR_MEMSLOTS:
                r = KVM_USER_MEM_SLOTS;
                break;
index fef3527af3bd72b0cbbd3c8375e2eeba224c1ac8..02bac8abd206fd5f6ad357306d82fb721efc17d9 100644 (file)
@@ -223,6 +223,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_NR_MEMSLOTS:
                r = KVM_USER_MEM_SLOTS;
                break;
index e909d9907b5066d597385eba9b932ed11964d1b6..2b36a51afb5764f485ca7918c67675b58ad6883f 100644 (file)
@@ -2965,8 +2965,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;
        default:
                break;
        }