[PATCH 0/1] fix circular lockdep when staring SE guest

From: Tony Krowiak
Date: Tue Feb 09 2021 - 18:12:09 EST


Patch f21916ec4826 ("s390/vfio-ap: clean up vfio_ap resources when KVM
pointer invalidated") introduced a change that results in a circular
locking dependency when a Secure Execution guest that is configured with
crypto devices is started. The problem resulted due to the fact that the
patch moved the setting of the guest's AP masks within the protection of
the matrix_dev->lock when the vfio_ap driver is notified that the KVM
pointer has been set. Since it is not critical that setting/clearing of
the guest's AP masks when the driver is notified, the masks will not be
updated under the matrix_dev->lock. The lock is necessary for the
setting/unsetting of the KVM pointer, however, so that will remain in
place.

The dependency chain for the circular lockdep resolved by this patch
is:

#2 vfio_ap_mdev_group_notifier: kvm->lock
matrix_dev->lock

#1: handle_pqap: matrix_dev->lock
kvm_vcpu_ioctl: vcpu->mutex

#0: kvm_s390_cpus_to_pv: vcpu->mutex
kvm_vm_ioctl: kvm->lock

Tony Krowiak (1):
s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

drivers/s390/crypto/vfio_ap_ops.c | 75 ++++++++++++++++++-------------
1 file changed, 45 insertions(+), 30 deletions(-)

--
2.21.1