Re: [PATCH v15 00/13] s390/vfio-ap: dynamic configuration support

2021-04-09 Thread Tony Krowiak
On 4/8/21 4:38 PM, Halil Pasic wrote: On Tue, 6 Apr 2021 11:31:09 -0400 Tony Krowiak wrote: Tony Krowiak (13): s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks The subsequent patches, re introduce this circular locking dependency problem. See my kernel messages

[PATCH v15 13/13] s390/vfio-ap: update docs to include dynamic config support

2021-04-06 Thread Tony Krowiak
Update the documentation in vfio-ap.rst to include information about the AP dynamic configuration support (i.e., hot plug of adapters, domains and control domains via the matrix mediated device's sysfs assignment attributes). Signed-off-by: Tony Krowiak --- Documentation/s390/vfio-ap.rst | 383

[PATCH v15 12/13] s390/zcrypt: notify drivers on config changed and scan complete callbacks

2021-04-06 Thread Tony Krowiak
the probe callback is invoked. Please note that changes to the apmask and aqmask do not trigger these two callbacks since the bus scan function is not invoked by changes to those masks. Signed-off-by: Harald Freudenberger Reviewed-by: Halil Pasic Signed-off-by: Tony Krowiak --- drivers/s390

[PATCH v15 11/13] s390/vfio-ap: sysfs attribute to display the guest's matrix

2021-04-06 Thread Tony Krowiak
that is or will be using the matrix mdev. For a matrix mdev denoted by $uuid, the guest matrix can be displayed as follows: cat /sys/devices/vfio_ap/matrix/$uuid/guest_matrix Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 51 ++- 1 file changed, 37

[PATCH v15 10/13] s390/vfio-ap: implement in-use callback for vfio_ap driver

2021-04-06 Thread Tony Krowiak
ll as during the in_use callback, the mutex_trylock(_dev->lock) function will be used. If the lock is not obtained, then the assignment and in_use functions will terminate with -EAGAIN. Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_drv.c | 1 + drivers/s390/crypto/vfio_ap

[PATCH v15 09/13] s390/zcrypt: driver callback to indicate resource in use

2021-04-06 Thread Tony Krowiak
). This will enforce the proper procedure for removing AP resources intended for guest usage which is to first unassign them from the matrix mdev, then unbind them from the vfio_ap device driver. Signed-off-by: Tony Krowiak Reviewed-by: Harald Freudenberger Reviewed-by: Halil Pasic --- drivers/s390/crypto

[PATCH v15 07/13] s390/vfio-ap: allow assignment of unavailable AP queues to mdev device

2021-04-06 Thread Tony Krowiak
that are not available to the system. Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 228 -- 1 file changed, 56 insertions(+), 172 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index a8ae1d22aeba..69b58b0fac8f

[PATCH v15 08/13] s390/vfio-ap: allow hot plug/unplug of AP resources using mdev device

2021-04-06 Thread Tony Krowiak
. After refreshing the APCB, if the mdev is in use by a KVM guest, it is hot plugged into the guest to provide access to dynamically provide access to the adapters, domains and control domains provided via the newly refreshed APCB. Signed-off-by: Tony Krowiak Acked-by: Halil Pasic --- drivers/s390

[PATCH v15 06/13] s390/vfio-ap: refresh guest's APCB by filtering APQNs assigned to mdev

2021-04-06 Thread Tony Krowiak
to the mdev. The filtering will take place: * Whenever an adapter, domain or control domains is assigned or unassigned. * When a queue device is bound to or unbound from the vfio_ap device driver. Signed-off-by: Tony Krowiak Acked-by: Halil Pasic --- drivers/s390/crypto/vfio_ap_ops.c | 84

[PATCH v15 04/13] s390/vfio-ap: manage link between queue struct and matrix mdev

2021-04-06 Thread Tony Krowiak
will be removed. Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic --- drivers/s390/crypto/vfio_ap_ops.c | 162 ++ drivers/s390/crypto/vfio_ap_private.h | 3 + 2 files changed, 140 insertions(+), 25 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b

[PATCH v15 05/13] s390/vfio-ap: introduce shadow APCB

2021-04-06 Thread Tony Krowiak
The APCB is a field within the CRYCB that provides the AP configuration to a KVM guest. Let's introduce a shadow copy of the KVM guest's APCB and maintain it for the lifespan of the guest. Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic --- drivers/s390/crypto/vfio_ap_ops.c | 10

[PATCH v15 03/13] s390/vfio-ap: move probe and remove callbacks to vfio_ap_ops.c

2021-04-06 Thread Tony Krowiak
. Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic --- drivers/s390/crypto/vfio_ap_drv.c | 41 ++- drivers/s390/crypto/vfio_ap_ops.c | 28 ++ drivers/s390/crypto/vfio_ap_private.h | 5 ++-- 3 files changed, 33 insertions(+), 41 deletions

[PATCH v15 01/13] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-04-06 Thread Tony Krowiak
fio-ap: clean up vfio_ap resources when KVM pointer invalidated") Cc: sta...@vger.kernel.org Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 308 ++ drivers/s390/crypto/vfio_ap_private.h | 2 + 2 files changed, 215 insertions(+), 95 de

