2023-11-29 14:54:28

by Anthony Krowiak

[permalink] [raw]
Subject: [PATCH v4 1/3] s390/vfio-ap: unpin pages on gisc registration failure

From: Anthony Krowiak <[email protected]>

In the vfio_ap_irq_enable function, after the page containing the
notification indicator byte (NIB) is pinned, the function attempts
to register the guest ISC. If registration fails, the function sets the
status response code and returns without unpinning the page containing
the NIB. In order to avoid a memory leak, the NIB should be unpinned before
returning from the vfio_ap_irq_enable function.

Co-developed-by: Janosch Frank <[email protected]>
Signed-off-by: Janosch Frank <[email protected]>
Signed-off-by: Anthony Krowiak <[email protected]>
Reviewed-by: Matthew Rosato <[email protected]>
Fixes: 783f0a3ccd79 ("s390/vfio-ap: add s390dbf logging to the vfio_ap_irq_enable function")
Cc: <[email protected]>
---
drivers/s390/crypto/vfio_ap_ops.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
index 4db538a55192..9cb28978c186 100644
--- a/drivers/s390/crypto/vfio_ap_ops.c
+++ b/drivers/s390/crypto/vfio_ap_ops.c
@@ -457,6 +457,7 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
VFIO_AP_DBF_WARN("%s: gisc registration failed: nisc=%d, isc=%d, apqn=%#04x\n",
__func__, nisc, isc, q->apqn);

+ vfio_unpin_pages(&q->matrix_mdev->vdev, nib, 1);
status.response_code = AP_RESPONSE_INVALID_GISA;
return status;
}
--
2.41.0


2023-12-01 09:57:56

by Christian Borntraeger

[permalink] [raw]
Subject: Re: [PATCH v4 1/3] s390/vfio-ap: unpin pages on gisc registration failure

Am 29.11.23 um 15:53 schrieb Tony Krowiak:
> From: Anthony Krowiak <[email protected]>
>
> In the vfio_ap_irq_enable function, after the page containing the
> notification indicator byte (NIB) is pinned, the function attempts
> to register the guest ISC. If registration fails, the function sets the
> status response code and returns without unpinning the page containing
> the NIB. In order to avoid a memory leak, the NIB should be unpinned before
> returning from the vfio_ap_irq_enable function.
>
> Co-developed-by: Janosch Frank <[email protected]>
> Signed-off-by: Janosch Frank <[email protected]>
> Signed-off-by: Anthony Krowiak <[email protected]>
> Reviewed-by: Matthew Rosato <[email protected]>
> Fixes: 783f0a3ccd79 ("s390/vfio-ap: add s390dbf logging to the vfio_ap_irq_enable function")
> Cc: <[email protected]>

Acked-by: Christian Borntraeger <[email protected]>

should go via the s390 tree
Tony, please CC Heiko, Vasily and Alexander

> ---
> drivers/s390/crypto/vfio_ap_ops.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index 4db538a55192..9cb28978c186 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c
> @@ -457,6 +457,7 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
> VFIO_AP_DBF_WARN("%s: gisc registration failed: nisc=%d, isc=%d, apqn=%#04x\n",
> __func__, nisc, isc, q->apqn);
>
> + vfio_unpin_pages(&q->matrix_mdev->vdev, nib, 1);
> status.response_code = AP_RESPONSE_INVALID_GISA;
> return status;
> }