* [Qemu-devel] [PATCH] virtio-scsi: finalize IOMMU support
@ 2017-07-04 12:21 Jason Wang
2017-07-04 23:49 ` Fam Zheng
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jason Wang @ 2017-07-04 12:21 UTC (permalink / raw)
To: mst, pbonzini, qemu-devel; +Cc: Jason Wang, qemu-stable
After converting to use DMA api for virtio devices, we should use
dma_as instead of address_space_memory. Otherwise it won't work if
IOMMU is enabled.
Fixes: commit 8607f5c3072c ("virtio: convert to use DMA api")
Cc: qemu-stable@nongnu.org
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/scsi/virtio-scsi.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index f46f06d..d076fe7 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -43,12 +43,13 @@ static inline SCSIDevice *virtio_scsi_device_find(VirtIOSCSI *s, uint8_t *lun)
void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req)
{
+ VirtIODevice *vdev = VIRTIO_DEVICE(s);
const size_t zero_skip =
offsetof(VirtIOSCSIReq, resp_iov) + sizeof(req->resp_iov);
req->vq = vq;
req->dev = s;
- qemu_sglist_init(&req->qsgl, DEVICE(s), 8, &address_space_memory);
+ qemu_sglist_init(&req->qsgl, DEVICE(s), 8, vdev->dma_as);
qemu_iovec_init(&req->resp_iov, 1);
memset((uint8_t *)req + zero_skip, 0, sizeof(*req) - zero_skip);
}
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-scsi: finalize IOMMU support
2017-07-04 12:21 [Qemu-devel] [PATCH] virtio-scsi: finalize IOMMU support Jason Wang
@ 2017-07-04 23:49 ` Fam Zheng
2017-07-05 2:49 ` Wei Xu
2017-07-05 6:23 ` Fam Zheng
2 siblings, 0 replies; 5+ messages in thread
From: Fam Zheng @ 2017-07-04 23:49 UTC (permalink / raw)
To: Jason Wang; +Cc: mst, pbonzini, qemu-devel, qemu-stable
On Tue, 07/04 20:21, Jason Wang wrote:
> After converting to use DMA api for virtio devices, we should use
> dma_as instead of address_space_memory. Otherwise it won't work if
> IOMMU is enabled.
>
> Fixes: commit 8607f5c3072c ("virtio: convert to use DMA api")
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-scsi: finalize IOMMU support
2017-07-04 12:21 [Qemu-devel] [PATCH] virtio-scsi: finalize IOMMU support Jason Wang
2017-07-04 23:49 ` Fam Zheng
@ 2017-07-05 2:49 ` Wei Xu
2017-07-05 6:23 ` Fam Zheng
2 siblings, 0 replies; 5+ messages in thread
From: Wei Xu @ 2017-07-05 2:49 UTC (permalink / raw)
To: Jason Wang; +Cc: mst, pbonzini, qemu-devel, qemu-stable
On Tue, Jul 04, 2017 at 08:21:06PM +0800, Jason Wang wrote:
> After converting to use DMA api for virtio devices, we should use
> dma_as instead of address_space_memory. Otherwise it won't work if
> IOMMU is enabled.
>
> Fixes: commit 8607f5c3072c ("virtio: convert to use DMA api")
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
> hw/scsi/virtio-scsi.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
> index f46f06d..d076fe7 100644
> --- a/hw/scsi/virtio-scsi.c
> +++ b/hw/scsi/virtio-scsi.c
> @@ -43,12 +43,13 @@ static inline SCSIDevice *virtio_scsi_device_find(VirtIOSCSI *s, uint8_t *lun)
>
> void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req)
> {
> + VirtIODevice *vdev = VIRTIO_DEVICE(s);
> const size_t zero_skip =
> offsetof(VirtIOSCSIReq, resp_iov) + sizeof(req->resp_iov);
>
> req->vq = vq;
> req->dev = s;
> - qemu_sglist_init(&req->qsgl, DEVICE(s), 8, &address_space_memory);
> + qemu_sglist_init(&req->qsgl, DEVICE(s), 8, vdev->dma_as);
> qemu_iovec_init(&req->resp_iov, 1);
> memset((uint8_t *)req + zero_skip, 0, sizeof(*req) - zero_skip);
> }
Reviewed-by: Wei Xu <wexu@redhat.com>
> --
> 2.7.4
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-scsi: finalize IOMMU support
2017-07-04 12:21 [Qemu-devel] [PATCH] virtio-scsi: finalize IOMMU support Jason Wang
2017-07-04 23:49 ` Fam Zheng
2017-07-05 2:49 ` Wei Xu
@ 2017-07-05 6:23 ` Fam Zheng
2017-07-05 6:27 ` Paolo Bonzini
2 siblings, 1 reply; 5+ messages in thread
From: Fam Zheng @ 2017-07-05 6:23 UTC (permalink / raw)
To: mst, pbonzini, Jason Wang; +Cc: qemu-devel, qemu-stable
On Tue, 07/04 20:21, Jason Wang wrote:
> After converting to use DMA api for virtio devices, we should use
> dma_as instead of address_space_memory. Otherwise it won't work if
> IOMMU is enabled.
>
> Fixes: commit 8607f5c3072c ("virtio: convert to use DMA api")
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
> hw/scsi/virtio-scsi.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
> index f46f06d..d076fe7 100644
> --- a/hw/scsi/virtio-scsi.c
> +++ b/hw/scsi/virtio-scsi.c
> @@ -43,12 +43,13 @@ static inline SCSIDevice *virtio_scsi_device_find(VirtIOSCSI *s, uint8_t *lun)
>
> void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req)
> {
> + VirtIODevice *vdev = VIRTIO_DEVICE(s);
> const size_t zero_skip =
> offsetof(VirtIOSCSIReq, resp_iov) + sizeof(req->resp_iov);
>
> req->vq = vq;
> req->dev = s;
> - qemu_sglist_init(&req->qsgl, DEVICE(s), 8, &address_space_memory);
> + qemu_sglist_init(&req->qsgl, DEVICE(s), 8, vdev->dma_as);
Not related to this patch, but is our vIOMMU iotlb implementation safe for data
plane (both virtio-blk and virtio-scsi)? There we don't have BQL to synchronize
between IOVA lookup and update, which means threads can race when accessing the
iotlb GHashTable.
Did I overlook a synchronization mechanism? Or is it missing? Paolo, MST?
Fam
> qemu_iovec_init(&req->resp_iov, 1);
> memset((uint8_t *)req + zero_skip, 0, sizeof(*req) - zero_skip);
> }
> --
> 2.7.4
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-scsi: finalize IOMMU support
2017-07-05 6:23 ` Fam Zheng
@ 2017-07-05 6:27 ` Paolo Bonzini
0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2017-07-05 6:27 UTC (permalink / raw)
To: Fam Zheng, mst, Jason Wang; +Cc: qemu-devel, qemu-stable
On 05/07/2017 08:23, Fam Zheng wrote:
>> req->vq = vq;
>> req->dev = s;
>> - qemu_sglist_init(&req->qsgl, DEVICE(s), 8, &address_space_memory);
>> + qemu_sglist_init(&req->qsgl, DEVICE(s), 8, vdev->dma_as);
> Not related to this patch, but is our vIOMMU iotlb implementation safe for data
> plane (both virtio-blk and virtio-scsi)? There we don't have BQL to synchronize
> between IOVA lookup and update, which means threads can race when accessing the
> iotlb GHashTable.
>
> Did I overlook a synchronization mechanism? Or is it missing? Paolo, MST?
I think it's missing. One way to fix it could be to finish the
MemoryRegionCache work and have an IOMMU->virtio notifier, similar to
how vhost works.
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-07-05 6:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-04 12:21 [Qemu-devel] [PATCH] virtio-scsi: finalize IOMMU support Jason Wang
2017-07-04 23:49 ` Fam Zheng
2017-07-05 2:49 ` Wei Xu
2017-07-05 6:23 ` Fam Zheng
2017-07-05 6:27 ` Paolo Bonzini
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.