From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from stargate3.asicdesigners.com (stargate.chelsio.com [67.207.112.58]) by dpdk.org (Postfix) with ESMTP id 997425A9B for ; Tue, 16 Jun 2015 16:17:12 +0200 (CEST) Received: from localhost (scalar.blr.asicdesigners.com [10.193.185.94]) by stargate3.asicdesigners.com (8.13.8/8.13.8) with ESMTP id t5GEH7Gn010516; Tue, 16 Jun 2015 07:17:08 -0700 From: Rahul Lakkireddy To: dev@dpdk.org Date: Tue, 16 Jun 2015 19:46:09 +0530 Message-Id: <61d1c9174f7f9159d4005dd2cea16c7719cec964.1434462470.git.rahul.lakkireddy@chelsio.com> X-Mailer: git-send-email 2.4.1 Cc: Felix Marti , Kumar Sanghvi , Nirranjan Kirubaharan Subject: [dpdk-dev] [PATCH] vfio: Fix overflow while assigning vfio BAR region offset and size X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jun 2015 14:17:14 -0000 After the commit-id 90a1633b2 (eal/linux: allow to map BARs with MSI-X tables), VFIO stopped working. On further debug, found that although BAR region offset and size from vfio are read as u64, they are truncated when assigned to uint32_t variables resulting in wrong offset being passed for mmap. The fix is to use uint64_t for offset and size. Signed-off-by: Rahul Lakkireddy Signed-off-by: Kumar Sanghvi --- lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 4 ++-- 1 file 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..d0385ff 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; + uint64_t offset, size; } memreg[2] = {}; reg.index = i; @@ -771,7 +771,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev) RTE_LOG(DEBUG, EAL, "Trying to map BAR %d that contains the MSI-X " "table. Trying offsets: " - "%04x:%04x, %04x:%04x\n", i, + "%04lx:%04lx, %04lx:%04lx\n", i, memreg[0].offset, memreg[0].size, memreg[1].offset, memreg[1].size); } -- 2.4.1