summaryrefslogtreecommitdiff
path: root/lib/librte_ivshmem
diff options
context:
space:
mode:
authorSergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>2015-08-07 16:27:33 +0100
committerThomas Monjalon <thomas.monjalon@6wind.com>2015-08-09 19:45:25 +0200
commitcd10c42eb5bcdc9b8d6f91db5929ed0e54132181 (patch)
treed7ec3e480c1d6987504aa4a47875a9ee71df957c /lib/librte_ivshmem
parentd1668c9762ad5f2e9e6ad8436e6a23bac64473c9 (diff)
downloaddpdk-cd10c42eb5bcdc9b8d6f91db5929ed0e54132181.zip
dpdk-cd10c42eb5bcdc9b8d6f91db5929ed0e54132181.tar.gz
dpdk-cd10c42eb5bcdc9b8d6f91db5929ed0e54132181.tar.xz
mem: fix ivshmem freeing
There is no sync between host and guest to allow removal of memzones, and freeing them result in undefined behavior. In the guest, we identify IVSHMEM memsegs/memzones by having ioremap_addr != 0. In the host, nothing is done to the memzone, meaning ioremap_addr == 0. As a solution, mark memzones being added to IVSHMEM in the host, by setting ioremap_addr, then return an error whenever we try to free an IVSHMEM memzone. Fixes: ff909fe21f0 ("mem: introduce memzone freeing") Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
Diffstat (limited to 'lib/librte_ivshmem')
-rw-r--r--lib/librte_ivshmem/rte_ivshmem.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/librte_ivshmem/rte_ivshmem.c b/lib/librte_ivshmem/rte_ivshmem.c
index 9621906..8fc4b57 100644
--- a/lib/librte_ivshmem/rte_ivshmem.c
+++ b/lib/librte_ivshmem/rte_ivshmem.c
@@ -504,7 +504,22 @@ add_memzone_to_metadata(const struct rte_memzone * mz,
config->metadata->name);
goto fail;
}
+#ifdef RTE_LIBRTE_IVSHMEM
+ struct rte_mem_config *mcfg;
+ unsigned int idx;
+ mcfg = rte_eal_get_configuration()->mem_config;
+
+ rte_rwlock_write_lock(&mcfg->mlock);
+
+ idx = ((uintptr_t)mz - (uintptr_t)mcfg->memzone);
+ idx = idx / sizeof(struct rte_memzone);
+
+ /* mark the memzone not freeable */
+ mcfg->memzone[idx].ioremap_addr = mz->phys_addr;
+
+ rte_rwlock_write_unlock(&mcfg->mlock);
+#endif
rte_spinlock_unlock(&config->sl);
return 0;
fail: