[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/15] vhost: Don't special case vq->used_phys in vhost_get_log_si
From: |
Michael S. Tsirkin |
Subject: |
[PULL 08/15] vhost: Don't special case vq->used_phys in vhost_get_log_size() |
Date: |
Fri, 30 Oct 2020 10:12:06 -0400 |
From: Greg Kurz <groug@kaod.org>
The first loop in vhost_get_log_size() computes the size of the dirty log
bitmap so that it allows to track changes in the entire guest memory, in
terms of GPA.
When not using a vIOMMU, the address of the vring's used structure,
vq->used_phys, is a GPA. It is thus already covered by the first loop.
When using a vIOMMU, vq->used_phys is a GIOVA that will be translated
to an HVA when the vhost backend needs to update the used structure. It
will log the corresponding GPAs into the bitmap but it certainly won't
log the GIOVA.
So in any case, vq->used_phys shouldn't be explicitly used to size the
bitmap. Drop the second loop.
This fixes a crash of the source when migrating a guest using in-kernel
vhost-net and iommu_platform=on on POWER, because DMA regions are put
over 0x800000000000000ULL. The resulting insanely huge log size causes
g_malloc0() to abort.
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1879349
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <160208823418.29027.15172801181796272300.stgit@bahia.lan>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/vhost.c | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 3077fa6ef5..79b2be20df 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -172,16 +172,6 @@ static uint64_t vhost_get_log_size(struct vhost_dev *dev)
reg->memory_size);
log_size = MAX(log_size, last / VHOST_LOG_CHUNK + 1);
}
- for (i = 0; i < dev->nvqs; ++i) {
- struct vhost_virtqueue *vq = dev->vqs + i;
-
- if (!vq->used_phys && !vq->used_size) {
- continue;
- }
-
- uint64_t last = vq->used_phys + vq->used_size - 1;
- log_size = MAX(log_size, last / VHOST_LOG_CHUNK + 1);
- }
return log_size;
}
--
MST
- [PULL 14/15] virtio: skip guest index check on device load, (continued)
- [PULL 14/15] virtio: skip guest index check on device load, Michael S. Tsirkin, 2020/10/30
- [PULL 15/15] intel_iommu: Fix two misuse of "0x%u" prints, Michael S. Tsirkin, 2020/10/30
- [PULL 01/15] vhost-vdpa: negotiate VIRTIO_NET_F_STATUS with driver, Michael S. Tsirkin, 2020/10/30
- Re: [PULL 00/15] pc,pci,vhost,virtio: misc fixes, no-reply, 2020/10/30
- [PULL 00/15] pc,pci,vhost,virtio: misc fixes, Michael S. Tsirkin, 2020/10/30
- [PULL 01/15] vhost-vdpa: negotiate VIRTIO_NET_F_STATUS with driver, Michael S. Tsirkin, 2020/10/30
- [PULL 02/15] vhost-vsock: set vhostfd to non-blocking mode, Michael S. Tsirkin, 2020/10/30
- [PULL 03/15] acpi/crs: Prevent bad ranges for host bridges, Michael S. Tsirkin, 2020/10/30
- [PULL 06/15] hw/pci: Extract pci_bus_change_irq_level() from pci_change_irq_level(), Michael S. Tsirkin, 2020/10/30
- [PULL 04/15] acpi/crs: Support ranges > 32b for hosts, Michael S. Tsirkin, 2020/10/30
- [PULL 08/15] vhost: Don't special case vq->used_phys in vhost_get_log_size(),
Michael S. Tsirkin <=
- [PULL 09/15] pc: Implement -no-hpet as sugar for -machine hpet=on, Michael S. Tsirkin, 2020/10/30
- [PULL 13/15] vhost-blk: set features before setting inflight feature, Michael S. Tsirkin, 2020/10/30
- [PULL 07/15] pci: Assert irqnum is between 0 and bus->nirqs in pci_bus_change_irq_level, Michael S. Tsirkin, 2020/10/30
- [PULL 05/15] hw/virtio/vhost-vdpa: Fix Coverity CID 1432864, Michael S. Tsirkin, 2020/10/30
- [PULL 10/15] pci: advertise a page aligned ATS, Michael S. Tsirkin, 2020/10/30
- [PULL 12/15] pci: Disallow improper BAR registration for type 1, Michael S. Tsirkin, 2020/10/30
- [PULL 14/15] virtio: skip guest index check on device load, Michael S. Tsirkin, 2020/10/30
- [PULL 11/15] pci: Change error_report to assert(3), Michael S. Tsirkin, 2020/10/30
- [PULL 15/15] intel_iommu: Fix two misuse of "0x%u" prints, Michael S. Tsirkin, 2020/10/30
- Re: [PULL 00/15] pc,pci,vhost,virtio: misc fixes, no-reply, 2020/10/30