vfio: fix secondary process start
authorJianfeng Tan <jianfeng.tan@intel.com>
Thu, 16 Mar 2017 16:28:44 +0000 (16:28 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 4 Apr 2017 09:58:57 +0000 (11:58 +0200)
commitdd18a2f0b27614841f258c567407093c3d4fd6c5
tree373f2ea61f2d1abec0612ab5a862c6842e358e6e
parent9fa5993f103712d10be0f0b111a3a9afc92cd9e6
vfio: fix secondary process start

When binding with vfio-pci, secondary process cannot be started with
an error message:

    cannot find TAILQ entry for PCI device.

It's due to: struct rte_pci_addr is padded with 1 byte for alignment
by compiler. Then below comparison in commit 2f4adfad0a69
("vfio: add multiprocess support") will fail if the last byte is not
initialized.

    memcmp(&vfio_res->pci_addr, &dev->addr, sizeof(dev->addr)

And commit cdc242f260e7 ("eal/linux: support running as unprivileged user")
just triggers this bug by using a stack un-initialized variable.

The fix is to use rte_eal_compare_pci_addr() for pci addr comparison.

Fixes: 2f4adfad0a69 ("vfio: add multiprocess support")
Fixes: cdc242f260e7 ("eal/linux: support running as unprivileged user")
Cc: stable@dpdk.org
Reported-by: Pawel Rutkowski <pawelx.rutkowski@intel.com>
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c