From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 247261B4FF for ; Fri, 23 Nov 2018 11:28:43 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 875B2308339C; Fri, 23 Nov 2018 10:28:42 +0000 (UTC) Received: from ktraynor.remote.csb (unknown [10.36.118.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B9C91836C; Fri, 23 Nov 2018 10:28:41 +0000 (UTC) From: Kevin Traynor To: Takeshi Yoshimura Cc: dpdk stable Date: Fri, 23 Nov 2018 10:26:09 +0000 Message-Id: <20181123102713.17309-5-ktraynor@redhat.com> In-Reply-To: <20181123102713.17309-1-ktraynor@redhat.com> References: <20181123102713.17309-1-ktraynor@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 23 Nov 2018 10:28:42 +0000 (UTC) Subject: [dpdk-stable] patch 'vfio: fix sPAPR IOMMU mapping' has been queued to stable release 18.08.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: Fri, 23 Nov 2018 10:28:43 -0000 Hi, FYI, your patch has been queued to stable release 18.08.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 11/29/18. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. If the code is different (ie: not only metadata diffs), due for example to a change in context or macro names, please double check it. Thanks. Kevin Traynor --- >>From e9634e33b6908bce9add992f5406863a64d834bb Mon Sep 17 00:00:00 2001 From: Takeshi Yoshimura Date: Tue, 7 Aug 2018 11:35:06 +0900 Subject: [PATCH] vfio: fix sPAPR IOMMU mapping [ upstream commit 998c89f148ee31564ccde958056e54418c18f10c ] Commit 73a639085938 ("vfio: allow to map other memory regions") introduced a bug in sPAPR IOMMU mapping. The commit removed necessary ioctl with VFIO_IOMMU_SPAPR_REGISTER_MEMORY. Also, vfio_spapr_map_walk should call vfio_spapr_dma_do_map instead of vfio_spapr_dma_mem_map. Fixes: 73a639085938 ("vfio: allow to map other memory regions") Signed-off-by: Takeshi Yoshimura --- lib/librte_eal/linuxapp/eal/eal_vfio.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c index c68dc38e0..68e862946 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c @@ -1146,6 +1146,20 @@ vfio_spapr_dma_do_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova, struct vfio_iommu_type1_dma_unmap dma_unmap; int ret; + struct vfio_iommu_spapr_register_memory reg = { + .argsz = sizeof(reg), + .flags = 0 + }; + reg.vaddr = (uintptr_t) vaddr; + reg.size = len; if (do_map != 0) { + ret = ioctl(vfio_container_fd, + VFIO_IOMMU_SPAPR_REGISTER_MEMORY, ®); + if (ret) { + RTE_LOG(ERR, EAL, " cannot register vaddr for IOMMU, " + "error %i (%s)\n", errno, strerror(errno)); + return -1; + } + memset(&dma_map, 0, sizeof(dma_map)); dma_map.argsz = sizeof(struct vfio_iommu_type1_dma_map); @@ -1164,11 +1178,4 @@ vfio_spapr_dma_do_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova, } else { - struct vfio_iommu_spapr_register_memory reg = { - .argsz = sizeof(reg), - .flags = 0 - }; - reg.vaddr = (uintptr_t) vaddr; - reg.size = len; - ret = ioctl(vfio_container_fd, VFIO_IOMMU_SPAPR_UNREGISTER_MEMORY, ®); @@ -1202,5 +1209,5 @@ vfio_spapr_map_walk(const struct rte_memseg_list *msl __rte_unused, int *vfio_container_fd = arg; - return vfio_spapr_dma_mem_map(*vfio_container_fd, ms->addr_64, ms->iova, + return vfio_spapr_dma_do_map(*vfio_container_fd, ms->addr_64, ms->iova, ms->len, 1); } -- 2.19.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2018-11-23 10:22:54.381170026 +0000 +++ 0005-vfio-fix-sPAPR-IOMMU-mapping.patch 2018-11-23 10:22:54.000000000 +0000 @@ -1,15 +1,16 @@ -From 998c89f148ee31564ccde958056e54418c18f10c Mon Sep 17 00:00:00 2001 +From e9634e33b6908bce9add992f5406863a64d834bb Mon Sep 17 00:00:00 2001 From: Takeshi Yoshimura Date: Tue, 7 Aug 2018 11:35:06 +0900 Subject: [PATCH] vfio: fix sPAPR IOMMU mapping +[ upstream commit 998c89f148ee31564ccde958056e54418c18f10c ] + Commit 73a639085938 ("vfio: allow to map other memory regions") introduced a bug in sPAPR IOMMU mapping. The commit removed necessary ioctl with VFIO_IOMMU_SPAPR_REGISTER_MEMORY. Also, vfio_spapr_map_walk should call vfio_spapr_dma_do_map instead of vfio_spapr_dma_mem_map. Fixes: 73a639085938 ("vfio: allow to map other memory regions") -Cc: stable@dpdk.org Signed-off-by: Takeshi Yoshimura --- @@ -17,10 +18,10 @@ 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c -index d7268e4ce..ebecde12c 100644 +index c68dc38e0..68e862946 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c -@@ -1155,6 +1155,20 @@ vfio_spapr_dma_do_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova, +@@ -1146,6 +1146,20 @@ vfio_spapr_dma_do_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova, struct vfio_iommu_type1_dma_unmap dma_unmap; int ret; + struct vfio_iommu_spapr_register_memory reg = { @@ -41,7 +42,7 @@ + memset(&dma_map, 0, sizeof(dma_map)); dma_map.argsz = sizeof(struct vfio_iommu_type1_dma_map); -@@ -1173,11 +1187,4 @@ vfio_spapr_dma_do_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova, +@@ -1164,11 +1178,4 @@ vfio_spapr_dma_do_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova, } else { - struct vfio_iommu_spapr_register_memory reg = { @@ -53,8 +54,8 @@ - ret = ioctl(vfio_container_fd, VFIO_IOMMU_SPAPR_UNREGISTER_MEMORY, ®); -@@ -1214,5 +1221,5 @@ vfio_spapr_map_walk(const struct rte_memseg_list *msl, - return 0; +@@ -1202,5 +1209,5 @@ vfio_spapr_map_walk(const struct rte_memseg_list *msl __rte_unused, + int *vfio_container_fd = arg; - return vfio_spapr_dma_mem_map(*vfio_container_fd, ms->addr_64, ms->iova, + return vfio_spapr_dma_do_map(*vfio_container_fd, ms->addr_64, ms->iova,