vhost: stop reusing vq->desc (and friends) to store physical address
Remove the hack of storing physical addresses in vq->desc/avail/used pointers when IOMMU is present. Instead, handle this case directly in vhost_virtqueue_set_addr() by checking for IOMMU presence. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Based-on: <20260206095258.894504-1-vsementsov@yandex-team.ru> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260420202032.714884-8-vsementsov@yandex-team.ru>
Vladimir Sementsov-Ogievskiy committed
Apr 20, 2026 at 23:20 UTC
15bbdc0a7bc96933fbe2a913346ab03dbd4584e1
1 file changed
+1
-4
hw/virtio/vhost.c
+1
-4
@@ -518,9 +518,6 @@ static int vhost_vrings_map(struct vhost_dev *dev,
518
}
519
520
if (vhost_dev_has_iommu(dev)) {
521
- vq->desc = (void *)(uintptr_t)vq->desc_phys;
522
- vq->avail = (void *)(uintptr_t)vq->avail_phys;
523
- vq->used = (void *)(uintptr_t)vq->used_phys;
521
return 1;
522
}
523
@@ -1104,7 +1101,7 @@ static int vhost_virtqueue_set_addr(struct vhost_dev *dev,
1101
int r;
1102
memset(&addr, 0, sizeof(struct vhost_vring_addr));
1103
1107
- if (phys) {
1104
+ if (phys || vhost_dev_has_iommu(dev)) {
1105
addr.desc_user_addr = (uint64_t)(unsigned long)vq->desc_phys;
1106
addr.avail_user_addr = (uint64_t)(unsigned long)vq->avail_phys;
1107
addr.used_user_addr = (uint64_t)(unsigned long)vq->used_phys;