vfio: fix DMA mapping of external heaps
authorAnatoly Burakov <anatoly.burakov@intel.com>
Tue, 5 Nov 2019 15:15:12 +0000 (15:15 +0000)
committerDavid Marchand <david.marchand@redhat.com>
Thu, 7 Nov 2019 16:46:43 +0000 (17:46 +0100)
commit47c45a4df687a1bf1f0ae186ebe555c883b446f2
tree6b1e518d5f958c81e085d4f7535a9db7de670a73
parentb14d192ca1fc7575f415f363990c202cece84e28
vfio: fix DMA mapping of external heaps

Currently, externally created heaps are supposed to be automatically
mapped for VFIO DMA by EAL, however they only do so if, at the time of
heap creation, VFIO is initialized and has at least one device
available. If no devices are available at the time of heap creation (or
if devices were available, but were since hot-unplugged, thus dropping
all VFIO container mappings), then VFIO mapping code would have skipped
over externally allocated heaps.

The fix is two-fold. First, we allow externally allocated memory
segments to be marked as "heap" segments. This allows us to distinguish
between external memory segments that were created via heap API, from
those that were created via rte_extmem_register() API.

Then, we fix the VFIO code to only skip non-heap external segments.
Also, since external heaps are not guaranteed to have valid IOVA
addresses, we will skip those which have invalid IOVA addresses as well.

Fixes: 0f526d674f8e ("malloc: separate creating memseg list and malloc heap")
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Tested-by: Rajesh Ravi <rajesh.ravi@broadcom.com>
Acked-by: David Marchand <david.marchand@redhat.com>
lib/librte_eal/common/include/rte_memory.h
lib/librte_eal/common/rte_malloc.c
lib/librte_eal/freebsd/eal/eal_memory.c
lib/librte_eal/linux/eal/eal_memory.c
lib/librte_eal/linux/eal/eal_vfio.c