From patchwork Thu Jun 11 15:47:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 71282 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2F6D3A00BE; Thu, 11 Jun 2020 17:47:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 157411DB8; Thu, 11 Jun 2020 17:47:41 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 890391D9E for ; Thu, 11 Jun 2020 17:47:39 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from matan@mellanox.com) with SMTP; 11 Jun 2020 18:47:34 +0300 Received: from pegasus25.mtr.labs.mlnx. (pegasus25.mtr.labs.mlnx [10.210.16.10]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 05BFlY1E008166; Thu, 11 Jun 2020 18:47:34 +0300 From: Matan Azrad To: Maxime Coquelin Cc: dev@dpdk.org, Xiao Wang , Tiwei Bie , stable@dpdk.org Date: Thu, 11 Jun 2020 15:47:30 +0000 Message-Id: <1591890450-63055-1-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] vhost: fix host notifier configuration error flow X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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) {