Skip to contentSkip to conversation

virtio-serial: fix ANY_LAYOUT

PATCH In review Michael S. Tsirkin 3 participants 4 messages Jul 27, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-serial: fix ANY_LAYOUT

Don't assume a specific layout for control messages. Required by virtio 1.

---
 hw/char/virtio-serial-bus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/char/virtio-serial-bus.c +2 -1
index 78c73e5..16de50f 100644
@@ -195,7 +195,8 @@ static size_t send_control_msg(VirtIOSerial *vser, void *buf, size_t len)
         return 0;
     }
 
-    memcpy(elem.in_sg[0].iov_base, buf, len);
+    /* TODO: detect a buffer that's too short, set NEEDS_RESET */
+    iov_from_buf(&elem.in_sg, buf, len);
 
     virtqueue_push(vq, &elem, len);
     virtio_notify(VIRTIO_DEVICE(vser), vq);
Signature · 1 line
MST
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Michael S. Tsirkin

Don't assume a specific layout for control messages. Required by virtio 1.

Quoted 9 lines
---
 hw/char/virtio-serial-bus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/char/virtio-serial-bus.c +0 -0
index 78c73e5..16de50f 100644

hw/char/virtio-serial-bus.c static size_t send_control_msg(VirtIOSerial *vser, void *buf, size_t len) · line 199

Quoted 6 lines
hw/char/virtio-serial-bus.c +2 -1
@@ -195,7 +195,8 @@ static size_t send_control_msg(VirtIOSerial *vser, void *buf, size_t len)
         return 0;
     }
 
-    memcpy(elem.in_sg[0].iov_base, buf, len);
+    /* TODO: detect a buffer that's too short, set NEEDS_RESET */
+    iov_from_buf(&elem.in_sg, buf, len);

Not sure why NEEDS_RESET -- anyhow, you planning on doing this?

Amit

#2 lore raw
Quoted 20 lines · Amit Shah
Quoted 4 lines · Michael S. Tsirkin

Don't assume a specific layout for control messages. Required by virtio 1.

Quoted 12 lines
---
 hw/char/virtio-serial-bus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/char/virtio-serial-bus.c +0 -0
index 78c73e5..16de50f 100644
@@ -195,7 +195,8 @@ static size_t send_control_msg(VirtIOSerial *vser, void *buf, size_t len)
         return 0;
     }
 
Quoted 8 lines

hw/char/virtio-serial-bus.c static size_t send_control_msg(VirtIOSerial *vser, void *buf, size_t len) · line 199

Quoted 3 lines
hw/char/virtio-serial-bus.c +2 -1
-    memcpy(elem.in_sg[0].iov_base, buf, len);
+    /* TODO: detect a buffer that's too short, set NEEDS_RESET */
+    iov_from_buf(&elem.in_sg, buf, len);

Not sure why NEEDS_RESET -- anyhow, you planning on doing this?

Amit

Definitely not for 2.4.
It's a guest bug, we need a consistent strategy for handling these.

Signature · 1 line
MST
Reviewed-by on v1 1/1
#3 lore raw
In reply to Michael S. Tsirkin
Quoted 13 lines · Michael S. Tsirkin

Don't assume a specific layout for control messages. Required by virtio 1.

---
 hw/char/virtio-serial-bus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/char/virtio-serial-bus.c +0 -0
index 78c73e5..16de50f 100644

hw/char/virtio-serial-bus.c static size_t send_control_msg(VirtIOSerial *vser, void *buf, size_t len) · line 202

Quoted 9 lines
hw/char/virtio-serial-bus.c +2 -1
@@ -195,7 +195,8 @@ static size_t send_control_msg(VirtIOSerial *vser, void *buf, size_t len)
         return 0;
     }
 
-    memcpy(elem.in_sg[0].iov_base, buf, len);
+    /* TODO: detect a buffer that's too short, set NEEDS_RESET */
+    iov_from_buf(&elem.in_sg, buf, len);
 
     virtqueue_push(vq, &elem, len);
     virtio_notify(VIRTIO_DEVICE(vser), vq);