From: Yong Wang Date: Fri, 15 Jul 2016 00:15:10 +0000 (-0700) Subject: vfio: fix PCI resource mapping X-Git-Tag: spdx-start~6167 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=9ba723566440d79f572bc88ce53241121fead43d;p=dpdk.git vfio: fix PCI resource mapping The offset of the 2nd mmap() when mapping the region after msix_bar needs to take region address into consideration as mmap() takes address that is resource-relative instead of bar-relative. This is exposed when binding vmxnet3 to vfio-pci. Fixes: 90a1633b2347 ("eal/linux: allow to map BARs with MSI-X tables") Signed-off-by: Yong Wang Signed-off-by: Ronghua Zhang Acked-by: Anatoly Burakov --- diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c index 46cd6831b5..5f478c5936 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c @@ -431,7 +431,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev) } else { memreg[0].offset = reg.offset; memreg[0].size = table_start; - memreg[1].offset = table_end; + memreg[1].offset = reg.offset + table_end; memreg[1].size = reg.size - table_end; RTE_LOG(DEBUG, EAL, @@ -474,7 +474,9 @@ pci_vfio_map_resource(struct rte_pci_device *dev) /* if there's a second part, try to map it */ if (map_addr != MAP_FAILED && memreg[1].offset && memreg[1].size) { - void *second_addr = RTE_PTR_ADD(bar_addr, memreg[1].offset); + void *second_addr = RTE_PTR_ADD(bar_addr, + memreg[1].offset - + (uintptr_t)reg.offset); map_addr = pci_map_resource(second_addr, vfio_dev_fd, memreg[1].offset, memreg[1].size,