]> git.proxmox.com Git - mirror_ubuntu-bionic-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)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1838700
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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.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 9730ba734afe0cef2c44713430904db020977840..aa6c365f25591f1a967e3de97bfbac2b4ca7c6b8 100644 (file)
@@ -1078,6 +1078,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 50854eda99d6e34b839883a6474c53e94e1e5a4c..0ca42766d80df2ff2240ced528518ff092b1e349 100644 (file)
@@ -633,6 +633,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 fbf2c1342e753f29f6784542c14609e7db36ad46..e30b4952a6d4f12ae73eb010a2d8853cc6f3a8dc 100644 (file)
@@ -486,6 +486,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 08e84d7443a985deea6332567f46fa6f157be5e7..ef6b59bd7c49adf2ad300fa122eba93477cc8c4d 100644 (file)
@@ -2853,6 +2853,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 8a5e790d5539610da18dcaf636e7a30e4e6841e1..4d62a548acde03a06f5b2362dd1e273eb0140285 100644 (file)
@@ -220,6 +220,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 ad0f4437355c7cbc0d32de5084d2710f1b456885..04ae9c6bf23538cc1a7931fcbdcdc77fcf1b8d66 100644 (file)
@@ -2961,8 +2961,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;
        }