[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 15/24] vdpa: Export vhost_vdpa_dma_map and unmap calls
From: |
Jason Wang |
Subject: |
[PULL 15/24] vdpa: Export vhost_vdpa_dma_map and unmap calls |
Date: |
Tue, 19 Jul 2022 21:16:28 +0800 |
From: Eugenio Pérez <eperezma@redhat.com>
Shadow CVQ will copy buffers on qemu VA, so we avoid TOCTOU attacks from
the guest that could set a different state in qemu device model and vdpa
device.
To do so, it needs to be able to map these new buffers to the device.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/virtio/vhost-vdpa.c | 7 +++----
include/hw/virtio/vhost-vdpa.h | 4 ++++
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 0b13e98..9699721 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -71,8 +71,8 @@ static bool
vhost_vdpa_listener_skipped_section(MemoryRegionSection *section,
return false;
}
-static int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
- void *vaddr, bool readonly)
+int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
+ void *vaddr, bool readonly)
{
struct vhost_msg_v2 msg = {};
int fd = v->device_fd;
@@ -97,8 +97,7 @@ static int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr
iova, hwaddr size,
return ret;
}
-static int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, hwaddr iova,
- hwaddr size)
+int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, hwaddr iova, hwaddr size)
{
struct vhost_msg_v2 msg = {};
int fd = v->device_fd;
diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
index a29dbb3..7214eb4 100644
--- a/include/hw/virtio/vhost-vdpa.h
+++ b/include/hw/virtio/vhost-vdpa.h
@@ -39,4 +39,8 @@ typedef struct vhost_vdpa {
VhostVDPAHostNotifier notifier[VIRTIO_QUEUE_MAX];
} VhostVDPA;
+int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
+ void *vaddr, bool readonly);
+int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, hwaddr iova, hwaddr size);
+
#endif
--
2.7.4
- [PULL 04/24] vdpa: Avoid compiler to squash reads to used idx, (continued)
- [PULL 04/24] vdpa: Avoid compiler to squash reads to used idx, Jason Wang, 2022/07/19
- [PULL 05/24] vhost: Reorder vhost_svq_kick, Jason Wang, 2022/07/19
- [PULL 06/24] vhost: Move vhost_svq_kick call to vhost_svq_add, Jason Wang, 2022/07/19
- [PULL 07/24] vhost: Check for queue full at vhost_svq_add, Jason Wang, 2022/07/19
- [PULL 08/24] vhost: Decouple vhost_svq_add from VirtQueueElement, Jason Wang, 2022/07/19
- [PULL 09/24] vhost: Add SVQDescState, Jason Wang, 2022/07/19
- [PULL 10/24] vhost: Track number of descs in SVQDescState, Jason Wang, 2022/07/19
- [PULL 12/24] vhost: Expose vhost_svq_add, Jason Wang, 2022/07/19
- [PULL 13/24] vhost: add vhost_svq_poll, Jason Wang, 2022/07/19
- [PULL 11/24] vhost: add vhost_svq_push_elem, Jason Wang, 2022/07/19
- [PULL 15/24] vdpa: Export vhost_vdpa_dma_map and unmap calls,
Jason Wang <=
- [PULL 14/24] vhost: Add svq avail_handler callback, Jason Wang, 2022/07/19
- [PULL 16/24] vdpa: manual forward CVQ buffers, Jason Wang, 2022/07/19
- [PULL 17/24] vdpa: Buffer CVQ support on shadow virtqueue, Jason Wang, 2022/07/19
- [PULL 19/24] vdpa: Add device migration blocker, Jason Wang, 2022/07/19
- [PULL 18/24] vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs, Jason Wang, 2022/07/19
- [PULL 20/24] vdpa: Add x-svq to NetdevVhostVDPAOptions, Jason Wang, 2022/07/19
- [PULL 22/24] net/colo: Fix a "double free" crash to clear the conn_list, Jason Wang, 2022/07/19
- [PULL 24/24] net/colo.c: fix segmentation fault when packet is not parsed correctly, Jason Wang, 2022/07/19
- [PULL 21/24] softmmu/runstate.c: add RunStateTransition support form COLO to PRELAUNCH, Jason Wang, 2022/07/19
- [PULL 23/24] net/colo.c: No need to track conn_list for filter-rewriter, Jason Wang, 2022/07/19