summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOlivier Matz <olivier.matz@6wind.com>2016-07-11 12:20:27 +0200
committerThomas Monjalon <thomas.monjalon@6wind.com>2016-07-11 19:10:09 +0200
commite33c4d97913e06b46573a9a43beaf979f8444790 (patch)
treed2f9d1730d1a80cc220ec21327f09e6d5c6ffa6d /lib
parent9d59b409ca0963451cd7117df1ca1a19a9407e95 (diff)
downloaddpdk-e33c4d97913e06b46573a9a43beaf979f8444790.zip
dpdk-e33c4d97913e06b46573a9a43beaf979f8444790.tar.gz
dpdk-e33c4d97913e06b46573a9a43beaf979f8444790.tar.xz
xen: fix retrieval of physical address
When using Xen Dom0, it looks that /proc/self/pagemap returns 0. This breaks the creation of mbufs pool. We can workaround this in rte_mem_virt2phy() by browsing the dpdk memory segments. This only works for dpdk memory, but it's enough to fix the mempool creation. Fixes: c042ba20674a ("mempool: rework support of Xen dom0") Fixes: 3097de6e6bfb ("mem: get physical address of any pointer") Reported-by: Huilong Xu <huilongx.xu@intel.com> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/librte_eal/linuxapp/eal/eal_memory.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
index b663244..42a29fa 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -164,6 +164,29 @@ rte_mem_virt2phy(const void *virtaddr)
int page_size;
off_t offset;
+ /* when using dom0, /proc/self/pagemap always returns 0, check in
+ * dpdk memory by browsing the memsegs */
+ if (rte_xen_dom0_supported()) {
+ struct rte_mem_config *mcfg;
+ struct rte_memseg *memseg;
+ unsigned i;
+
+ mcfg = rte_eal_get_configuration()->mem_config;
+ for (i = 0; i < RTE_MAX_MEMSEG; i++) {
+ memseg = &mcfg->memseg[i];
+ if (memseg->addr == NULL)
+ break;
+ if (virtaddr > memseg->addr &&
+ virtaddr < RTE_PTR_ADD(memseg->addr,
+ memseg->len)) {
+ return memseg->phys_addr +
+ RTE_PTR_DIFF(virtaddr, memseg->addr);
+ }
+ }
+
+ return RTE_BAD_PHYS_ADDR;
+ }
+
/* Cannot parse /proc/self/pagemap, no need to log errors everywhere */
if (!proc_pagemap_readable)
return RTE_BAD_PHYS_ADDR;