[PATCH v15 02/13] s390/vfio-ap: use new AP bus interface to search for queue devices

2021-04-06 Thread Tony Krowiak
. This is much more efficient than looping over the list of devices attached to the AP bus by several orders of magnitude. Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic --- drivers/s390/crypto/vfio_ap_ops.c | 23 +-- 1 file changed, 9 insertions(+), 14 deletions

[PATCH v15 00/13] s390/vfio-ap: dynamic configuration support

2021-04-06 Thread Tony Krowiak
Change log v1->v2: - * Removed patches preventing root user from unbinding AP queues from the vfio_ap device driver * Introduced a shadow CRYCB in the vfio_ap driver to manage dynamic changes to the AP guest configuration due to root user interventions or hardware anomalies.

Re: [PATCH v14 00/13] s390/vfio-ap: dynamic configuration support

2021-04-06 Thread Tony Krowiak
a new set of patches with the fix included. On 4/1/21 3:17 PM, Halil Pasic wrote: On Wed, 31 Mar 2021 11:22:43 -0400 Tony Krowiak wrote: Change log v13-v14: -- When testing I've experienced this kernel panic. [ 4422.479706] vfio_ap matrix: MDEV: Registered [ 4422.516999

Re: [PATCH v14 00/13] s390/vfio-ap: dynamic configuration support

2021-04-02 Thread Tony Krowiak
On 4/1/21 3:17 PM, Halil Pasic wrote: On Wed, 31 Mar 2021 11:22:43 -0400 Tony Krowiak wrote: Change log v13-v14: -- When testing I've experienced this kernel panic. I am able to recreate this, but only when the kernel is built with the debug_defconfig configuration. I'll

[PATCH v14 12/13] s390/zcrypt: notify drivers on config changed and scan complete callbacks

2021-03-31 Thread Tony Krowiak
the probe callback is invoked. Please note that changes to the apmask and aqmask do not trigger these two callbacks since the bus scan function is not invoked by changes to those masks. Signed-off-by: Harald Freudenberger Reviewed-by: Halil Pasic Signed-off-by: Tony Krowiak --- drivers/s390

[PATCH v14 10/13] s390/vfio-ap: implement in-use callback for vfio_ap driver

2021-03-31 Thread Tony Krowiak
ll as during the in_use callback, the mutex_trylock(_dev->lock) function will be used. If the lock is not obtained, then the assignment and in_use functions will terminate with -EAGAIN. Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_drv.c | 1 + drivers/s390/crypto/vfio_ap

[PATCH v14 13/13] s390/vfio-ap: update docs to include dynamic config support

2021-03-31 Thread Tony Krowiak
Update the documentation in vfio-ap.rst to include information about the AP dynamic configuration support (i.e., hot plug of adapters, domains and control domains via the matrix mediated device's sysfs assignment attributes). Signed-off-by: Tony Krowiak --- Documentation/s390/vfio-ap.rst | 383

[PATCH v14 09/13] s390/zcrypt: driver callback to indicate resource in use

2021-03-31 Thread Tony Krowiak
). This will enforce the proper procedure for removing AP resources intended for guest usage which is to first unassign them from the matrix mdev, then unbind them from the vfio_ap device driver. Signed-off-by: Tony Krowiak Reviewed-by: Harald Freudenberger Reviewed-by: Halil Pasic --- drivers/s390/crypto

[PATCH v14 08/13] s390/vfio-ap: allow hot plug/unplug of AP resources using mdev device

2021-03-31 Thread Tony Krowiak
. After refreshing the APCB, if the mdev is in use by a KVM guest, it is hot plugged into the guest to provide access to dynamically provide access to the adapters, domains and control domains provided via the newly refreshed APCB. Signed-off-by: Tony Krowiak Acked-by: Halil Pasic --- drivers/s390

[PATCH v14 11/13] s390/vfio-ap: sysfs attribute to display the guest's matrix

2021-03-31 Thread Tony Krowiak
that is or will be using the matrix mdev. For a matrix mdev denoted by $uuid, the guest matrix can be displayed as follows: cat /sys/devices/vfio_ap/matrix/$uuid/guest_matrix Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 51 ++- 1 file changed, 37

[PATCH v14 05/13] s390/vfio-ap: introduce shadow APCB

2021-03-31 Thread Tony Krowiak
The APCB is a field within the CRYCB that provides the AP configuration to a KVM guest. Let's introduce a shadow copy of the KVM guest's APCB and maintain it for the lifespan of the guest. Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic --- drivers/s390/crypto/vfio_ap_ops.c | 10

[PATCH v14 07/13] s390/vfio-ap: allow assignment of unavailable AP queues to mdev device

2021-03-31 Thread Tony Krowiak
that are not available to the system. Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 228 -- 1 file changed, 56 insertions(+), 172 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 241051565783..1f2a3049b283

[PATCH v14 06/13] s390/vfio-ap: refresh guest's APCB by filtering APQNs assigned to mdev

