render / rpms / qemu

Forked from rpms/qemu 10 months ago
Clone

Blame 0042-vhost-fix-used-logging-size-math.patch

Justin M. Forbes eff942
From 91c827f000a94908b043b5de68eb0cd4fb6ff83d Mon Sep 17 00:00:00 2001
Justin M. Forbes eff942
From: Michael S. Tsirkin <mst@redhat.com>
Justin M. Forbes eff942
Date: Wed, 24 Feb 2010 21:09:58 +0200
Justin M. Forbes eff942
Subject: [PATCH] vhost: fix used logging size math
Justin M. Forbes eff942
Justin M. Forbes eff942
Must include used header as well, not only ring
Justin M. Forbes eff942
Justin M. Forbes eff942
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Justin M. Forbes eff942
---
Justin M. Forbes eff942
 hw/vhost.c |    4 +++-
Justin M. Forbes eff942
 1 files changed, 3 insertions(+), 1 deletions(-)
Justin M. Forbes eff942
Justin M. Forbes eff942
diff --git a/hw/vhost.c b/hw/vhost.c
Justin M. Forbes eff942
index 48034ba..7391bd1 100644
Justin M. Forbes eff942
--- a/hw/vhost.c
Justin M. Forbes eff942
+++ b/hw/vhost.c
Justin M. Forbes eff942
@@ -62,7 +62,8 @@ static int vhost_client_sync_dirty_bitmap(struct CPUPhysMemoryClient *client,
Justin M. Forbes eff942
 	}
Justin M. Forbes eff942
 	for (i = 0; i < dev->nvqs; ++i) {
Justin M. Forbes eff942
 		struct vhost_virtqueue *vq = dev->vqs + i;
Justin M. Forbes eff942
-		unsigned size = sizeof(struct vring_used_elem) * vq->num;
Justin M. Forbes eff942
+		unsigned size = offsetof(struct vring_used, ring) +
Justin M. Forbes eff942
+			sizeof(struct vring_used_elem) * vq->num;
Justin M. Forbes eff942
 		vhost_dev_sync_region(dev, start_addr, end_addr, vq->used_phys,
Justin M. Forbes eff942
 				      range_get_last(vq->used_phys, size));
Justin M. Forbes eff942
 	}
Justin M. Forbes eff942
@@ -230,6 +231,7 @@ static uint64_t vhost_get_log_size(struct vhost_dev *dev)
Justin M. Forbes eff942
 	for (i = 0; i < dev->nvqs; ++i) {
Justin M. Forbes eff942
 		struct vhost_virtqueue *vq = dev->vqs + i;
Justin M. Forbes eff942
 		uint64_t last = vq->used_phys +
Justin M. Forbes eff942
+			offsetof(struct vring_used, ring) +
Justin M. Forbes eff942
 			sizeof(struct vring_used_elem) * vq->num - 1;
Justin M. Forbes eff942
 		log_size = MAX(log_size, last / VHOST_LOG_CHUNK + 1);
Justin M. Forbes eff942
 	}
Justin M. Forbes eff942
-- 
Justin M. Forbes eff942
1.6.6.1
Justin M. Forbes eff942