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>
This commit is contained in:
parent
f7378a03d1
commit
998c89f148
@ -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, ®);
|
||||
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, ®);
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user