From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nh501-vm5.bullet.mail.kks.yahoo.co.jp (nh501-vm5.bullet.mail.kks.yahoo.co.jp [183.79.56.135]) by dpdk.org (Postfix) with SMTP id DCE202BE2 for ; Mon, 6 Aug 2018 10:43:15 +0200 (CEST) Received: from [183.79.100.141] by nh501.bullet.mail.kks.yahoo.co.jp with NNFMP; 06 Aug 2018 08:43:14 -0000 Received: from [183.79.100.137] by t504.bullet.mail.kks.yahoo.co.jp with NNFMP; 06 Aug 2018 08:43:14 -0000 Received: from [127.0.0.1] by omp506.mail.kks.yahoo.co.jp with NNFMP; 06 Aug 2018 08:43:14 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 228051.28262.bm@omp506.mail.kks.yahoo.co.jp Received: (qmail 11933 invoked by alias); 6 Aug 2018 08:43:14 -0000 Received: from unknown (HELO localhost.localdomain) (61.21.22.172 with login) by ymobsmtp5003.mail.kks.ynwp.yahoo.co.jp with SMTP; 6 Aug 2018 08:43:14 -0000 X-YMail-JAS: zGo7lGgVM1n.jnfDOXQNIVZtAfTltEkwDPhux2wEuZyVzeuDKJ6Y3Q5IUlNL_rzREOIYhl1OKHySNniZaE20m4WlU16KuQhM0uGk7y2apUTEMafXG_QG1LQF9wg_Fcv3fbY9hcbFmvjQylE- X-Apparently-From: X-YMail-OSG: OaVljeQVM1lSYAS6UFCuP.Lr6k10JFR9eXO55hwi7DilcLf wytFthJUzH5eMj53_C_CDtGFRz51uDjfqZwjIKdVssskvt1T7nYrYdXFV.gN tAgMzdI95xZceGo5a8wzBGg5GphCk2IljP6pVtkb4BY1BSoLuM5YqfgocixO W4io7A_FED1H5t.UeSyxYskGNHM4AazQhxItdS63PyrQs02syB44WWrS3hOy viQPnNdVl5iF9I3QT3AD4kWd1usb_vZjGExIvRi7ILpAMwr.lAg1.Fwsv2FI p51xKhPnubBOeaIGVwQJQl28vEWvSp21KkwpaKYSzX0iQkN7JZcWpnlWGqjP V6c9A7MXcBvdD0LAtSTMR1bWlAy6ZfVXlFJ3aiK6AxtE4yF_Vsy85Pe.vZnL 9gmg80JyRY2NdsJwInsIIBgTuDCoUWWO.brxH6acPGcqjTGVKHI0mHEFvYwo hnzZINv5JgkcFPUdWKyl9EA9aKwbJ5s1xxgf4sODeBWj.sTNmEanDBRuPbHX U3cGa.2Es.C96YxS_xXnJoveV9FC7cBcHbLy6OyMJt00R28nDEUoYzeVhuej N1UEMY8Ex6P200qVd3lBWZ3_9Dkk- From: Takeshi Yoshimura To: dev@dpdk.org Cc: Takeshi Yoshimura , Takeshi Yoshimura Date: Mon, 6 Aug 2018 17:43:09 +0900 Message-Id: <20180806084309.5489-1-tyos@jp.ibm.com> X-Mailer: git-send-email 2.15.1 Subject: [dpdk-dev] [PATCH] 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: Mon, 06 Aug 2018 08:43: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