From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nh602-vm14.bullet.mail.ssk.yahoo.co.jp (nh602-vm14.bullet.mail.ssk.yahoo.co.jp [182.22.90.39]) by dpdk.org (Postfix) with SMTP id 654FB1B1EC for ; Tue, 7 Aug 2018 04:35:10 +0200 (CEST) Received: from [182.22.66.103] by nh602.bullet.mail.ssk.yahoo.co.jp with NNFMP; 07 Aug 2018 02:35:08 -0000 Received: from [182.22.91.130] by t601.bullet.mail.ssk.yahoo.co.jp with NNFMP; 07 Aug 2018 02:35:08 -0000 Received: from [127.0.0.1] by omp603.mail.ssk.yahoo.co.jp with NNFMP; 07 Aug 2018 02:35:08 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 626133.21503.bm@omp603.mail.ssk.yahoo.co.jp Received: (qmail 21374 invoked by alias); 7 Aug 2018 02:35:08 -0000 Received: from unknown (HELO takeshi-no-air.dhcp.hakozaki.ibm.com) (203.141.91.13 with login) by ymobsmtp5007.mail.kks.ynwp.yahoo.co.jp with SMTP; 7 Aug 2018 02:35:08 -0000 X-YMail-JAS: pHOoBp0VM1my2G9LT4p_FRfeMdsi8pyZ2YJeaKIJN7ly9Dl.7BdhR2XI_MoWMnlFWlUDhAkcjHlJI2PRgc08clOJhJfD9k_5cVh.W0TDkVZqMLo6G5OGIU49SZaJIvfxBDyoS81xv3PpgXE- X-Apparently-From: X-YMail-OSG: noima5oVM1lyqTp9JlOrJT60U7Cj9Pvb49TOUTy2qoDvA.. 8Tp3yRe.ht61JWXnqFypUvddlakc.lD2oF_Kfuga4Pu1CXReskYDBwVptoZ. Y5CUGONOgwjo8iQnC6pwTpepAJGm4UcgV2QQ0C9KkNBFvQFhbBXYve0IZmA9 F5iiL.obEgssXqpZdd6hcM.1wv_5ZNzuIsvWmz_E6XMWPAEatn3S7k4i6ZoE nmQPcxjNFsozJL8JFlF66HKd1YBggMdD4CvzbOno3a0lzg6cZP_Gt7LBzOK9 QUiB81bBhkU8DqYx8D.MjPttmwYAXDn3gpXu_iVIu_a4Z_mdCoBvQO.0gjR8 nu1dTKyUZaKIOnLs8KEk6aLsw61u8sUEaiO9iLiZXMM2OnX9JV4JHrZyBKcf g8PwGmrN_eVjkCHCZdtAwNVi9oNcrmWK_kCsXQ2seqG9Zz1V7NeeGcVz00Rr 5TtNpQNyG0g.ZXCOzezPfZ7XC72DEWJL4MCeLAKPjwLcT8bl0BFnJQUZoFuj MpESSNJ9diyOSjysurx4VcvwEyIX_by61SavgLHs.vj1A3fmTb_H6WmIPLdO 0T6TFNaXpGNAo8MK0m0iP9DqMrHyi From: Takeshi Yoshimura To: dev@dpdk.org Cc: stable@dpdk.org, Thomas Monjalon , anatoly.burakov@intel.com, chaozhu@linux.vnet.ibm.com, Takeshi Yoshimura , Takeshi Yoshimura Date: Tue, 7 Aug 2018 11:35:06 +0900 Message-Id: <20180807023506.1714-1-tyos@jp.ibm.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180807023211.1627-1-tyos@jp.ibm.com> References: <20180807023211.1627-1-tyos@jp.ibm.com> Subject: [dpdk-stable] [PATCH v2] eal/vfio: fix sPAPR IOMMU mapping 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, 07 Aug 2018 02:35:11 -0000 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 --- v2: Added Cc in message 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 @@ -1145,8 +1145,22 @@ vfio_spapr_dma_do_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova, struct vfio_iommu_type1_dma_map dma_map; 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); dma_map.vaddr = vaddr; @@ -1163,13 +1177,6 @@ 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, ®); if (ret) { @@ -1201,7 +1208,7 @@ 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.15.1