s390/vfio-ap: prepare for dynamic update of guest's APCB on assign/unassign
authorTony Krowiak <akrowiak@linux.ibm.com>
Thu, 17 Mar 2022 02:21:38 +0000 (22:21 -0400)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Tue, 19 Jul 2022 14:18:10 +0000 (16:18 +0200)
commit8ee13ad99337b0b6920e732d87c692d577335f15
tree57100cfb5b2ab231ba870ed0e38456a01ba7fd36
parentb84eb8e05057f6f329e28f2563668340ea14184b
s390/vfio-ap: prepare for dynamic update of guest's APCB on assign/unassign

The functions backing the matrix mdev's sysfs attribute interfaces to
assign/unassign adapters, domains and control domains must take and
release the locks required to perform a dynamic update of a guest's APCB
in the proper order.

The proper order for taking the locks is:

matrix_dev->guests_lock => kvm->lock => matrix_dev->mdevs_lock

The proper order for releasing the locks is:

matrix_dev->mdevs_lock => kvm->lock => matrix_dev->guests_lock

Two new macros are introduced for this purpose: One to take the locks and
the other to release the locks. These macros will be used by the
assignment/unassignment functions to prepare for dynamic update of
the KVM guest's APCB.

Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
drivers/s390/crypto/vfio_ap_ops.c