From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: qemu-devel@nongnu.org
Cc: xen-devel@lists.xensource.com, mst@redhat.com,
jasowang@redhat.com,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
pbonzini@redhat.com
Subject: [Qemu-devel] [PATCH 4/4] virtio-net: do not leak cpu mappings
Date: Tue, 25 Nov 2014 14:43:23 +0000 [thread overview]
Message-ID: <1416926603-12397-4-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1411251436080.2675@kaball.uk.xensource.com>
In virtio_net_handle_ctrl unmap the previously mapped out_sg, not a
subset of it.
This patch fixes an abort() when running on Xen.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
CC: jasowang@redhat.com
CC: wency@cn.fujitsu.com
CC: mst@redhat.com
CC: pbonzini@redhat.com
---
hw/net/virtio-net.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 5035313..c9b82f3 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -773,6 +773,7 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
VirtQueueElement elem;
size_t s;
struct iovec *iov;
+ struct iovec iov_copy[VIRTQUEUE_MAX_SIZE];
unsigned int iov_cnt;
while (virtqueue_pop(vq, &elem)) {
@@ -782,6 +783,7 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
exit(1);
}
+ memcpy(iov_copy, elem.out_sg, elem.out_num*sizeof(struct iovec));
iov = elem.out_sg;
iov_cnt = elem.out_num;
s = iov_to_buf(iov, iov_cnt, 0, &ctrl, sizeof(ctrl));
@@ -804,7 +806,7 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
assert(s == sizeof(status));
virtqueue_unmap_sg(elem.in_sg, elem.in_num, 1, sizeof(status));
- virtqueue_unmap_sg(elem.out_sg, elem.out_num, 0, UINT_MAX);
+ virtqueue_unmap_sg(iov_copy, elem.out_num, 0, UINT_MAX);
virtqueue_fill(vq, &elem, sizeof(status), 0);
virtqueue_flush(vq, 1);
virtio_notify(vdev, vq);
--
1.7.10.4
next prev parent reply other threads:[~2014-11-25 14:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-25 14:42 [Qemu-devel] [PATCH 0/4] virtio-net: do not leak cpu mappings Stefano Stabellini
2014-11-25 14:43 ` [Qemu-devel] [PATCH 1/4] introduce virtqueue_unmap_sg Stefano Stabellini
2014-11-25 15:05 ` Peter Maydell
2014-11-25 15:28 ` Stefano Stabellini
2014-11-25 14:43 ` [Qemu-devel] [PATCH 2/4] use virtqueue_unmap_sg in virtqueue_fill Stefano Stabellini
2014-11-25 14:43 ` [Qemu-devel] [PATCH 3/4] move virtqueue_unmap_sg calls from virtqueue_fill to virtqueue_push Stefano Stabellini
2014-11-25 14:43 ` Stefano Stabellini [this message]
2014-11-25 15:28 ` [Qemu-devel] [Xen-devel] [PATCH 0/4] virtio-net: do not leak cpu mappings Fabio Fantoni
2014-11-25 17:09 ` Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1416926603-12397-4-git-send-email-stefano.stabellini@eu.citrix.com \
--to=stefano.stabellini@eu.citrix.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).