From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by dpdk.org (Postfix) with ESMTP id 8E8745B12 for ; Tue, 6 Mar 2018 17:26:37 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C964384221; Tue, 6 Mar 2018 16:26:36 +0000 (UTC) Received: from [10.36.112.61] (ovpn-112-61.ams2.redhat.com [10.36.112.61]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0FEDF2026DFD; Tue, 6 Mar 2018 16:26:32 +0000 (UTC) To: Tomasz Kulasek , yliu@fridaylinux.org Cc: daniel.verkamp@intel.com, james.r.harris@intel.com, pawelx.wodkowski@intel.com, dev@dpdk.org, Dariusz Stojaczyk References: <20180305161108.8232-1-tomaszx.kulasek@intel.com> From: Maxime Coquelin Message-ID: <94395154-a1cb-486e-d03f-e42a8872fabb@redhat.com> Date: Tue, 6 Mar 2018 17:26:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180305161108.8232-1-tomaszx.kulasek@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 06 Mar 2018 16:26:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 06 Mar 2018 16:26:36 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'maxime.coquelin@redhat.com' RCPT:'' Subject: Re: [dpdk-dev] [PATCH] vhost: stop device before updating public vring data 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: , X-List-Received-Date: Tue, 06 Mar 2018 16:26:37 -0000 Hi Tomasz, On 03/05/2018 05:11 PM, Tomasz Kulasek wrote: > For now DPDK assumes that callfd, kickfd and last_idx are being set just > once during vring initialization and device cannot be running while DPDK > receives SET_VRING_KICK, SET_VRING_CALL and SET_VRING_BASE messages. > However, that assumption is wrong. For Vhost SCSI messages might arrive > at any point of time, possibly multiple times, one after another. > > QEMU issues SET_VRING_CALL once during device initialization, then again > during device start. The second message will close previous callfd, > which is still being used by the user-implementation of vhost device. > This results in writing to invalid (closed) callfd. > > Other messages like SET_FEATURES, SET_VRING_ADDR etc also will change > internal state of VQ or device. To prevent race condition device should > also be stopped before updateing vring data. > > Signed-off-by: Dariusz Stojaczyk > Signed-off-by: Pawel Wodkowski > Signed-off-by: Tomasz Kulasek > --- > lib/librte_vhost/vhost_user.c | 40 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 40 insertions(+) In last release, we have introduced a per-virtqueue lock to protect vring handling against asynchronous device changes. I think that would solve the issue you are facing, but you would need to export the VQs locking functions to the vhost-user lib API to be able to use it. I don't think your current patch is the right solution anyway, because it destroys the device in case we don't want it to remain alive, like set_log_base, or set_features when only the logging feature gets enabled. Cheers, Maxime