vfio: fix boundary check in region search
authorXiao Wang <xiao.w.wang@intel.com>
Fri, 20 Apr 2018 15:10:50 +0000 (23:10 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 23 Apr 2018 19:24:22 +0000 (21:24 +0200)
A previously mapped region is skipped during the search, leading to
DMA unmap fails.

This patch fixes it and rewords the comment.

Fixes: 73a639085938 ("vfio: allow to map other memory regions")

Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
lib/librte_eal/linuxapp/eal/eal_vfio.c

index cc2030a..95cd343 100644 (file)
@@ -220,15 +220,15 @@ find_user_mem_map(uint64_t addr, uint64_t iova, uint64_t len)
                /* check start VA */
                if (addr < map->addr || addr >= map_va_end)
                        continue;
-               /* check if IOVA end is within boundaries */
-               if (va_end <= map->addr || va_end >= map_va_end)
+               /* check if VA end is within boundaries */
+               if (va_end <= map->addr || va_end > map_va_end)
                        continue;
 
-               /* check start PA */
+               /* check start IOVA */
                if (iova < map->iova || iova >= map_iova_end)
                        continue;
                /* check if IOVA end is within boundaries */
-               if (iova_end <= map->iova || iova_end >= map_iova_end)
+               if (iova_end <= map->iova || iova_end > map_iova_end)
                        continue;
 
                /* we've found our map */