Skip to content

Commit a03825b

Browse files
committed
KVM: s390: use kvm->created_vcpus
The new created_vcpus field avoids possible races between enabling capabilities and creating VCPUs. Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 557abc4 commit a03825b

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎arch/s390/kvm/kvm-s390.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ static int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)
422422
break;
423423
case KVM_CAP_S390_VECTOR_REGISTERS:
424424
mutex_lock(&kvm->lock);
425-
if (atomic_read(&kvm->online_vcpus)) {
425+
if (kvm->created_vcpus) {
426426
r = -EBUSY;
427427
} else if (MACHINE_HAS_VX) {
428428
set_kvm_facility(kvm->arch.model.fac_mask, 129);
@@ -437,7 +437,7 @@ static int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)
437437
case KVM_CAP_S390_RI:
438438
r = -EINVAL;
439439
mutex_lock(&kvm->lock);
440-
if (atomic_read(&kvm->online_vcpus)) {
440+
if (kvm->created_vcpus) {
441441
r = -EBUSY;
442442
} else if (test_facility(64)) {
443443
set_kvm_facility(kvm->arch.model.fac_mask, 64);
@@ -492,7 +492,7 @@ static int kvm_s390_set_mem_control(struct kvm *kvm, struct kvm_device_attr *att
492492
ret = -EBUSY;
493493
VM_EVENT(kvm, 3, "%s", "ENABLE: CMMA support");
494494
mutex_lock(&kvm->lock);
495-
if (atomic_read(&kvm->online_vcpus) == 0) {
495+
if (!kvm->created_vcpus) {
496496
kvm->arch.use_cmma = 1;
497497
ret = 0;
498498
}
@@ -536,7 +536,7 @@ static int kvm_s390_set_mem_control(struct kvm *kvm, struct kvm_device_attr *att
536536

537537
ret = -EBUSY;
538538
mutex_lock(&kvm->lock);
539-
if (atomic_read(&kvm->online_vcpus) == 0) {
539+
if (!kvm->created_vcpus) {
540540
/* gmap_alloc will round the limit up */
541541
struct gmap *new = gmap_alloc(current->mm, new_limit);
542542

@@ -713,7 +713,7 @@ static int kvm_s390_set_processor(struct kvm *kvm, struct kvm_device_attr *attr)
713713
int ret = 0;
714714

715715
mutex_lock(&kvm->lock);
716-
if (atomic_read(&kvm->online_vcpus)) {
716+
if (kvm->created_vcpus) {
717717
ret = -EBUSY;
718718
goto out;
719719
}

0 commit comments

Comments
 (0)