From: Anthony Krowiak <akrowiak@linux.ibm.com>
To: Yi Liu <yi.l.liu@intel.com>, jgg@nvidia.com
Cc: alex.williamson@redhat.com, kevin.tian@intel.com,
kvm@vger.kernel.org, mjrosato@linux.ibm.com,
chao.p.peng@linux.intel.com, yi.y.sun@linux.intel.com,
intel-gvt-dev@lists.freedesktop.org, linux-s390@vger.kernel.org,
Halil Pasic <pasic@linux.ibm.com>,
Jason Herne <jjherne@linux.ibm.com>
Subject: Re: [[RESEND] iommufd PATCH v2 2/2] vfio/ap: validate iova during dma_unmap and trigger irq disable
Date: Tue, 29 Nov 2022 17:02:23 -0500 [thread overview]
Message-ID: <69fd3f57-4589-2d9e-3aa1-7959cc1711e6@linux.ibm.com> (raw)
In-Reply-To: <20221129105831.466954-3-yi.l.liu@intel.com>
LGTM:
Reviewed-by: Tony Krowiak <akrowiak@linux.ibm.com>
On 11/29/22 5:58 AM, Yi Liu wrote:
> From: Matthew Rosato <mjrosato@linux.ibm.com>
>
> Currently, each mapped iova is stashed in its associated vfio_ap_queue;
> when we get an unmap request, validate that it matches with one or more
> of these stashed values before attempting unpins.
>
> Each stashed iova represents IRQ that was enabled for a queue. Therefore,
> if a match is found, trigger IRQ disable for this queue to ensure that
> underlying firmware will no longer try to use the associated pfn after
> the page is unpinned. IRQ disable will also handle the associated unpin.
>
> Cc: Tony Krowiak <akrowiak@linux.ibm.com>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Jason Herne <jjherne@linux.ibm.com>
> Cc: linux-s390@vger.kernel.org
> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
> Signed-off-by: Yi Liu <yi.l.liu@intel.com>
> ---
> drivers/s390/crypto/vfio_ap_ops.c | 18 +++++++++++++++++-
> 1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index 0b4cc8c597ae..8bf353d46820 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c
> @@ -1535,13 +1535,29 @@ static int vfio_ap_mdev_set_kvm(struct ap_matrix_mdev *matrix_mdev,
> return 0;
> }
>
> +static void unmap_iova(struct ap_matrix_mdev *matrix_mdev, u64 iova, u64 length)
> +{
> + struct ap_queue_table *qtable = &matrix_mdev->qtable;
> + struct vfio_ap_queue *q;
> + int loop_cursor;
> +
> + hash_for_each(qtable->queues, loop_cursor, q, mdev_qnode) {
> + if (q->saved_iova >= iova && q->saved_iova < iova + length)
> + vfio_ap_irq_disable(q);
> + }
> +}
> +
> static void vfio_ap_mdev_dma_unmap(struct vfio_device *vdev, u64 iova,
> u64 length)
> {
> struct ap_matrix_mdev *matrix_mdev =
> container_of(vdev, struct ap_matrix_mdev, vdev);
>
> - vfio_unpin_pages(&matrix_mdev->vdev, iova, 1);
> + mutex_lock(&matrix_dev->mdevs_lock);
> +
> + unmap_iova(matrix_mdev, iova, length);
> +
> + mutex_unlock(&matrix_dev->mdevs_lock);
> }
>
> /**
prev parent reply other threads:[~2022-11-29 22:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-29 10:58 [[RESEND] iommufd PATCH v2 0/2] Make mdev driver dma_unmap callback tolerant to unmaps come before device open Yi Liu
2022-11-29 10:58 ` [[RESEND] iommufd PATCH v2 1/2] i915/gvt: Move gvt mapping cache initialization to intel_vgpu_init_dev() Yi Liu
2022-12-01 3:25 ` Zhenyu Wang
2022-12-01 4:18 ` Yi Liu
2022-12-01 7:21 ` Zhenyu Wang
2022-12-01 7:51 ` Yi Liu
2022-11-29 10:58 ` [[RESEND] iommufd PATCH v2 2/2] vfio/ap: validate iova during dma_unmap and trigger irq disable Yi Liu
2022-11-29 22:02 ` Anthony Krowiak [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=69fd3f57-4589-2d9e-3aa1-7959cc1711e6@linux.ibm.com \
--to=akrowiak@linux.ibm.com \
--cc=alex.williamson@redhat.com \
--cc=chao.p.peng@linux.intel.com \
--cc=intel-gvt-dev@lists.freedesktop.org \
--cc=jgg@nvidia.com \
--cc=jjherne@linux.ibm.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mjrosato@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=yi.l.liu@intel.com \
--cc=yi.y.sun@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox