From patchwork Tue Feb 27 14:34:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 35478 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3F6943544; Tue, 27 Feb 2018 15:34:57 +0100 (CET) Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by dpdk.org (Postfix) with ESMTP id 27AC01E2B for ; Tue, 27 Feb 2018 15:34:56 +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 A0D44404084B; Tue, 27 Feb 2018 14:34:55 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.112.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F4E52024CA2; Tue, 27 Feb 2018 14:34:54 +0000 (UTC) From: Maxime Coquelin To: jianfeng.tan@intel.com, stefanha@redhat.com, tiwei.bie@intel.com, jfreimann@redhat.com, dev@dpdk.org Cc: Maxime Coquelin Date: Tue, 27 Feb 2018 15:34:39 +0100 Message-Id: <20180227143441.6471-2-maxime.coquelin@redhat.com> In-Reply-To: <20180227143441.6471-1-maxime.coquelin@redhat.com> References: <20180227143441.6471-1-maxime.coquelin@redhat.com> 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.5]); Tue, 27 Feb 2018 14:34:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 27 Feb 2018 14:34:55 +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: [dpdk-dev] [RFC v2 1/3] vhost: invalidate vring addresses in cleanup_vq() 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" When cleaning-up the virtqueue, we also need to invalidate its addresses to be sure outdated addresses won't be used later. Signed-off-by: Maxime Coquelin Reviewed-by: Jens Freimann Reviewed-by: Zhiyong Yang --- lib/librte_vhost/vhost.c | 6 ++++-- lib/librte_vhost/vhost.h | 3 ++- lib/librte_vhost/vhost_user.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index f6f12a03b..e4281cf67 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -69,12 +69,14 @@ __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq, } void -cleanup_vq(struct vhost_virtqueue *vq, int destroy) +cleanup_vq(struct virtio_net *dev, struct vhost_virtqueue *vq, int destroy) { if ((vq->callfd >= 0) && (destroy != 0)) close(vq->callfd); if (vq->kickfd >= 0) close(vq->kickfd); + + vring_invalidate(dev, vq); } /* @@ -89,7 +91,7 @@ cleanup_device(struct virtio_net *dev, int destroy) vhost_backend_cleanup(dev); for (i = 0; i < dev->nr_vring; i++) - cleanup_vq(dev->virtqueue[i], destroy); + cleanup_vq(dev, dev->virtqueue[i], destroy); } void diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index 58aec2e0d..481700489 100644 --- a/lib/librte_vhost/vhost.h +++ b/lib/librte_vhost/vhost.h @@ -362,7 +362,8 @@ void cleanup_device(struct virtio_net *dev, int destroy); void reset_device(struct virtio_net *dev); void vhost_destroy_device(int); -void cleanup_vq(struct vhost_virtqueue *vq, int destroy); +void cleanup_vq(struct virtio_net *dev, struct vhost_virtqueue *vq, + int destroy); void free_vq(struct vhost_virtqueue *vq); int alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx); diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 5c5361066..c256ebb06 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -219,7 +219,7 @@ vhost_user_set_features(struct virtio_net *dev, uint64_t features) continue; dev->virtqueue[dev->nr_vring] = NULL; - cleanup_vq(vq, 1); + cleanup_vq(dev, vq, 1); free_vq(vq); } }