qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] fixup! virtio: introduce virtio_map
@ 2015-10-27 12:30 Michael S. Tsirkin
  2015-10-27 12:51 ` Cornelia Huck
  0 siblings, 1 reply; 4+ messages in thread
From: Michael S. Tsirkin @ 2015-10-27 12:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cornelia Huck, Igor Mammedov

---

This will fix the issue reported by Cornelia.

 hw/virtio/virtio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index be32145..ed1f274 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -449,7 +449,7 @@ int virtqueue_avail_bytes(VirtQueue *vq, unsigned int in_bytes,
 }
 
 static void virtqueue_map_iovec(struct iovec *sg, hwaddr *addr,
-                                size_t *num_sg, size_t max_size,
+                                unsigned int *num_sg, unsigned int max_size,
                                 int is_write)
 {
     unsigned int i;
-- 
MST

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] fixup! virtio: introduce virtio_map
  2015-10-27 12:30 Michael S. Tsirkin
@ 2015-10-27 12:51 ` Cornelia Huck
  0 siblings, 0 replies; 4+ messages in thread
From: Cornelia Huck @ 2015-10-27 12:51 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Igor Mammedov, qemu-devel

On Tue, 27 Oct 2015 14:30:05 +0200
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> ---
> 
> This will fix the issue reported by Cornelia.
> 
>  hw/virtio/virtio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index be32145..ed1f274 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -449,7 +449,7 @@ int virtqueue_avail_bytes(VirtQueue *vq, unsigned int in_bytes,
>  }
> 
>  static void virtqueue_map_iovec(struct iovec *sg, hwaddr *addr,
> -                                size_t *num_sg, size_t max_size,
> +                                unsigned int *num_sg, unsigned int max_size,
>                                  int is_write)
>  {
>      unsigned int i;

With this fixup applied, both s390 machines come up. virtio-serial and
virtio-blk with and without dataplane seem fine.

At a first glance, the code seems fine as well.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH] fixup! virtio: introduce virtio_map
@ 2015-10-27 21:00 Michael S. Tsirkin
  2015-10-28 11:40 ` Stefan Hajnoczi
  0 siblings, 1 reply; 4+ messages in thread
From: Michael S. Tsirkin @ 2015-10-27 21:00 UTC (permalink / raw)
  To: qemu-devel; +Cc: Igor Mammedov

Stefan noticed that we must use memmove, not memcpy,
as arguments overlap.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/virtio/virtio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index ed1f274..939f802 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -481,8 +481,8 @@ static void virtqueue_map_iovec(struct iovec *sg, hwaddr *addr,
             error_report("virtio: memory split makes iovec too large");
             exit(1);
         }
-        memcpy(sg + i + 1, sg + i, sizeof(*sg) * (*num_sg - i));
-        memcpy(addr + i + 1, addr + i, sizeof(*addr) * (*num_sg - i));
+        memmove(sg + i + 1, sg + i, sizeof(*sg) * (*num_sg - i));
+        memmove(addr + i + 1, addr + i, sizeof(*addr) * (*num_sg - i));
         assert(len < sg[i + 1].iov_len);
         sg[i].iov_len = len;
         addr[i + 1] += len;
-- 
MST

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] fixup! virtio: introduce virtio_map
  2015-10-27 21:00 [Qemu-devel] [PATCH] fixup! virtio: introduce virtio_map Michael S. Tsirkin
@ 2015-10-28 11:40 ` Stefan Hajnoczi
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2015-10-28 11:40 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Igor Mammedov, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 353 bytes --]

On Tue, Oct 27, 2015 at 11:00:36PM +0200, Michael S. Tsirkin wrote:
> Stefan noticed that we must use memmove, not memcpy,
> as arguments overlap.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  hw/virtio/virtio.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-28 11:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-27 21:00 [Qemu-devel] [PATCH] fixup! virtio: introduce virtio_map Michael S. Tsirkin
2015-10-28 11:40 ` Stefan Hajnoczi
  -- strict thread matches above, loose matches on Subject: below --
2015-10-27 12:30 Michael S. Tsirkin
2015-10-27 12:51 ` Cornelia Huck

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).