diff options
authorRahul Lakkireddy <>2015-07-13 14:21:45 +0530
committerThomas Monjalon <>2015-07-14 10:51:01 +0200
commit0205f873557c3784d5b5ed55ecd08aee3e1dba19 (patch)
parent538e7b887600abf40957b59ac3d7c2f879906488 (diff)
vfio: fix overflow of BAR region offset and size
When using vfio, the probe fails for BAR > 0 after the commit-id 90a1633b2 (eal/linux: allow to map BARs with MSI-X tables). While debugging further, found that the BAR region offset and size read from vfio are u64, but are assigned to uint32_t variables. This results in the u64 value getting truncated to 0 and passing wrong offset and size to mmap for subsequent BAR regions. The fix is to use unsigned long for the offset and size. This is based on patch by Alejandro Lucero <> posted at below: and updated with diff from below to fix 32-bit compilation: Fixes: 90a1633b2347 ("eal/linux: allow to map BARs with MSI-X tables") Signed-off-by: Alejandro Lucero <> Signed-off-by: Rahul Lakkireddy <> Signed-off-by: Kumar Sanghvi <>
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index 426953a..6127f5f 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -728,7 +728,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
struct vfio_region_info reg = { .argsz = sizeof(reg) };
void *bar_addr;
struct memreg {
- uint32_t offset, size;
+ unsigned long offset, size;
} memreg[2] = {};
reg.index = i;
@@ -771,7 +771,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
"Trying to map BAR %d that contains the MSI-X "
"table. Trying offsets: "
- "%04x:%04x, %04x:%04x\n", i,
+ "0x%04lx:0x%04lx, 0x%04lx:0x%04lx\n", i,
memreg[0].offset, memreg[0].size,
memreg[1].offset, memreg[1].size);