From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nh503-vm3.bullet.mail.kks.yahoo.co.jp (nh503-vm3.bullet.mail.kks.yahoo.co.jp [183.79.56.189]) by dpdk.org (Postfix) with SMTP id 344821B1BB for ; Tue, 7 Aug 2018 04:35:09 +0200 (CEST) Received: from [183.79.100.141] by nh503.bullet.mail.kks.yahoo.co.jp with NNFMP; 07 Aug 2018 02:35:08 -0000 Received: from [183.79.100.136] by t504.bullet.mail.kks.yahoo.co.jp with NNFMP; 07 Aug 2018 02:35:08 -0000 Received: from [127.0.0.1] by omp505.mail.kks.yahoo.co.jp with NNFMP; 07 Aug 2018 02:35:08 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 504036.66091.bm@omp505.mail.kks.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-dev] [PATCH v2] eal/vfio: fix sPAPR IOMMU mapping 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, 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