* [PATCH v2] s390/vfio-ap: fix sysfs status attribute for AP queue devices
@ 2023-11-08 20:11 Tony Krowiak
2023-11-08 20:21 ` Tony Krowiak
0 siblings, 1 reply; 5+ messages in thread
From: Tony Krowiak @ 2023-11-08 20:11 UTC (permalink / raw)
To: linux-s390, linux-kernel, kvm
Cc: jjherne, pasic, borntraeger, frankja, imbrenda, david,
Harald Freudenberger
The 'status' attribute for AP queue devices bound to the vfio_ap device
driver displays incorrect status when the mediated device is attached to a
guest, but the queue device is not passed through. In the current
implementation, the status displayed is 'in_use' which is not correct; it
should be 'assigned'. This can happen if one of the queue devices
associated with a given adapter is not bound to the vfio_ap device driver.
For example:
Queues listed in /sys/bus/ap/drivers/vfio_ap:
14.0005
14.0006
14.000d
16.0006
16.000d
Queues listed in /sys/devices/vfio_ap/matrix/$UUID/matrix
14.0005
14.0006
14.000d
16.0005
16.0006
16.000d
Queues listed in /sys/devices/vfio_ap/matrix/$UUID/guest_matrix
14.0005
14.0006
14.000d
The reason no queues for adapter 0x16 are listed in the guest_matrix is
because queue 16.0005 is not bound to the vfio_ap device driver, so no
queue associated with the adapter is passed through to the guest;
therefore, each queue device for adapter 0x16 should display 'assigned'
instead of 'in_use', because those queues are not in use by a guest, but
only assigned to the mediated device.
Let's check the AP configuration for the guest to determine whether a
queue device is passed through before displaying a status of 'in_use'.
Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
Acked-by: Halil Pasic <pasic@linux.ibm.com>
Acked-by: Harald Freudenberger <freude@linux.ibm.com>
---
drivers/s390/crypto/vfio_ap_ops.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
index 4db538a55192..6e0a79086656 100644
--- a/drivers/s390/crypto/vfio_ap_ops.c
+++ b/drivers/s390/crypto/vfio_ap_ops.c
@@ -1976,6 +1976,7 @@ static ssize_t status_show(struct device *dev,
{
ssize_t nchars = 0;
struct vfio_ap_queue *q;
+ unsigned long apid, apqi;
struct ap_matrix_mdev *matrix_mdev;
struct ap_device *apdev = to_ap_dev(dev);
@@ -1983,8 +1984,21 @@ static ssize_t status_show(struct device *dev,
q = dev_get_drvdata(&apdev->device);
matrix_mdev = vfio_ap_mdev_for_queue(q);
+ /* If the queue is assigned to the matrix mediated device, then
+ * determine whether it is passed through to a guest; otherwise,
+ * indicate that it is unassigned.
+ */
if (matrix_mdev) {
- if (matrix_mdev->kvm)
+ apid = AP_QID_CARD(q->apqn);
+ apqi = AP_QID_QUEUE(q->apqn);
+ /*
+ * If the queue is passed through to the guest, then indicate
+ * that it is in use; otherwise, indicate that it is
+ * merely assigned to a matrix mediated device.
+ */
+ if (matrix_mdev->kvm &&
+ test_bit_inv(apid, matrix_mdev->shadow_apcb.apm) &&
+ test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm))
nchars = scnprintf(buf, PAGE_SIZE, "%s\n",
AP_QUEUE_IN_USE);
else
--
2.41.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] s390/vfio-ap: fix sysfs status attribute for AP queue devices
2023-11-08 20:11 [PATCH v2] s390/vfio-ap: fix sysfs status attribute for AP queue devices Tony Krowiak
@ 2023-11-08 20:21 ` Tony Krowiak
2023-11-20 9:16 ` Christian Borntraeger
0 siblings, 1 reply; 5+ messages in thread
From: Tony Krowiak @ 2023-11-08 20:21 UTC (permalink / raw)
To: linux-s390, linux-kernel, kvm
Cc: jjherne, pasic, borntraeger, frankja, imbrenda, david,
Harald Freudenberger
Christian,
Can this be pushed with the Acks by Halil and Harald?
On 11/8/23 15:11, Tony Krowiak wrote:
> The 'status' attribute for AP queue devices bound to the vfio_ap device
> driver displays incorrect status when the mediated device is attached to a
> guest, but the queue device is not passed through. In the current
> implementation, the status displayed is 'in_use' which is not correct; it
> should be 'assigned'. This can happen if one of the queue devices
> associated with a given adapter is not bound to the vfio_ap device driver.
> For example:
>
> Queues listed in /sys/bus/ap/drivers/vfio_ap:
> 14.0005
> 14.0006
> 14.000d
> 16.0006
> 16.000d
>
> Queues listed in /sys/devices/vfio_ap/matrix/$UUID/matrix
> 14.0005
> 14.0006
> 14.000d
> 16.0005
> 16.0006
> 16.000d
>
> Queues listed in /sys/devices/vfio_ap/matrix/$UUID/guest_matrix
> 14.0005
> 14.0006
> 14.000d
>
> The reason no queues for adapter 0x16 are listed in the guest_matrix is
> because queue 16.0005 is not bound to the vfio_ap device driver, so no
> queue associated with the adapter is passed through to the guest;
> therefore, each queue device for adapter 0x16 should display 'assigned'
> instead of 'in_use', because those queues are not in use by a guest, but
> only assigned to the mediated device.
>
> Let's check the AP configuration for the guest to determine whether a
> queue device is passed through before displaying a status of 'in_use'.
>
> Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
> Acked-by: Halil Pasic <pasic@linux.ibm.com>
> Acked-by: Harald Freudenberger <freude@linux.ibm.com>
> ---
> drivers/s390/crypto/vfio_ap_ops.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index 4db538a55192..6e0a79086656 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c
> @@ -1976,6 +1976,7 @@ static ssize_t status_show(struct device *dev,
> {
> ssize_t nchars = 0;
> struct vfio_ap_queue *q;
> + unsigned long apid, apqi;
> struct ap_matrix_mdev *matrix_mdev;
> struct ap_device *apdev = to_ap_dev(dev);
>
> @@ -1983,8 +1984,21 @@ static ssize_t status_show(struct device *dev,
> q = dev_get_drvdata(&apdev->device);
> matrix_mdev = vfio_ap_mdev_for_queue(q);
>
> + /* If the queue is assigned to the matrix mediated device, then
> + * determine whether it is passed through to a guest; otherwise,
> + * indicate that it is unassigned.
> + */
> if (matrix_mdev) {
> - if (matrix_mdev->kvm)
> + apid = AP_QID_CARD(q->apqn);
> + apqi = AP_QID_QUEUE(q->apqn);
> + /*
> + * If the queue is passed through to the guest, then indicate
> + * that it is in use; otherwise, indicate that it is
> + * merely assigned to a matrix mediated device.
> + */
> + if (matrix_mdev->kvm &&
> + test_bit_inv(apid, matrix_mdev->shadow_apcb.apm) &&
> + test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm))
> nchars = scnprintf(buf, PAGE_SIZE, "%s\n",
> AP_QUEUE_IN_USE);
> else
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] s390/vfio-ap: fix sysfs status attribute for AP queue devices
2023-11-08 20:21 ` Tony Krowiak
@ 2023-11-20 9:16 ` Christian Borntraeger
2023-11-21 14:36 ` Alexander Gordeev
0 siblings, 1 reply; 5+ messages in thread
From: Christian Borntraeger @ 2023-11-20 9:16 UTC (permalink / raw)
To: Tony Krowiak, linux-s390, linux-kernel, kvm, Alexander Gordeev,
Vasily Gorbik, Heiko Carstens
Cc: jjherne, pasic, frankja, imbrenda, david, Harald Freudenberger
Am 08.11.23 um 21:21 schrieb Tony Krowiak:
> Christian,
> Can this be pushed with the Acks by Halil and Harald?
[...]
>> Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
>> Acked-by: Halil Pasic <pasic@linux.ibm.com>
>> Acked-by: Harald Freudenberger <freude@linux.ibm.com>
>> ---
>> drivers/s390/crypto/vfio_ap_ops.c | 16 +++++++++++++++-
>> 1 file changed, 15 insertions(+), 1 deletion(-)
>>
I think this can go via the s390 tree as well. Alexander do you want to take it?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] s390/vfio-ap: fix sysfs status attribute for AP queue devices
2023-11-20 9:16 ` Christian Borntraeger
@ 2023-11-21 14:36 ` Alexander Gordeev
2023-11-21 22:02 ` Tony Krowiak
0 siblings, 1 reply; 5+ messages in thread
From: Alexander Gordeev @ 2023-11-21 14:36 UTC (permalink / raw)
To: Christian Borntraeger
Cc: Tony Krowiak, linux-s390, linux-kernel, kvm, Vasily Gorbik,
Heiko Carstens, jjherne, pasic, frankja, imbrenda, david,
Harald Freudenberger
On Mon, Nov 20, 2023 at 10:16:10AM +0100, Christian Borntraeger wrote:
> I think this can go via the s390 tree as well. Alexander do you want to take it?
Applied, thanks!
I assume, it does not need to wait until the merge window?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] s390/vfio-ap: fix sysfs status attribute for AP queue devices
2023-11-21 14:36 ` Alexander Gordeev
@ 2023-11-21 22:02 ` Tony Krowiak
0 siblings, 0 replies; 5+ messages in thread
From: Tony Krowiak @ 2023-11-21 22:02 UTC (permalink / raw)
To: Alexander Gordeev, Christian Borntraeger
Cc: linux-s390, linux-kernel, kvm, Vasily Gorbik, Heiko Carstens,
jjherne, pasic, frankja, imbrenda, david, Harald Freudenberger
On 11/21/23 09:36, Alexander Gordeev wrote:
> On Mon, Nov 20, 2023 at 10:16:10AM +0100, Christian Borntraeger wrote:
>> I think this can go via the s390 tree as well. Alexander do you want to take it?
>
> Applied, thanks!
>
> I assume, it does not need to wait until the merge window?
I can't answer that question, but this is not a critical fix as it
simply fixes an erroneous display of a queue's status via it's sysfs
status attribute which is reflected in the lszcrypt -V output. The error
only occurs in a specific instance which is likely rare.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-21 22:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-08 20:11 [PATCH v2] s390/vfio-ap: fix sysfs status attribute for AP queue devices Tony Krowiak
2023-11-08 20:21 ` Tony Krowiak
2023-11-20 9:16 ` Christian Borntraeger
2023-11-21 14:36 ` Alexander Gordeev
2023-11-21 22:02 ` Tony Krowiak
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.