Commit 714e7634 authored by Benjamin Beichler's avatar Benjamin Beichler Committed by Richard Weinberger

um: read multiple msg from virtio slave request fd

If VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS is activated, the user mode
linux virtio irq handler only read one msg from the corresponding socket.
This creates issues, when the device emulation creates multiple call
requests (e.g. for multiple virtqueues), as the socket buffer tend to fill
up and the call requests are delayed.

This creates a deadlock situation, when the device simulation blocks,
because of sending a msg and the kernel side blocks because of
synchronously waiting for an acknowledge of kick request.

Actually inband notifications are meant to be used in combination with the
time travel protocol, but it is not required, therefore this corner case
needs to be handled.

Anyways, in general it seems to be more natural to consume always all
messages from a socket, instead of only a single one.

Fixes: 2cd097ba ("um: virtio: Implement VHOST_USER_PROTOCOL_F_SLAVE_REQ")
Signed-off-by: default avatarBenjamin Beichler <benjamin.beichler@uni-rostock.de>
Reviewed-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent 521a547c
...@@ -374,14 +374,14 @@ static irqreturn_t vu_req_read_message(struct virtio_uml_device *vu_dev, ...@@ -374,14 +374,14 @@ static irqreturn_t vu_req_read_message(struct virtio_uml_device *vu_dev,
u8 extra_payload[512]; u8 extra_payload[512];
} msg; } msg;
int rc; int rc;
irqreturn_t irq_rc = IRQ_NONE;
while (1) {
rc = vhost_user_recv_req(vu_dev, &msg.msg, rc = vhost_user_recv_req(vu_dev, &msg.msg,
sizeof(msg.msg.payload) + sizeof(msg.msg.payload) +
sizeof(msg.extra_payload)); sizeof(msg.extra_payload));
vu_dev->recv_rc = rc;
if (rc) if (rc)
return IRQ_NONE; break;
switch (msg.msg.header.request) { switch (msg.msg.header.request) {
case VHOST_USER_SLAVE_CONFIG_CHANGE_MSG: case VHOST_USER_SLAVE_CONFIG_CHANGE_MSG:
...@@ -411,8 +411,11 @@ static irqreturn_t vu_req_read_message(struct virtio_uml_device *vu_dev, ...@@ -411,8 +411,11 @@ static irqreturn_t vu_req_read_message(struct virtio_uml_device *vu_dev,
if (msg.msg.header.flags & VHOST_USER_FLAG_NEED_REPLY) if (msg.msg.header.flags & VHOST_USER_FLAG_NEED_REPLY)
vhost_user_reply(vu_dev, &msg.msg, response); vhost_user_reply(vu_dev, &msg.msg, response);
irq_rc = IRQ_HANDLED;
return IRQ_HANDLED; };
/* mask EAGAIN as we try non-blocking read until socket is empty */
vu_dev->recv_rc = (rc == -EAGAIN) ? 0 : rc;
return irq_rc;
} }
static irqreturn_t vu_req_interrupt(int irq, void *data) static irqreturn_t vu_req_interrupt(int irq, void *data)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment