[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for 8.0 v8 11/12] vdpa: add shadow_data to vhost_vdpa
From: |
Eugenio Pérez |
Subject: |
[PATCH for 8.0 v8 11/12] vdpa: add shadow_data to vhost_vdpa |
Date: |
Thu, 24 Nov 2022 16:51:57 +0100 |
The memory listener that thells the device how to convert GPA to qemu's
va is registered against CVQ vhost_vdpa. memory listener translations
are always ASID 0, CVQ ones are ASID 1 if supported.
Let's tell the listener if it needs to register them on iova tree or
not.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
---
v7: Rename listener_shadow_vq to shadow_data
v5: Solve conflict about vhost_iova_tree_remove accepting mem_region by
value.
---
include/hw/virtio/vhost-vdpa.h | 2 ++
hw/virtio/vhost-vdpa.c | 6 +++---
net/vhost-vdpa.c | 1 +
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
index e57dfa1fd1..45b969a311 100644
--- a/include/hw/virtio/vhost-vdpa.h
+++ b/include/hw/virtio/vhost-vdpa.h
@@ -40,6 +40,8 @@ typedef struct vhost_vdpa {
struct vhost_vdpa_iova_range iova_range;
uint64_t acked_features;
bool shadow_vqs_enabled;
+ /* Vdpa must send shadow addresses as IOTLB key for data queues, not GPA */
+ bool shadow_data;
/* IOVA mapping used by the Shadow Virtqueue */
VhostIOVATree *iova_tree;
GPtrArray *shadow_vqs;
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 1100cde29e..8e54c5c0fc 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -224,7 +224,7 @@ static void vhost_vdpa_listener_region_add(MemoryListener
*listener,
vaddr, section->readonly);
llsize = int128_sub(llend, int128_make64(iova));
- if (v->shadow_vqs_enabled) {
+ if (v->shadow_data) {
int r;
mem_region.translated_addr = (hwaddr)(uintptr_t)vaddr,
@@ -251,7 +251,7 @@ static void vhost_vdpa_listener_region_add(MemoryListener
*listener,
return;
fail_map:
- if (v->shadow_vqs_enabled) {
+ if (v->shadow_data) {
vhost_iova_tree_remove(v->iova_tree, mem_region);
}
@@ -296,7 +296,7 @@ static void vhost_vdpa_listener_region_del(MemoryListener
*listener,
llsize = int128_sub(llend, int128_make64(iova));
- if (v->shadow_vqs_enabled) {
+ if (v->shadow_data) {
const DMAMap *result;
const void *vaddr = memory_region_get_ram_ptr(section->mr) +
section->offset_within_region +
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 3ff149dfd9..a1f1e29b7c 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -587,6 +587,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientState
*peer,
s->vhost_vdpa.index = queue_pair_index;
s->always_svq = svq;
s->vhost_vdpa.shadow_vqs_enabled = svq;
+ s->vhost_vdpa.shadow_data = svq;
s->vhost_vdpa.iova_tree = iova_tree;
if (!is_datapath) {
s->cvq_cmd_out_buffer = qemu_memalign(qemu_real_host_page_size(),
--
2.31.1
- [PATCH for 8.0 v8 03/12] vhost: allocate SVQ device file descriptors at device start, (continued)
- [PATCH for 8.0 v8 03/12] vhost: allocate SVQ device file descriptors at device start, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 04/12] vhost: move iova_tree set to vhost_svq_start, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 05/12] vdpa: add vhost_vdpa_net_valid_svq_features, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 06/12] vdpa: extract vhost_vdpa_svq_allocate_iova_tree, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 08/12] vdpa: allocate SVQ array unconditionally, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 07/12] vdpa: move SVQ vring features check to net/, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 10/12] vdpa: store x-svq parameter in VhostVDPAState, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 09/12] vdpa: add asid parameter to vhost_vdpa_dma_map/unmap, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 11/12] vdpa: add shadow_data to vhost_vdpa,
Eugenio Pérez <=
- [PATCH for 8.0 v8 12/12] vdpa: always start CVQ in SVQ mode if possible, Eugenio Pérez, 2022/11/24