2021-03-31 Thread Tony Krowiak
to the mdev. The filtering will take place: * Whenever an adapter, domain or control domains is assigned or unassigned. * When a queue device is bound to or unbound from the vfio_ap device driver. Signed-off-by: Tony Krowiak Acked-by: Halil Pasic --- drivers/s390/crypto/vfio_ap_ops.c | 84

[PATCH v14 02/13] s390/vfio-ap: use new AP bus interface to search for queue devices

2021-03-31 Thread Tony Krowiak
. This is much more efficient than looping over the list of devices attached to the AP bus by several orders of magnitude. Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic --- drivers/s390/crypto/vfio_ap_ops.c | 23 +-- 1 file changed, 9 insertions(+), 14 deletions

[PATCH v14 03/13] s390/vfio-ap: move probe and remove callbacks to vfio_ap_ops.c

2021-03-31 Thread Tony Krowiak
. Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic --- drivers/s390/crypto/vfio_ap_drv.c | 41 ++- drivers/s390/crypto/vfio_ap_ops.c | 28 ++ drivers/s390/crypto/vfio_ap_private.h | 5 ++-- 3 files changed, 33 insertions(+), 41 deletions

[PATCH v14 04/13] s390/vfio-ap: manage link between queue struct and matrix mdev

2021-03-31 Thread Tony Krowiak
is unassigned from a matrix mdev, for each APQN unassigned that references a queue device bound to the vfio_ap device driver, the structures representing the queue device and the matrix mdev will be unlinked. Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic --- drivers/s390/crypto/vfio_ap_ops.c

[PATCH v14 00/13] s390/vfio-ap: dynamic configuration support

2021-03-31 Thread Tony Krowiak
m the vfio_ap device driver * Introduced a shadow CRYCB in the vfio_ap driver to manage dynamic changes to the AP guest configuration due to root user interventions or hardware anomalies. Tony Krowiak (13): s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks s390/vfio-ap:

[PATCH v14 01/13] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-03-31 Thread Tony Krowiak
fio-ap: clean up vfio_ap resources when KVM pointer invalidated") Cc: sta...@vger.kernel.org Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 308 ++ drivers/s390/crypto/vfio_ap_private.h | 2 + 2 files changed, 215 insertions(+), 95 de

Re: [PATCH v13 06/15] s390/vfio-ap: allow assignment of unavailable AP queues to mdev device

