DPDK patches and discussions
 help / color / mirror / Atom feed
From: Matan Azrad <matan@mellanox.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>
Cc: dev@dpdk.org, Xiao Wang <xiao.w.wang@intel.com>,
	Tiwei Bie <tiwei.bie@intel.com>,
	stable@dpdk.org
Subject: [dpdk-dev] [PATCH] vhost: fix host notifier configuration error flow
Date: Thu, 11 Jun 2020 15:47:30 +0000	[thread overview]
Message-ID: <1591890450-63055-1-git-send-email-matan@mellanox.com> (raw)

A vDPA driver can configure its device FD to be notified directly by
the guest memory mapping using `rte_vhost_host_notifier_ctrl` API.

The driver request is managed by the dpdk vhost management and is
forwarded to the QEMU, the vhost massage includes reply request in order
to be sure that the memory mapping was done correctly by the QEMU.

When QEMU finishes the configuration, it marks that its replay is valid
in the slave FD using VHOST_USER_REPLY_MASK flag.
The flag is set only in success and when the slave FD includes the reply
data.

The vhost library didn't validate the above flag before accessing to the
slave FD, it leaded to the thread to be blocked on recvmsg call forever
in case the QEMU has some problems in the notifier configuration.

Handle VHOST_USER_REPLY_MASK flag to validate that slave FD includes
a reply data.

Fixes: d90cf7d111ac ("vhost: support host notifier")
Cc: stable@dpdk.org

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 lib/librte_vhost/vhost_user.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 84bebad..aa19d15 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -2833,8 +2833,14 @@ static int process_slave_message_reply(struct virtio_net *dev,
 	struct VhostUserMsg msg_reply;
 	int ret;
 
-	if ((msg->flags & VHOST_USER_NEED_REPLY) == 0)
-		return 0;
+	if (!(msg->flags & VHOST_USER_REPLY_MASK)) {
+		if (msg->flags & VHOST_USER_NEED_REPLY) {
+			ret = -1;
+			goto out;
+		} else {
+			return 0;
+		}
+	}
 
 	ret = read_vhost_message(dev->slave_req_fd, &msg_reply);
 	if (ret <= 0) {
-- 
1.8.3.1


             reply	other threads:[~2020-06-11 15:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-11 15:47 Matan Azrad [this message]
2020-06-12  7:25 ` Xia, Chenbo
2020-06-12 11:05   ` Matan Azrad
2020-06-14 13:11     ` Xia, Chenbo

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=1591890450-63055-1-git-send-email-matan@mellanox.com \
    --to=matan@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=stable@dpdk.org \
    --cc=tiwei.bie@intel.com \
    --cc=xiao.w.wang@intel.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).