From 3860fa7ef64dec35b87b1aef919ee7c5d259eba3 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Tue, 22 Aug 2017 11:41:38 -0700 Subject: [PATCH] env: Search DPDK memsegs before /proc/self/pagemap for phys addrs When running IOMMU enabled the user is actually interacting with IO addresses - not physical addresses. The value in the DPDK memseg array is the correct one in this case, and should be used at a higher priority than attempting to look up the address in /proc/self/pagemap (i.e. what rte_mem_virt2phy() does). Further, rte_mem_virt2phy() will always fail when running as an unprivileged user, but scanning the memory segments will work. Change-Id: I576e685111b7f9f848337134b7b89a3cf7c85402 Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/375208 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris --- lib/env_dpdk/vtophys.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/env_dpdk/vtophys.c b/lib/env_dpdk/vtophys.c index f2da1a30e..638aa72df 100644 --- a/lib/env_dpdk/vtophys.c +++ b/lib/env_dpdk/vtophys.c @@ -450,11 +450,6 @@ vtophys_get_paddr(uint64_t vaddr) struct rte_memseg *seg; uint32_t seg_idx; - paddr = vtophys_get_dpdk_paddr((void *)vaddr); - if (paddr != RTE_BAD_PHYS_ADDR) { - return paddr; - } - mcfg = rte_eal_get_configuration()->mem_config; for (seg_idx = 0; seg_idx < RTE_MAX_MEMSEG; seg_idx++) { @@ -471,6 +466,15 @@ vtophys_get_paddr(uint64_t vaddr) } } + /* + * The memory is not registered with DPDK. Try to look it up + * in /proc/self/pagemap. + */ + paddr = vtophys_get_dpdk_paddr((void *)vaddr); + if (paddr != RTE_BAD_PHYS_ADDR) { + return paddr; + } + #ifdef DEBUG fprintf(stderr, "could not find vaddr 0x%" PRIx64 " in DPDK mem config\n", vaddr); #endif