2021-03-31 Thread Tony Krowiak
On 1/14/21 8:44 PM, Halil Pasic wrote: On Thu, 14 Jan 2021 12:54:39 -0500 Tony Krowiak wrote: /** * vfio_ap_mdev_verify_no_sharing * - * Verifies that the APQNs derived from the cross product of the AP adapter IDs - * and AP queue indexes comprising the AP matrix

Re: [PATCH v5 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-03-26 Thread Tony Krowiak
On 3/25/21 4:32 PM, Halil Pasic wrote: On Thu, 25 Mar 2021 08:46:40 -0400 Tony Krowiak wrote: This patch fixes a lockdep splat introduced by commit f21916ec4826 ("s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated"). The lockdep splat only occurs when startin

[PATCH v5 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-03-25 Thread Tony Krowiak
fio-ap: clean up vfio_ap resources when KVM pointer invalidated") Cc: sta...@vger.kernel.org Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 309 ++ drivers/s390/crypto/vfio_ap_private.h | 2 + 2 files changed, 215 insertions(+), 96 de

[PATCH v5 0/1] s390/vfio-ap: fix circular lockdep when starting

2021-03-25 Thread Tony Krowiak
_mdev_set_kvm() function instead of the group notifier callback. * Check for the matrix mdev's KVM pointer in the vfio_ap_mdev_unset_kvm() function instead of the vfio_ap_mdev_release() function. Tony Krowiak (1): s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks drive

Re: [PATCH v4 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-03-18 Thread Tony Krowiak
On 3/17/21 7:17 PM, Halil Pasic wrote: On Wed, 10 Mar 2021 10:05:59 -0500 Tony Krowiak wrote: - ret = vfio_ap_mdev_reset_queues(mdev); + matrix_mdev = mdev_get_drvdata(mdev); Is it guaranteed that matrix_mdev can't be NULL here? If yes, please remind me

Re: [PATCH v4 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-03-18 Thread Tony Krowiak
On 3/17/21 7:17 PM, Halil Pasic wrote: On Wed, 10 Mar 2021 10:05:59 -0500 Tony Krowiak wrote: - ret = vfio_ap_mdev_reset_queues(mdev); + matrix_mdev = mdev_get_drvdata(mdev); Is it guaranteed that matrix_mdev can't be NULL here? If yes, please remind me

[PATCH v4 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-03-10 Thread Tony Krowiak
fio-ap: clean up vfio_ap resources when KVM pointer invalidated") Cc: sta...@vger.kernel.org Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 309 ++ drivers/s390/crypto/vfio_ap_private.h | 2 + 2 files changed, 215 insertions(+), 96 de

[PATCH v4 0/1] s390/vfio-ap: fix circular lockdep when starting

2021-03-10 Thread Tony Krowiak
l updates to the data in the matrix mdev that is used to manage AP resources used by the KVM guest in the vfio_ap_mdev_set_kvm() function instead of the group notifier callback. * Check for the matrix mdev's KVM pointer in the vfio_ap_mdev_unset_kvm() function instead of the vfio_ap_mdev_release

Re: [PATCH v3 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-03-09 Thread Tony Krowiak
On 3/9/21 5:23 AM, Halil Pasic wrote: On Thu, 4 Mar 2021 12:43:44 -0500 Tony Krowiak wrote: On the other hand, if we don't have ->kvm because something broke, then we may be out of luck anyway. There will certainly be no way to unregister the GISC; however, it may still be possi

Re: [PATCH v3 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-03-04 Thread Tony Krowiak
On 3/3/21 2:47 PM, Halil Pasic wrote: On Wed, 3 Mar 2021 12:10:11 -0500 Tony Krowiak wrote: On 3/3/21 10:23 AM, Halil Pasic wrote: On Tue, 2 Mar 2021 15:43:22 -0500 Tony Krowiak wrote: This patch fixes a lockdep splat introduced by commit f21916ec4826 ("s390/vfio-ap: cle

Re: [PATCH v3 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-03-04 Thread Tony Krowiak
On 3/3/21 2:42 PM, Halil Pasic wrote: On Wed, 3 Mar 2021 11:41:22 -0500 Tony Krowiak wrote: How do you exect userspace to react to this -ENODEV? The VFIO_DEVICE_RESET ioctl expects a return code. The vfio_ap_mdev_reset_queues() function can return -EIO or -EBUSY, so I would expect

Re: [PATCH v3 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-03-03 Thread Tony Krowiak
On 3/3/21 10:23 AM, Halil Pasic wrote: On Tue, 2 Mar 2021 15:43:22 -0500 Tony Krowiak wrote: This patch fixes a lockdep splat introduced by commit f21916ec4826 ("s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated"). The lockdep splat only occurs when startin

Re: [PATCH v3 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-03-03 Thread Tony Krowiak
On 3/3/21 10:23 AM, Halil Pasic wrote: On Tue, 2 Mar 2021 15:43:22 -0500 Tony Krowiak wrote: This patch fixes a lockdep splat introduced by commit f21916ec4826 ("s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated"). The lockdep splat only occurs when startin

[PATCH v3 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-03-02 Thread Tony Krowiak
fio-ap: clean up vfio_ap resources when KVM pointer invalidated") Cc: sta...@vger.kernel.org Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 312 ++ drivers/s390/crypto/vfio_ap_private.h | 2 + 2 files changed, 218 insertions(+), 96 de

[PATCH v3 0/1] s390/vfio-ap: fix circular lockdep when starting SE guest

2021-03-02 Thread Tony Krowiak
guest. * Make all updates to the data in the matrix mdev that is used to manage AP resources used by the KVM guest in the vfio_ap_mdev_set_kvm() function instead of the group notifier callback. * Check for the matrix mdev's KVM pointer in the vfio_ap_mdev_unset_kvm() function instead of the vfio_ap_md

Re: [PATCH] s390: crypto: Return -EFAULT if copy_to_user() fails

2021-03-01 Thread Tony Krowiak
= 0; info.num_irqs = 0; - return copy_to_user((void __user *)arg, , minsz); + return copy_to_user((void __user *)arg, , minsz) ? -EFAULT : 0; } LGTM Reviewed-by: Tony Krowiak static ssize_t vfio_ap_mdev_ioctl(struct mdev_device *mdev,

Re: [PATCH v2 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-02-25 Thread Tony Krowiak
On 2/25/21 10:35 AM, Halil Pasic wrote: On Thu, 25 Feb 2021 10:25:24 -0500 Tony Krowiak wrote: On 2/25/21 8:53 AM, Tony Krowiak wrote: On 2/25/21 6:28 AM, Halil Pasic wrote: On Wed, 24 Feb 2021 22:28:50 -0500 Tony Krowiak wrote: static void vfio_ap_mdev_unset_kvm(struct

Re: [PATCH v2 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-02-25 Thread Tony Krowiak
On 2/25/21 8:53 AM, Tony Krowiak wrote: On 2/25/21 6:28 AM, Halil Pasic wrote: On Wed, 24 Feb 2021 22:28:50 -0500 Tony Krowiak wrote: static void vfio_ap_mdev_unset_kvm(struct ap_matrix_mdev *matrix_mdev) { - kvm_arch_crypto_clear_masks(matrix_mdev->kvm); - matrix_m

Re: [PATCH v2 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-02-24 Thread Tony Krowiak
On 2/24/21 11:10 AM, Christian Borntraeger wrote: On 23.02.21 10:48, Halil Pasic wrote: On Mon, 15 Feb 2021 20:15:47 -0500 Tony Krowiak wrote: This patch fixes a circular locking dependency in the CI introduced by commit f21916ec4826 ("s390/vfio-ap: clean up vfio_ap resources whe

Re: [PATCH v2 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-02-19 Thread Tony Krowiak
On 2/19/21 8:45 AM, Cornelia Huck wrote: On Mon, 15 Feb 2021 20:15:47 -0500 Tony Krowiak wrote: This patch fixes a circular locking dependency in the CI introduced by commit f21916ec4826 ("s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated"). The lockdep only o

[PATCH v2 0/1] s390/vfio-ap: fix circular lockdep when staring SE guest

2021-02-15 Thread Tony Krowiak
s used to manage AP resources used by the KVM guest in the vfio_ap_mdev_set_kvm() function instead of the group notifier callback. * Check for the matrix mdev's KVM pointer in the vfio_ap_mdev_unset_kvm() function instead of the vfio_ap_mdev_release() function. Tony Krowiak (1): s390/vfio-ap: fix circular lock

[PATCH v2 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-02-15 Thread Tony Krowiak
rily critical for setting the masks, so this will not be done under protection of the matrix_dev->lock. Fixes: f21916ec4826 ("s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated") Cc: sta...@vger.kernel.org Signed-off-by: Tony Krowiak --- drivers/s390/

Re: [PATCH 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-02-11 Thread Tony Krowiak
On 2/11/21 11:47 AM, Halil Pasic wrote: On Thu, 11 Feb 2021 09:21:26 -0500 Tony Krowiak wrote: Yes, it makes sense. I guess I didn't look closely at your suggestion when I said it was exactly what I implemented after agreeing with Connie. I had a slight difference in my implementation

Re: [PATCH 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-02-11 Thread Tony Krowiak
On 2/11/21 7:23 AM, Cornelia Huck wrote: On Wed, 10 Feb 2021 15:34:24 -0500 Tony Krowiak wrote: On 2/10/21 5:53 AM, Cornelia Huck wrote: On Tue, 9 Feb 2021 14:48:30 -0500 Tony Krowiak wrote: This patch fixes a circular locking dependency in the CI introduced by commit f21916ec4826

Re: [PATCH 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-02-11 Thread Tony Krowiak
On 2/10/21 5:46 PM, Halil Pasic wrote: On Wed, 10 Feb 2021 17:05:48 -0500 Tony Krowiak wrote: On 2/10/21 10:32 AM, Halil Pasic wrote: On Wed, 10 Feb 2021 16:24:29 +0100 Halil Pasic wrote: Maybe you could - grab a reference to kvm while holding the lock - call the mask handling

Re: [PATCH 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-02-10 Thread Tony Krowiak
On 2/10/21 10:24 AM, Halil Pasic wrote: On Wed, 10 Feb 2021 11:53:34 +0100 Cornelia Huck wrote: On Tue, 9 Feb 2021 14:48:30 -0500 Tony Krowiak wrote: This patch fixes a circular locking dependency in the CI introduced by commit f21916ec4826 ("s390/vfio-ap: clean up vfio_ap reso

Re: [PATCH 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-02-10 Thread Tony Krowiak
On 2/10/21 10:32 AM, Halil Pasic wrote: On Wed, 10 Feb 2021 16:24:29 +0100 Halil Pasic wrote: Maybe you could - grab a reference to kvm while holding the lock - call the mask handling functions with that kvm reference - lock again, drop the reference, and do the rest of the processing? I

Re: [PATCH 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-02-10 Thread Tony Krowiak
On 2/10/21 5:53 AM, Cornelia Huck wrote: On Tue, 9 Feb 2021 14:48:30 -0500 Tony Krowiak wrote: This patch fixes a circular locking dependency in the CI introduced by commit f21916ec4826 ("s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated"). The lockdep only o

[PATCH 1/1] s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks

2021-02-09 Thread Tony Krowiak
rily critical for setting the masks, so this will not be done under protection of the matrix_dev->lock. Fixes: f21916ec4826 ("s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated") Cc: sta...@vger.kernel.org Signed-off-by: Tony Krowiak --- drivers/s390

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

2021-02-09 Thread Tony Krowiak
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 circ

Re: [PATCH v13 09/15] s390/vfio-ap: allow hot plug/unplug of AP resources using mdev device

2021-02-03 Thread Tony Krowiak
On 1/12/21 12:55 PM, Halil Pasic wrote: On Tue, 12 Jan 2021 02:12:51 +0100 Halil Pasic wrote: @@ -1347,8 +1437,11 @@ void vfio_ap_mdev_remove_queue(struct ap_device *apdev) apqi = AP_QID_QUEUE(q->apqn); vfio_ap_mdev_reset_queue(apid, apqi, 1); - if (q->matrix_mdev) +

Re: [PATCH v13 09/15] s390/vfio-ap: allow hot plug/unplug of AP resources using mdev device

2021-02-01 Thread Tony Krowiak
On 1/12/21 12:55 PM, Halil Pasic wrote: On Tue, 12 Jan 2021 02:12:51 +0100 Halil Pasic wrote: @@ -1347,8 +1437,11 @@ void vfio_ap_mdev_remove_queue(struct ap_device *apdev) apqi = AP_QID_QUEUE(q->apqn); vfio_ap_mdev_reset_queue(apid, apqi, 1); - if (q->matrix_mdev) +

Re: [PATCH v13 08/15] s390/vfio-ap: sysfs attribute to display the guest's matrix

2021-01-28 Thread Tony Krowiak
On 1/11/21 5:58 PM, Halil Pasic wrote: On Tue, 22 Dec 2020 20:15:59 -0500 Tony Krowiak wrote: The matrix of adapters and domains configured in a guest's APCB may differ from the matrix of adapters and domains assigned to the matrix mdev, so this patch introduces a sysfs attribute

Re: [PATCH v13 07/15] s390/vfio-ap: introduce shadow APCB

2021-01-14 Thread Tony Krowiak
On 1/11/21 5:50 PM, Halil Pasic wrote: On Tue, 22 Dec 2020 20:15:58 -0500 Tony Krowiak wrote: The APCB is a field within the CRYCB that provides the AP configuration to a KVM guest. Let's introduce a shadow copy of the KVM guest's APCB and maintain it for the lifespan of the guest. Signed

Re: [PATCH v13 05/15] s390/vfio-ap: manage link between queue struct and matrix mdev

2021-01-14 Thread Tony Krowiak
On 1/13/21 9:50 PM, Halil Pasic wrote: On Wed, 13 Jan 2021 16:41:27 -0500 Tony Krowiak wrote: On 1/11/21 2:17 PM, Halil Pasic wrote: On Tue, 22 Dec 2020 20:15:56 -0500 Tony Krowiak wrote: Let's create links between each queue device bound to the vfio_ap device driver and the matrix

Re: [PATCH v13 06/15] s390/vfio-ap: allow assignment of unavailable AP queues to mdev device

2021-01-14 Thread Tony Krowiak
On 1/11/21 3:40 PM, Halil Pasic wrote: On Tue, 22 Dec 2020 20:15:57 -0500 Tony Krowiak wrote: The current implementation does not allow assignment of an AP adapter or domain to an mdev device if each APQN resulting from the assignment does not reference an AP queue device that is bound

Re: [PATCH v13 02/15] s390/vfio-ap: No need to disable IRQ after queue reset

2021-01-13 Thread Tony Krowiak
On 1/13/21 4:21 PM, Halil Pasic wrote: On Wed, 13 Jan 2021 12:06:28 -0500 Tony Krowiak wrote: On 1/11/21 11:32 AM, Halil Pasic wrote: On Tue, 22 Dec 2020 20:15:53 -0500 Tony Krowiak wrote: The queues assigned to a matrix mediated device are currently reset when

Re: [PATCH v13 05/15] s390/vfio-ap: manage link between queue struct and matrix mdev

2021-01-13 Thread Tony Krowiak
On 1/11/21 2:17 PM, Halil Pasic wrote: On Tue, 22 Dec 2020 20:15:56 -0500 Tony Krowiak wrote: Let's create links between each queue device bound to the vfio_ap device driver and the matrix mdev to which the queue's APQN is assigned. The idea is to facilitate efficient retrieval

Re: [PATCH v13 02/15] s390/vfio-ap: No need to disable IRQ after queue reset

2021-01-13 Thread Tony Krowiak
On 1/11/21 11:32 AM, Halil Pasic wrote: On Tue, 22 Dec 2020 20:15:53 -0500 Tony Krowiak wrote: The queues assigned to a matrix mediated device are currently reset when: * The VFIO_DEVICE_RESET ioctl is invoked * The mdev fd is closed by userspace (QEMU) * The mdev is removed from sysfs

Re: [PATCH v13 00/15] s390/vfio-ap: dynamic configuration support

2021-01-06 Thread Tony Krowiak
Ping On 12/22/20 8:15 PM, Tony Krowiak wrote: Note: Patch 1, s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated does not belong to this series. It has been posted as a separate patch to fix a known problem. It is included here because it will likely pre

[PATCH v5] s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated

2020-12-22 Thread Tony Krowiak
the KVM pointer was set. Fixes: 258287c994de ("s390: vfio-ap: implement mediated device open callback") Cc: sta...@vger.kernel.org Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic Reviewed-by: Cornelia Huck --- drivers/s390/crypto/vfio_ap_ops.c | 49 ++---

[PATCH v13 01/15] s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated

2020-12-22 Thread Tony Krowiak
the KVM pointer was set. Fixes: 258287c994de ("s390: vfio-ap: implement mediated device open callback") Cc: sta...@vger.kernel.org Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic Reviewed-by: Cornelia Huck --- drivers/s390/crypto/vfio_ap_ops.c | 49 ++---

[PATCH v13 04/15] s390/vfio-ap: use new AP bus interface to search for queue devices

2020-12-22 Thread Tony Krowiak
. This is much more efficient than looping over the list of devices attached to the AP bus by several orders of magnitude. Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic --- drivers/s390/crypto/vfio_ap_ops.c | 25 ++--- 1 file changed, 10 insertions(+), 15 deletions

[PATCH v13 05/15] s390/vfio-ap: manage link between queue struct and matrix mdev

2020-12-22 Thread Tony Krowiak
representing the queue device and the matrix mdev will be unlinked. Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 140 +- drivers/s390/crypto/vfio_ap_private.h | 3 + 2 files changed, 117 insertions(+), 26 deletions(-) diff --git a/drivers/s390

[PATCH v13 08/15] s390/vfio-ap: sysfs attribute to display the guest's matrix

2020-12-22 Thread Tony Krowiak
that is or will be using the matrix mdev. For a matrix mdev denoted by $uuid, the guest matrix can be displayed as follows: cat /sys/devices/vfio_ap/matrix/$uuid/guest_matrix Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 51 ++- 1 file changed, 37

[PATCH v13 06/15] s390/vfio-ap: allow assignment of unavailable AP queues to mdev device

2020-12-22 Thread Tony Krowiak
that are not available to the system. 2. APQNs that do not reference a queue device bound to the vfio_ap device driver will not be assigned to the guest's CRYCB, so the guest will not get access to queues not bound to the vfio_ap driver. Signed-off-by: Tony Krowiak --- drivers/s390

[PATCH v13 10/15] s390/zcrypt: driver callback to indicate resource in use

2020-12-22 Thread Tony Krowiak
). This will enforce the proper procedure for removing AP resources intended for guest usage which is to first unassign them from the matrix mdev, then unbind them from the vfio_ap device driver. Signed-off-by: Tony Krowiak Reviewed-by: Harald Freudenberger --- drivers/s390/crypto/ap_bus.c | 160

[PATCH v13 07/15] s390/vfio-ap: introduce shadow APCB

2020-12-22 Thread Tony Krowiak
The APCB is a field within the CRYCB that provides the AP configuration to a KVM guest. Let's introduce a shadow copy of the KVM guest's APCB and maintain it for the lifespan of the guest. Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic --- drivers/s390/crypto/vfio_ap_ops.c | 15

[PATCH v13 14/15] s390/vfio-ap: handle AP bus scan completed notification

2020-12-22 Thread Tony Krowiak
derived from the newly added APQI of the domain and the APIDs already assigned to the guest's APCB references an AP queue device bound to the vfio_ap driver Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_drv.c | 1 + drivers/s390/crypto/vfio_ap_ops.c | 21

[PATCH v13 09/15] s390/vfio-ap: allow hot plug/unplug of AP resources using mdev device

2020-12-22 Thread Tony Krowiak
, it is hot plugged into the guest to provide access to dynamically provide access to the adapters, domains and control domains provided via the newly refreshed APCB. Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 143 -- 1 file changed, 118

[PATCH v13 15/15] s390/vfio-ap: update docs to include dynamic config support

2020-12-22 Thread Tony Krowiak
Update the documentation in vfio-ap.rst to include information about the AP dynamic configuration support (i.e., hot plug of adapters, domains and control domains via the matrix mediated device's sysfs assignment attributes). Signed-off-by: Tony Krowiak --- Documentation/s390/vfio-ap.rst | 383

[PATCH v13 13/15] s390/vfio-ap: handle host AP config change notification

2020-12-22 Thread Tony Krowiak
from the host AP configuration, the APCB of the matrix mdev will be refreshed. If a KVM guest is using the matrix mdev, the APCB will be hot plugged into the guest to refresh its AP configuration. Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_drv.c | 3 +- drivers/s390/crypto

[PATCH v13 11/15] s390/vfio-ap: implement in-use callback for vfio_ap driver

2020-12-22 Thread Tony Krowiak
ll as during the in_use callback, the mutex_trylock(_dev->lock) function will be used. If the lock is not obtained, then the assignment and in_use functions will terminate with -EBUSY. Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_drv.c | 1 + drivers/s390/crypto/vfio_ap

[PATCH v13 12/15] s390/zcrypt: Notify driver on config changed and scan complete callbacks

2020-12-22 Thread Tony Krowiak
the probe callback is invoked. Please note that changes to the apmask and aqmask do not trigger these two callbacks since the bus scan function is not invoked by changes to those masks. Signed-off-by: Harald Freudenberger Signed-off-by: Tony Krowiak --- drivers/s390/crypto/ap_bus.c | 91

[PATCH v13 03/15] s390/vfio-ap: move probe and remove callbacks to vfio_ap_ops.c

2020-12-22 Thread Tony Krowiak
. Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic --- drivers/s390/crypto/vfio_ap_drv.c | 44 ++- drivers/s390/crypto/vfio_ap_ops.c | 34 +++-- drivers/s390/crypto/vfio_ap_private.h | 6 ++-- 3 files changed, 37 insertions(+), 47 deletions

[PATCH v13 02/15] s390/vfio-ap: No need to disable IRQ after queue reset

2020-12-22 Thread Tony Krowiak
. This is entirely unnecessary because the reset of a queue disables interrupts, so this will be removed. Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_drv.c | 1 - drivers/s390/crypto/vfio_ap_ops.c | 40 +-- drivers/s390/crypto/vfio_ap_private.h | 1 - 3 files

[PATCH v13 00/15] s390/vfio-ap: dynamic configuration support

2020-12-22 Thread Tony Krowiak
v1->v2: - * Removed patches preventing root user from unbinding AP queues from the vfio_ap device driver * Introduced a shadow CRYCB in the vfio_ap driver to manage dynamic changes to the AP guest configuration due to root user interventions or hardware anomalies. Tony Krowiak (15): s39

Re: [PATCH v4] s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated

2020-12-22 Thread Tony Krowiak
On 12/22/20 2:43 PM, Halil Pasic wrote: On Tue, 22 Dec 2020 16:57:06 +0100 Cornelia Huck wrote: On Tue, 22 Dec 2020 10:37:01 -0500 Tony Krowiak wrote: On 12/21/20 11:05 PM, Halil Pasic wrote: On Mon, 21 Dec 2020 13:56:25 -0500 Tony Krowiak wrote: static int

Re: [PATCH v4] s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated

2020-12-22 Thread Tony Krowiak
On 12/21/20 11:05 PM, Halil Pasic wrote: On Mon, 21 Dec 2020 13:56:25 -0500 Tony Krowiak wrote: The vfio_ap device driver registers a group notifier with VFIO when the file descriptor for a VFIO mediated device for a KVM guest is opened to receive notification that the KVM pointer is set

[PATCH v4] s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated

2020-12-21 Thread Tony Krowiak
the KVM pointer was set. Fixes: 258287c994de ("s390: vfio-ap: implement mediated device open callback") Cc: sta...@vger.kernel.org Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic Reviewed-by: Cornelia Huck --- drivers/s390/crypto/vfio_ap_ops.c | 42 +

Re: [PATCH v3] s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated

2020-12-16 Thread Tony Krowiak
taken when the KVM pointer was set. Fixes: 258287c994de ("s390: vfio-ap: implement mediated device open callback") Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 29 - 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/dr

Re: [PATCH v3] s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated

2020-12-16 Thread Tony Krowiak
On 12/14/20 11:56 AM, Tony Krowiak wrote: The vfio_ap device driver registers a group notifier with VFIO when the file descriptor for a VFIO mediated device for a KVM guest is opened to receive notification that the KVM pointer is set (VFIO_GROUP_NOTIFY_SET_KVM event). When the KVM pointer

Re: [PATCH v12 14/17] s390/zcrypt: Notify driver on config changed and scan complete callbacks

2020-12-16 Thread Tony Krowiak
On 11/30/20 4:18 AM, h...@d06av26.portsmouth.uk.ibm.com wrote: On Tue, 24 Nov 2020 16:40:13 -0500 Tony Krowiak wrote: This patch intruduces an extension to the ap bus to notify device drivers when the host AP configuration changes - i.e., adapters, domains or control domains are added

Re: [PATCH v12 14/17] s390/zcrypt: Notify driver on config changed and scan complete callbacks

2020-12-16 Thread Tony Krowiak
On 12/9/20 2:20 AM, Harald Freudenberger wrote: On 30.11.20 10:18, h...@d06av26.portsmouth.uk.ibm.com wrote: On Tue, 24 Nov 2020 16:40:13 -0500 Tony Krowiak wrote: This patch intruduces an extension to the ap bus to notify device drivers when the host AP configuration changes - i.e

Re: [PATCH v12 10/17] s390/vfio-ap: initialize the guest apcb

2020-12-16 Thread Tony Krowiak
On 11/28/20 8:09 PM, Halil Pasic wrote: On Tue, 24 Nov 2020 16:40:09 -0500 Tony Krowiak wrote: The APCB is a control block containing the masks that specify the adapters, domains and control domains to which a KVM guest is granted access. When the vfio_ap device driver is notified

Re: [PATCH v12 11/17] s390/vfio-ap: allow assignment of unavailable AP queues to mdev device

2020-12-16 Thread Tony Krowiak
On 11/28/20 8:17 PM, Halil Pasic wrote: On Tue, 24 Nov 2020 16:40:10 -0500 Tony Krowiak wrote: The current implementation does not allow assignment of an AP adapter or domain to an mdev device if each APQN resulting from the assignment does not reference an AP queue device that is bound

Re: [PATCH v12 09/17] s390/vfio-ap: sysfs attribute to display the guest's matrix

2020-12-16 Thread Tony Krowiak
Thanks for the review. On 11/28/20 7:49 PM, Halil Pasic wrote: On Tue, 24 Nov 2020 16:40:08 -0500 Tony Krowiak wrote: The matrix of adapters and domains configured in a guest's APCB may differ from the matrix of adapters and domains assigned to the matrix mdev, so this patch introduces

Re: [PATCH v12 07/17] s390/vfio-ap: implement in-use callback for vfio_ap driver

2020-12-14 Thread Tony Krowiak
On 11/26/20 10:54 AM, Halil Pasic wrote: On Tue, 24 Nov 2020 16:40:06 -0500 Tony Krowiak wrote: Let's implement the callback to indicate when an APQN is in use by the vfio_ap device driver. The callback is invoked whenever a change to the apmask or aqmask would result in one or more queue

Re: [PATCH v12 05/17] s390/vfio-ap: manage link between queue struct and matrix mdev

2020-12-14 Thread Tony Krowiak
On 11/26/20 9:08 AM, Halil Pasic wrote: On Tue, 24 Nov 2020 16:40:04 -0500 Tony Krowiak wrote: @@ -1155,6 +1243,11 @@ static int vfio_ap_mdev_reset_queues(struct mdev_device *mdev) matrix_mdev->matrix.apm_max + 1) { for_each_set_bit_inv(a

  1   2   3   4   5   6   7   8   9   10   >