[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v3 26/29] vhost: Map in vdpa-dev
From: |
Eugenio Pérez |
Subject: |
[RFC v3 26/29] vhost: Map in vdpa-dev |
Date: |
Wed, 19 May 2021 18:29:00 +0200 |
Use and export vhost-vpda functions directly. In the final version,
these methods needs to be exposed through VhostOps, or vhost-vdpa
backend needs to be adapted to work with vhost_send_device_iotlb_msg
in case its custom iommu is disabled.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
include/hw/virtio/vhost-backend.h | 4 ++++
hw/virtio/vhost-vdpa.c | 2 +-
hw/virtio/vhost.c | 18 ++++++++++++++++++
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/include/hw/virtio/vhost-backend.h
b/include/hw/virtio/vhost-backend.h
index f8eed2ace5..9d88074e4d 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -203,4 +203,8 @@ int vhost_backend_handle_iotlb_msg(struct vhost_dev *dev,
int vhost_user_gpu_set_socket(struct vhost_dev *dev, int fd);
+struct vhost_vdpa;
+int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
+ void *vaddr, bool readonly);
+
#endif /* VHOST_BACKEND_H */
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 9e7a0ce5e0..c742e6944e 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -36,7 +36,7 @@ static bool
vhost_vdpa_listener_skipped_section(MemoryRegionSection *section)
section->offset_within_address_space & (1ULL << 63);
}
-static int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
+int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
void *vaddr, bool readonly)
{
struct vhost_msg_v2 msg = {};
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 4339b899ea..286863ad42 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1314,9 +1314,19 @@ static bool vhost_shadow_vq_start_store_sections(struct
vhost_dev *dev)
r = vhost_iova_tree_insert(&dev->iova_map, ®ion);
}
assert(r == VHOST_DMA_MAP_OK);
+ r = vhost_vdpa_dma_map(dev->opaque, region.iova, region_size,
+ (void *)dev->mem->regions[idx].userspace_addr,
+ false);
+ if (r != 0) {
+ goto fail;
+ }
}
return true;
+
+fail:
+ assert(0);
+ return false;
}
/*
@@ -1377,6 +1387,14 @@ static bool vhost_sw_live_migration_start_vq(struct
vhost_dev *dev,
}
vhost_virtqueue_stop(dev, dev->vdev, &dev->vqs[idx], dev->vq_index + idx);
+ /* TODO: Why cannot make this read only? */
+ r = vhost_vdpa_dma_map(dev->opaque, addr.desc_user_addr,
driver_region.size,
+ (void *)driver_region.translated_addr, false);
+ assert(r == 0);
+ r = vhost_vdpa_dma_map(dev->opaque, addr.used_user_addr,
device_region.size,
+ (void *)device_region.translated_addr, false);
+ assert(r == 0);
+
ok = vhost_shadow_vq_start(dev, idx, dev->shadow_vqs[idx]);
if (unlikely(!ok)) {
return false;
--
2.27.0
- [RFC v3 16/29] vhost-vdpa: Add vhost_vdpa_enable_custom_iommu, (continued)
- [RFC v3 16/29] vhost-vdpa: Add vhost_vdpa_enable_custom_iommu, Eugenio Pérez, 2021/05/19
- [RFC v3 17/29] vhost: Shadow virtqueue buffers forwarding, Eugenio Pérez, 2021/05/19
- [RFC v3 18/29] vhost: Use vhost_enable_custom_iommu to unmap everything if available, Eugenio Pérez, 2021/05/19
- [RFC v3 19/29] vhost: Check for device VRING_USED_F_NO_NOTIFY at shadow virtqueue kick, Eugenio Pérez, 2021/05/19
- [RFC v3 20/29] vhost: Use VRING_AVAIL_F_NO_INTERRUPT at device call on shadow virtqueue, Eugenio Pérez, 2021/05/19
- [RFC v3 21/29] vhost: Add VhostIOVATree, Eugenio Pérez, 2021/05/19
- [RFC v3 22/29] vhost: Add iova_rev_maps_find_iova to IOVAReverseMaps, Eugenio Pérez, 2021/05/19
- [RFC v3 23/29] vhost: Use a tree to store memory mappings, Eugenio Pérez, 2021/05/19
- [RFC v3 24/29] vhost: Add iova_rev_maps_alloc, Eugenio Pérez, 2021/05/19
- [RFC v3 25/29] vhost: Add custom IOTLB translations to SVQ, Eugenio Pérez, 2021/05/19
- [RFC v3 26/29] vhost: Map in vdpa-dev,
Eugenio Pérez <=
- [RFC v3 27/29] vhost-vdpa: Implement vhost_vdpa_vring_pause operation, Eugenio Pérez, 2021/05/19
- [RFC v3 28/29] vhost-vdpa: never map with vDPA listener, Eugenio Pérez, 2021/05/19
- [RFC v3 29/29] vhost: Start vhost-vdpa SVQ directly, Eugenio Pérez, 2021/05/19
- Re: [RFC v3 00/29] vDPA software assisted live migration, Michael S. Tsirkin, 2021/05/24