diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2015-04-17 17:13:24 +0200 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2015-04-20 09:27:01 +0100 |
commit | e05ca8200216149008fa1b1d1d847bf16691f6b4 (patch) | |
tree | 79602910de540af5f26d62f42d18768e2ed064b6 | |
parent | 638b8366200130cc7cf7a026630bc6bfb63b0c4c (diff) | |
download | qemu-e05ca8200216149008fa1b1d1d847bf16691f6b4.zip qemu-e05ca8200216149008fa1b1d1d847bf16691f6b4.tar.gz qemu-e05ca8200216149008fa1b1d1d847bf16691f6b4.tar.bz2 |
vhost: fix log base address
VHOST_SET_LOG_BASE got an incorrect address, causing
migration errors and potentially even memory corruption.
Reported-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Amos Kong <akong@redhat.com>
Message-id: 1429283565-32265-1-git-send-email-mst@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r-- | hw/virtio/vhost.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 5a12861..54851b7 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -288,7 +288,7 @@ static inline void vhost_dev_log_resize(struct vhost_dev* dev, uint64_t size) int r; log = g_malloc0(size * sizeof *log); - log_base = (uint64_t)(unsigned long)log; + log_base = (uintptr_t)log; r = dev->vhost_ops->vhost_call(dev, VHOST_SET_LOG_BASE, &log_base); assert(r >= 0); /* Sync only the range covered by the old log */ @@ -1057,10 +1057,13 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) } if (hdev->log_enabled) { + uint64_t log_base; + hdev->log_size = vhost_get_log_size(hdev); hdev->log = hdev->log_size ? g_malloc0(hdev->log_size * sizeof *hdev->log) : NULL; - r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_LOG_BASE, hdev->log); + log_base = (uintptr_t)hdev->log; + r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_LOG_BASE, &log_base); if (r < 0) { r = -errno; goto fail_log; |