summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTakeshi Yoshimura <tyos@jp.ibm.com>2018-08-07 11:35:06 +0900
committerThomas Monjalon <thomas@monjalon.net>2018-10-28 22:33:27 +0100
commit998c89f148ee31564ccde958056e54418c18f10c (patch)
treed1afd63b3408278dd9c7d3169a0206b436b340bf /lib
parentf7378a03d18d186b0c53f57f5bcc939e5c5c227c (diff)
downloaddpdk-998c89f148ee31564ccde958056e54418c18f10c.zip
dpdk-998c89f148ee31564ccde958056e54418c18f10c.tar.gz
dpdk-998c89f148ee31564ccde958056e54418c18f10c.tar.xz
vfio: fix sPAPR IOMMU mapping
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 <tyos@jp.ibm.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/librte_eal/linuxapp/eal/eal_vfio.c23
1 files 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 d7268e4..ebecde1 100644
--- a/lib/librte_eal/linuxapp/eal/eal_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c
@@ -1154,8 +1154,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, &reg);
+ 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;
@@ -1172,13 +1186,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, &reg);
if (ret) {
@@ -1213,7 +1220,7 @@ vfio_spapr_map_walk(const struct rte_memseg_list *msl,
if (msl->external)
return 0;
- 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);
}