From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yk4sN-0004cX-CV for qemu-devel@nongnu.org; Mon, 20 Apr 2015 02:08:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yk4sK-0001BJ-6o for qemu-devel@nongnu.org; Mon, 20 Apr 2015 02:08:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40973) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yk4sJ-0001BF-Uw for qemu-devel@nongnu.org; Mon, 20 Apr 2015 02:08:08 -0400 Date: Mon, 20 Apr 2015 08:07:57 +0200 From: "Michael S. Tsirkin" Message-ID: <20150420080635-mutt-send-email-mst@redhat.com> References: <1429283565-32265-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1429283565-32265-1-git-send-email-mst@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4] vhost: fix log base address List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell On Fri, Apr 17, 2015 at 05:13:24PM +0200, Michael S. Tsirkin wrote: > VHOST_SET_LOG_BASE got an incorrect address, causing > migration errors and potentially even memory corruption. > > Reported-by: Wen Congyang > Signed-off-by: Michael S. Tsirkin > --- OK, this passed testing now. Peter, can you merge this directly for 2.3? > > changed (uint64_t)(unsigned long) to (uintptr_t). > Untested. > Wen Congyang, can you pls test and confirm. > > hw/virtio/vhost.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c > index 8dd2f59..b83675f 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 */ > @@ -1016,10 +1016,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; > -- > MST