@@ -769,7 +769,7 @@ static void kvm_s390_sync_request_broadcast(struct kvm *kvm, int req)
769
769
770
770
/*
771
771
* Must be called with kvm->srcu held to avoid races on memslots, and with
772
- * kvm->lock to avoid races with ourselves and kvm_s390_vm_stop_migration.
772
+ * kvm->slots_lock to avoid races with ourselves and kvm_s390_vm_stop_migration.
773
773
*/
774
774
static int kvm_s390_vm_start_migration (struct kvm * kvm )
775
775
{
@@ -825,7 +825,7 @@ static int kvm_s390_vm_start_migration(struct kvm *kvm)
825
825
}
826
826
827
827
/*
828
- * Must be called with kvm->lock to avoid races with ourselves and
828
+ * Must be called with kvm->slots_lock to avoid races with ourselves and
829
829
* kvm_s390_vm_start_migration.
830
830
*/
831
831
static int kvm_s390_vm_stop_migration (struct kvm * kvm )
@@ -840,6 +840,8 @@ static int kvm_s390_vm_stop_migration(struct kvm *kvm)
840
840
841
841
if (kvm -> arch .use_cmma ) {
842
842
kvm_s390_sync_request_broadcast (kvm , KVM_REQ_STOP_MIGRATION );
843
+ /* We have to wait for the essa emulation to finish */
844
+ synchronize_srcu (& kvm -> srcu );
843
845
vfree (mgs -> pgste_bitmap );
844
846
}
845
847
kfree (mgs );
@@ -849,22 +851,20 @@ static int kvm_s390_vm_stop_migration(struct kvm *kvm)
849
851
static int kvm_s390_vm_set_migration (struct kvm * kvm ,
850
852
struct kvm_device_attr * attr )
851
853
{
852
- int idx , res = - ENXIO ;
854
+ int res = - ENXIO ;
853
855
854
- mutex_lock (& kvm -> lock );
856
+ mutex_lock (& kvm -> slots_lock );
855
857
switch (attr -> attr ) {
856
858
case KVM_S390_VM_MIGRATION_START :
857
- idx = srcu_read_lock (& kvm -> srcu );
858
859
res = kvm_s390_vm_start_migration (kvm );
859
- srcu_read_unlock (& kvm -> srcu , idx );
860
860
break ;
861
861
case KVM_S390_VM_MIGRATION_STOP :
862
862
res = kvm_s390_vm_stop_migration (kvm );
863
863
break ;
864
864
default :
865
865
break ;
866
866
}
867
- mutex_unlock (& kvm -> lock );
867
+ mutex_unlock (& kvm -> slots_lock );
868
868
869
869
return res ;
870
870
}
@@ -1754,7 +1754,9 @@ long kvm_arch_vm_ioctl(struct file *filp,
1754
1754
r = - EFAULT ;
1755
1755
if (copy_from_user (& args , argp , sizeof (args )))
1756
1756
break ;
1757
+ mutex_lock (& kvm -> slots_lock );
1757
1758
r = kvm_s390_get_cmma_bits (kvm , & args );
1759
+ mutex_unlock (& kvm -> slots_lock );
1758
1760
if (!r ) {
1759
1761
r = copy_to_user (argp , & args , sizeof (args ));
1760
1762
if (r )
@@ -1768,7 +1770,9 @@ long kvm_arch_vm_ioctl(struct file *filp,
1768
1770
r = - EFAULT ;
1769
1771
if (copy_from_user (& args , argp , sizeof (args )))
1770
1772
break ;
1773
+ mutex_lock (& kvm -> slots_lock );
1771
1774
r = kvm_s390_set_cmma_bits (kvm , & args );
1775
+ mutex_unlock (& kvm -> slots_lock );
1772
1776
break ;
1773
1777
}
1774
1778
default :
0 commit comments