aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2019-05-23 12:43:08 -0400
committerChristian Borntraeger <borntraeger@de.ibm.com>2019-05-28 09:52:19 -0400
commita86cb413f4bf273a9d341a3ab2c2ca44e12eb317 (patch)
tree9cadf1c3a9f0dd172677d5c30884edca37c3851a /virt
parenteb1f2f387db8c0d084581fb26e7faffde700bc8e (diff)
KVM: s390: Do not report unusabled IDs via KVM_CAP_MAX_VCPU_ID
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>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/arm/arm.c3
-rw-r--r--virt/kvm/kvm_main.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c
index 90cedebaeb94..7eeebe5e9da2 100644
--- a/virt/kvm/arm/arm.c
+++ b/virt/kvm/arm/arm.c
@@ -224,6 +224,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
224 case KVM_CAP_MAX_VCPUS: 224 case KVM_CAP_MAX_VCPUS:
225 r = KVM_MAX_VCPUS; 225 r = KVM_MAX_VCPUS;
226 break; 226 break;
227 case KVM_CAP_MAX_VCPU_ID:
228 r = KVM_MAX_VCPU_ID;
229 break;
227 case KVM_CAP_MSI_DEVID: 230 case KVM_CAP_MSI_DEVID:
228 if (!kvm) 231 if (!kvm)
229 r = -EINVAL; 232 r = -EINVAL;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 301089a462c4..ca54b09adf5b 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3151,8 +3151,6 @@ static long kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg)
3151 case KVM_CAP_MULTI_ADDRESS_SPACE: 3151 case KVM_CAP_MULTI_ADDRESS_SPACE:
3152 return KVM_ADDRESS_SPACE_NUM; 3152 return KVM_ADDRESS_SPACE_NUM;
3153#endif 3153#endif
3154 case KVM_CAP_MAX_VCPU_ID:
3155 return KVM_MAX_VCPU_ID;
3156 case KVM_CAP_NR_MEMSLOTS: 3154 case KVM_CAP_NR_MEMSLOTS:
3157 return KVM_USER_MEM_SLOTS; 3155 return KVM_USER_MEM_SLOTS;
3158 default: 3156 default: