[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 27/40] ivshmem: Rely on server sending the ID righ
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PULL v2 27/40] ivshmem: Rely on server sending the ID right after the version |
Date: |
Mon, 21 Mar 2016 21:43:50 +0100 |
The protocol specification (ivshmem-spec.txt, formerly
ivshmem_device_spec.txt) has always required the ID message to be sent
right at the beginning, and ivshmem-server has always complied. The
device, however, accepts it out of order. If an interrupt setup
arrived before it, though, it would be misinterpreted as connect
notification. Fix the latent bug by relying on the spec and
ivshmem-server's actual behavior.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Message-Id: <address@hidden>
---
hw/misc/ivshmem.c | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 7f439c3..da32a74 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -653,8 +653,6 @@ static void process_msg(IVShmemState *s, int64_t msg, int
fd, Error **errp)
if (fd >= 0) {
process_msg_connect(s, msg, fd, errp);
- } else if (s->vm_id == -1) {
- s->vm_id = msg;
} else {
process_msg_disconnect(s, msg, errp);
}
@@ -722,6 +720,30 @@ static void ivshmem_recv_setup(IVShmemState *s, Error
**errp)
}
/*
+ * ivshmem-server sends the remaining initial messages in a fixed
+ * order, but the device has always accepted them in any order.
+ * Stay as compatible as practical, just in case people use
+ * servers that behave differently.
+ */
+
+ /*
+ * ivshmem_device_spec.txt has always required the ID message
+ * right here, and ivshmem-server has always complied. However,
+ * older versions of the device accepted it out of order, but
+ * broke when an interrupt setup message arrived before it.
+ */
+ msg = ivshmem_recv_msg(s, &fd, &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
+ }
+ if (fd != -1 || msg < 0 || msg > IVSHMEM_MAX_PEERS) {
+ error_setg(errp, "server sent invalid ID message");
+ return;
+ }
+ s->vm_id = msg;
+
+ /*
* Receive more messages until we got shared memory.
*/
do {
@@ -956,7 +978,6 @@ static void pci_ivshmem_realize(PCIDevice *dev, Error
**errp)
/* we allocate enough space for 16 peers and grow as needed */
resize_peers(s, 16);
- s->vm_id = -1;
pci_register_bar(dev, 2, attr, &s->bar);
--
2.4.3
- [Qemu-devel] [PULL v2 22/40] ivshmem: Simplify rejection of invalid peer ID from server, (continued)
- [Qemu-devel] [PULL v2 22/40] ivshmem: Simplify rejection of invalid peer ID from server, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 16/40] ivshmem: Fix harmless misuse of Error, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 34/40] qdev: New DEFINE_PROP_ON_OFF_AUTO, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 38/40] ivshmem: Drop ivshmem property x-memdev, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 06/40] tests/libqos/pci-pc: Fix qpci_pc_iomap() to map BARs aligned, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 11/40] ivshmem: Add missing newlines to debug printfs, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 14/40] ivshmem: Drop ivshmem_event() stub, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 15/40] ivshmem: Don't destroy the chardev on version mismatch, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 24/40] ivshmem: Plug leaks on unplug, fix peer disconnect, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 20/40] ivshmem: Leave INTx alone when using MSI-X, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 27/40] ivshmem: Rely on server sending the ID right after the version,
Markus Armbruster <=
- [Qemu-devel] [PULL v2 29/40] ivshmem: Simplify how we cope with short reads from server, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 31/40] ivshmem: Implement shm=... with a memory backend, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 35/40] ivshmem: Replace int role_val by OnOffAuto master, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 01/40] target-ppc: Document TOCTTOU in hugepage support, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 25/40] ivshmem: Receive shared memory synchronously in realize(), Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 10/40] ivshmem: Rewrite specification document, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 39/40] ivshmem: Require master to have ID zero, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 03/40] ivshmem-server: Don't overload POSIX shmem and file name, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 19/40] ivshmem: Clean up MSI-X conditions, Markus Armbruster, 2016/03/21
- [Qemu-devel] [PULL v2 32/40] ivshmem: Simplify memory regions for BAR 2 (shared memory), Markus Armbruster, 2016/03/21