vfio: fix overflow of BAR region offset and size
authorRahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Mon, 13 Jul 2015 08:51:45 +0000 (14:21 +0530)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 14 Jul 2015 08:51:01 +0000 (10:51 +0200)
commit0205f873557c3784d5b5ed55ecd08aee3e1dba19
tree87cd986efa8a91671991a3072cb9d79f3badb00e
parent538e7b887600abf40957b59ac3d7c2f879906488
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 <alejandro.lucero@netronome.com>
posted at below:
http://dpdk.org/ml/archives/dev/2015-June/020201.html
and updated with diff from below to fix 32-bit compilation:
http://dpdk.org/ml/archives/dev/2015-July/020963.html

Fixes: 90a1633b2347 ("eal/linux: allow to map BARs with MSI-X tables")

Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Signed-off-by: Kumar Sanghvi <kumaras@chelsio.com>
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c