From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by dpdk.org (Postfix) with ESMTP id C61FF4CB3 for ; Tue, 14 Aug 2018 13:09:43 +0200 (CEST) Received: from 1.general.paelzer.uk.vpn ([10.172.196.172] helo=lap.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fpXAc-0000wO-EP; Tue, 14 Aug 2018 11:07:26 +0000 From: Christian Ehrhardt To: Maxime Coquelin Cc: Tiwei Bie , Jens Freimann , dpdk stable Date: Tue, 14 Aug 2018 13:06:36 +0200 Message-Id: <20180814110651.25277-33-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180814110651.25277-1-christian.ehrhardt@canonical.com> References: <20180814110651.25277-1-christian.ehrhardt@canonical.com> Subject: [dpdk-stable] patch 'vhost: flush IOTLB cache on new mem table handling' has been queued to stable release 18.05.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Aug 2018 11:09:43 -0000 Hi, FYI, your patch has been queued to stable release 18.05.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 08/16/18. So please shout if anyone has objections. Thanks. Christian Ehrhardt --- >>From db31cb32bca97b40ee3d590d8a438734e99dfd0d Mon Sep 17 00:00:00 2001 From: Maxime Coquelin Date: Thu, 2 Aug 2018 19:21:22 +0200 Subject: [PATCH] vhost: flush IOTLB cache on new mem table handling [ upstream commit af53db486792f3d864c9a30dc13ee12402994640 ] IOTLB entries contain the host virtual address of the guest pages. When receiving a new VHOST_USER_SET_MEM_TABLE request, the previous regions get unmapped, so the IOTLB entries, if any, will be invalid. It does cause the vhost-user process to segfault. This patch introduces a new function to flush the IOTLB cache, and call it as soon as the backend handles a VHOST_USER_SET_MEM request. Fixes: 69c90e98f483 ("vhost: enable IOMMU support") Signed-off-by: Maxime Coquelin Reviewed-by: Tiwei Bie Reviewed-by: Jens Freimann --- lib/librte_vhost/iotlb.c | 10 ++++++++-- lib/librte_vhost/iotlb.h | 2 +- lib/librte_vhost/vhost_user.c | 5 +++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/librte_vhost/iotlb.c b/lib/librte_vhost/iotlb.c index c11ebcaac..c6354fef7 100644 --- a/lib/librte_vhost/iotlb.c +++ b/lib/librte_vhost/iotlb.c @@ -303,6 +303,13 @@ out: return vva; } +void +vhost_user_iotlb_flush_all(struct vhost_virtqueue *vq) +{ + vhost_user_iotlb_cache_remove_all(vq); + vhost_user_iotlb_pending_remove_all(vq); +} + int vhost_user_iotlb_init(struct virtio_net *dev, int vq_index) { @@ -315,8 +322,7 @@ vhost_user_iotlb_init(struct virtio_net *dev, int vq_index) * The cache has already been initialized, * just drop all cached and pending entries. */ - vhost_user_iotlb_cache_remove_all(vq); - vhost_user_iotlb_pending_remove_all(vq); + vhost_user_iotlb_flush_all(vq); } #ifdef RTE_LIBRTE_VHOST_NUMA diff --git a/lib/librte_vhost/iotlb.h b/lib/librte_vhost/iotlb.h index e7083e37b..60b9e4c57 100644 --- a/lib/librte_vhost/iotlb.h +++ b/lib/librte_vhost/iotlb.h @@ -73,7 +73,7 @@ void vhost_user_iotlb_pending_insert(struct vhost_virtqueue *vq, uint64_t iova, uint8_t perm); void vhost_user_iotlb_pending_remove(struct vhost_virtqueue *vq, uint64_t iova, uint64_t size, uint8_t perm); - +void vhost_user_iotlb_flush_all(struct vhost_virtqueue *vq); int vhost_user_iotlb_init(struct virtio_net *dev, int vq_index); #endif /* _VHOST_IOTLB_H_ */ diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 947290fc3..683b99d33 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -751,6 +751,11 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *pmsg) dev->mem = NULL; } + /* Flush IOTLB cache as previous HVAs are now invalid */ + if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) + for (i = 0; i < dev->nr_vring; i++) + vhost_user_iotlb_flush_all(dev->virtqueue[i]); + dev->nr_guest_pages = 0; if (!dev->guest_pages) { dev->max_guest_pages = 8; -- 2.17.1