From: Steve Sistare <steven.sistare@oracle.com>
To: qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
Philippe Mathieu-Daude <philmd@linaro.org>,
Eugenio Perez Martin <eperezma@redhat.com>,
Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>,
Si-Wei Liu <si-wei.liu@oracle.com>,
Steve Sistare <steven.sistare@oracle.com>
Subject: [RFC V1 6/7] vdpa/cpr: pass shadow parameter to dma functions
Date: Fri, 12 Jul 2024 07:02:10 -0700 [thread overview]
Message-ID: <1720792931-456433-7-git-send-email-steven.sistare@oracle.com> (raw)
In-Reply-To: <1720792931-456433-1-git-send-email-steven.sistare@oracle.com>
Pass a parameter to the dma mapping functions that indicates if the
memory backs rings or buffers for svq's. No functional change.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
hw/virtio/vhost-vdpa.c | 19 ++++++++++---------
include/hw/virtio/vhost-vdpa.h | 4 ++--
net/vhost-vdpa.c | 5 +++--
3 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 9e3f414ac2..d9ebc396b7 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -92,7 +92,7 @@ static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *section,
* This is not an ABI break since it is set to 0 by the initializer anyway.
*/
int vhost_vdpa_dma_map(VhostVDPAShared *s, uint32_t asid, hwaddr iova,
- hwaddr size, void *vaddr, bool readonly)
+ hwaddr size, void *vaddr, bool readonly, bool shadow)
{
struct vhost_msg_v2 msg = {};
int fd = s->device_fd;
@@ -124,7 +124,7 @@ int vhost_vdpa_dma_map(VhostVDPAShared *s, uint32_t asid, hwaddr iova,
* This is not an ABI break since it is set to 0 by the initializer anyway.
*/
int vhost_vdpa_dma_unmap(VhostVDPAShared *s, uint32_t asid, hwaddr iova,
- hwaddr size)
+ hwaddr size, bool shadow)
{
struct vhost_msg_v2 msg = {};
int fd = s->device_fd;
@@ -234,7 +234,7 @@ static void vhost_vdpa_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
return;
}
ret = vhost_vdpa_dma_map(s, VHOST_VDPA_GUEST_PA_ASID, iova,
- iotlb->addr_mask + 1, vaddr, read_only);
+ iotlb->addr_mask + 1, vaddr, read_only, false);
if (ret) {
error_report("vhost_vdpa_dma_map(%p, 0x%" HWADDR_PRIx ", "
"0x%" HWADDR_PRIx ", %p) = %d (%m)",
@@ -242,7 +242,7 @@ static void vhost_vdpa_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
}
} else {
ret = vhost_vdpa_dma_unmap(s, VHOST_VDPA_GUEST_PA_ASID, iova,
- iotlb->addr_mask + 1);
+ iotlb->addr_mask + 1, false);
if (ret) {
error_report("vhost_vdpa_dma_unmap(%p, 0x%" HWADDR_PRIx ", "
"0x%" HWADDR_PRIx ") = %d (%m)",
@@ -376,7 +376,8 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener,
vhost_vdpa_iotlb_batch_begin_once(s);
ret = vhost_vdpa_dma_map(s, VHOST_VDPA_GUEST_PA_ASID, iova,
- int128_get64(llsize), vaddr, section->readonly);
+ int128_get64(llsize), vaddr, section->readonly,
+ false);
if (ret) {
error_report("vhost vdpa map fail!");
goto fail_map;
@@ -463,7 +464,7 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
if (int128_eq(llsize, int128_2_64())) {
llsize = int128_rshift(llsize, 1);
ret = vhost_vdpa_dma_unmap(s, VHOST_VDPA_GUEST_PA_ASID, iova,
- int128_get64(llsize));
+ int128_get64(llsize), false);
if (ret) {
error_report("vhost_vdpa_dma_unmap(%p, 0x%" HWADDR_PRIx ", "
@@ -473,7 +474,7 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
iova += int128_get64(llsize);
}
ret = vhost_vdpa_dma_unmap(s, VHOST_VDPA_GUEST_PA_ASID, iova,
- int128_get64(llsize));
+ int128_get64(llsize), false);
if (ret) {
error_report("vhost_vdpa_dma_unmap(%p, 0x%" HWADDR_PRIx ", "
@@ -1116,7 +1117,7 @@ static void vhost_vdpa_svq_unmap_ring(struct vhost_vdpa *v, hwaddr addr)
size = ROUND_UP(result->size, qemu_real_host_page_size());
r = vhost_vdpa_dma_unmap(v->shared, v->address_space_id, result->iova,
- size);
+ size, true);
if (unlikely(r < 0)) {
error_report("Unable to unmap SVQ vring: %s (%d)", g_strerror(-r), -r);
return;
@@ -1159,7 +1160,7 @@ static bool vhost_vdpa_svq_map_ring(struct vhost_vdpa *v, DMAMap *needle,
r = vhost_vdpa_dma_map(v->shared, v->address_space_id, needle->iova,
needle->size + 1,
(void *)(uintptr_t)needle->translated_addr,
- needle->perm == IOMMU_RO);
+ needle->perm == IOMMU_RO, true);
if (unlikely(r != 0)) {
error_setg_errno(errp, -r, "Cannot map region to device");
vhost_iova_tree_remove(v->shared->iova_tree, *needle);
diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
index 427458cfed..aac6ad439c 100644
--- a/include/hw/virtio/vhost-vdpa.h
+++ b/include/hw/virtio/vhost-vdpa.h
@@ -82,9 +82,9 @@ int vhost_vdpa_get_iova_range(int fd, struct vhost_vdpa_iova_range *iova_range);
int vhost_vdpa_set_vring_ready(struct vhost_vdpa *v, unsigned idx);
int vhost_vdpa_dma_map(VhostVDPAShared *s, uint32_t asid, hwaddr iova,
- hwaddr size, void *vaddr, bool readonly);
+ hwaddr size, void *vaddr, bool readonly, bool shadow);
int vhost_vdpa_dma_unmap(VhostVDPAShared *s, uint32_t asid, hwaddr iova,
- hwaddr size);
+ hwaddr size, bool shadow);
typedef struct vdpa_iommu {
VhostVDPAShared *dev_shared;
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index e6010e8900..e3e861cfcc 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -499,7 +499,7 @@ static void vhost_vdpa_cvq_unmap_buf(struct vhost_vdpa *v, void *addr)
}
r = vhost_vdpa_dma_unmap(v->shared, v->address_space_id, map->iova,
- map->size + 1);
+ map->size + 1, true);
if (unlikely(r != 0)) {
error_report("Device cannot unmap: %s(%d)", g_strerror(r), r);
}
@@ -524,7 +524,8 @@ static int vhost_vdpa_cvq_map_buf(struct vhost_vdpa *v, void *buf, size_t size,
}
r = vhost_vdpa_dma_map(v->shared, v->address_space_id, map.iova,
- vhost_vdpa_net_cvq_cmd_page_len(), buf, !write);
+ vhost_vdpa_net_cvq_cmd_page_len(), buf, !write,
+ true);
if (unlikely(r < 0)) {
goto dma_map_err;
}
--
2.39.3
next prev parent reply other threads:[~2024-07-12 14:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-12 14:02 [RFC V1 0/7] Live update: vdpa Steve Sistare
2024-07-12 14:02 ` [RFC V1 1/7] migration: cpr_needed_for_reuse Steve Sistare
2024-07-12 14:02 ` [RFC V1 2/7] migration: skip dirty memory tracking for cpr Steve Sistare
2024-08-12 18:57 ` Fabiano Rosas
2024-08-14 19:54 ` Steven Sistare
2024-07-12 14:02 ` [RFC V1 3/7] vdpa/cpr: preserve device fd Steve Sistare
2024-07-12 14:02 ` [RFC V1 4/7] vdpa/cpr: kernel interfaces Steve Sistare
2024-07-12 14:02 ` [RFC V1 5/7] vdpa/cpr: use VHOST_NEW_OWNER Steve Sistare
2024-07-12 14:02 ` Steve Sistare [this message]
2024-07-12 14:02 ` [RFC V1 7/7] vdpa/cpr: preserve dma mappings Steve Sistare
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=1720792931-456433-7-git-send-email-steven.sistare@oracle.com \
--to=steven.sistare@oracle.com \
--cc=eperezma@redhat.com \
--cc=farosas@suse.de \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=si-wei.liu@oracle.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;
as well as URLs for NNTP newsgroup(s).