From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nh505-vm9.bullet.mail.kks.yahoo.co.jp (nh505-vm9.bullet.mail.kks.yahoo.co.jp [183.79.57.111]) by dpdk.org (Postfix) with SMTP id A89B44C57 for ; Tue, 7 Aug 2018 04:32:16 +0200 (CEST) Received: from [183.79.100.139] by nh505.bullet.mail.kks.yahoo.co.jp with NNFMP; 07 Aug 2018 02:32:14 -0000 Received: from [183.79.100.135] by t502.bullet.mail.kks.yahoo.co.jp with NNFMP; 07 Aug 2018 02:32:14 -0000 Received: from [127.0.0.1] by omp504.mail.kks.yahoo.co.jp with NNFMP; 07 Aug 2018 02:32:14 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 759345.72164.bm@omp504.mail.kks.yahoo.co.jp Received: (qmail 1019 invoked by alias); 7 Aug 2018 02:32:14 -0000 Received: from unknown (HELO takeshi-no-air.dhcp.hakozaki.ibm.com) (203.141.91.13 with login) by ymobsmtp5006.mail.kks.ynwp.yahoo.co.jp with SMTP; 7 Aug 2018 02:32:14 -0000 X-YMail-JAS: RrqIzT8VM1nmc7JPHHbNT_8UqgwaKeBAaJlxUeQvuM3aLPEqticbxlS0RKx1FavDmIU0x7O3kJL5I9NKkYpoW6yQLFj1qm4vvMv9mJ3ned6gvvXZWIJezszNbyY0P990yBMle2.adns56jc- X-Apparently-From: X-YMail-OSG: j8wPXdsVM1nfmSJYfG07yenhA1aEg8YUQ9O1xErgqLoiujB jfroEYm2K7tN6MRAUY5r.CH6s8h95wgUqwQv7tEXh4DwYNyvIh_PP5ooE4Ug jc9fqFQeqTty7IuV8fwBCTD65DfOlUA4EloiwhUAWCMVE2KkpvsWZS2M3ZTD Cj1MEgc0NA_pIJM_ezCx1y_4PvJ0a5vhqOIZQAjeKs3GVD_tkH_NEG1LxV8s O45IPMoHQCKObD7NXEdUkmE4256NqrwDSlAWAXT5D4ZE8k7jb.DhvCxvtoiK 6YKLwQU_eTkcrG_xFxOljeo495HMOYm9ymWJqoEWFGwgLqU_dS5UUKnhd3dk x3quyiqBd4NbGaofD7ci.ZF8.CsVPBQMTpNQVQqkz1JAfUi_WuhAB1N5IJl6 .kpoDfrjShP1N7uubVB6RgTol3pATQtJqaK4K8mkKUkIKQ3_6u5qk6YLUoAQ 7vWIS.wqEzbPtRd5_X8BZq4QWVCALPNN3A44zPgpwU2g0G6zNbO677YOiigL B_3.Abmhg9mDsBSwp5Y_CmXmzDhTqLyp4ekyZM_xymLsCBp4Am8aoWFJdLTG GSj5rqjsHU178bNJNy2J3Imm8GY8C 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:32:11 +0900 Message-Id: <20180807023211.1627-1-tyos@jp.ibm.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180806084309.5489-1-tyos@jp.ibm.com> References: <20180806084309.5489-1-tyos@jp.ibm.com> Subject: [dpdk-stable] [PATCH] 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:32:17 -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") 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 @@ -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