On 06/08/2017 01:05 PM, Santosh Shukla wrote:
Check iova mode and accordingly map iova to pa or va.

Signed-off-by: Santosh Shukla<santosh.shu...@caviumnetworks.com>
Signed-off-by: Jerin Jacob<jerin.ja...@caviumnetworks.com>
---
  lib/librte_eal/linuxapp/eal/eal_vfio.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c 
b/lib/librte_eal/linuxapp/eal/eal_vfio.c
index 04914406f..348b7a7f4 100644
--- a/lib/librte_eal/linuxapp/eal/eal_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c
@@ -706,7 +706,10 @@ vfio_type1_dma_map(int vfio_container_fd)
                dma_map.argsz = sizeof(struct vfio_iommu_type1_dma_map);
                dma_map.vaddr = ms[i].addr_64;
                dma_map.size = ms[i].len;
-               dma_map.iova = ms[i].phys_addr;
+               if (rte_eal_iova_mode() == RTE_IOVA_VA)
+                       dma_map.iova = dma_map.vaddr;
+               else
+                       dma_map.iova = ms[i].phys_addr;
                dma_map.flags = VFIO_DMA_MAP_FLAG_READ | 
VFIO_DMA_MAP_FLAG_WRITE;

IIUC, it is changing default behavior for VFIO devices.

I see a possible problem, but I'm not sure the case is valid.

Imagine you have two devices in the iommu group, and the two devices are
used in separate processes. Each process could try two different
physical addresses at the same virtual address, and so the second map
would fail.

By using physical addresses, you are safe against this problem.

Any thoughts?

Cheers,
Maxime

Reply via email to