[dpdk-dev,v3,5/6] ena: fix memory management issue
Commit Message
After allocating memzone it's required to zeroize memory in it.
Freeing memzone with function dedicated for memoryzones.
Signed-off-by: Alexander Matushevsky <matua@amazon.com>
Signed-off-by: Jakub Palider <jpa@semihalf.com>
Signed-off-by: Jan Medala <jan@semihalf.com>
---
drivers/net/ena/base/ena_plat_dpdk.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Comments
On Thu, Jun 30, 2016 at 05:04:58PM +0200, Jan Medala wrote:
> After allocating memzone it's required to zeroize memory in it.
> Freeing memzone with function dedicated for memoryzones.
>
Can you provide a fixes line for this patch?
> Signed-off-by: Alexander Matushevsky <matua@amazon.com>
> Signed-off-by: Jakub Palider <jpa@semihalf.com>
> Signed-off-by: Jan Medala <jan@semihalf.com>
> ---
> drivers/net/ena/base/ena_plat_dpdk.h | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ena/base/ena_plat_dpdk.h b/drivers/net/ena/base/ena_plat_dpdk.h
> index b1ed80c..87c3bf1 100644
> --- a/drivers/net/ena/base/ena_plat_dpdk.h
> +++ b/drivers/net/ena/base/ena_plat_dpdk.h
> @@ -62,7 +62,7 @@ typedef uint64_t dma_addr_t;
> #endif
>
> #define ena_atomic32_t rte_atomic32_t
> -#define ena_mem_handle_t void *
> +#define ena_mem_handle_t const struct rte_memzone *
>
> #define SZ_256 (256U)
> #define SZ_4K (4096U)
> @@ -188,13 +188,15 @@ typedef uint64_t dma_addr_t;
> snprintf(z_name, sizeof(z_name), \
> "ena_alloc_%d", ena_alloc_cnt++); \
> mz = rte_memzone_reserve(z_name, size, SOCKET_ID_ANY, 0); \
> + memset(mz->addr, 0, size); \
> virt = mz->addr; \
> phys = mz->phys_addr; \
> + handle = mz; \
> } while (0)
> #define ENA_MEM_FREE_COHERENT(dmadev, size, virt, phys, handle) \
> ({ ENA_TOUCH(size); ENA_TOUCH(phys); \
> ENA_TOUCH(dmadev); \
> - rte_free(virt); })
> + rte_memzone_free(handle); })
>
> #define ENA_MEM_ALLOC_COHERENT_NODE(dmadev, size, virt, phys, node, dev_node) \
> do { \
> --
> 2.8.2
>
On Mon, Jul 04, 2016 at 05:27:50PM +0100, Bruce Richardson wrote:
> On Thu, Jun 30, 2016 at 05:04:58PM +0200, Jan Medala wrote:
> > After allocating memzone it's required to zeroize memory in it.
> > Freeing memzone with function dedicated for memoryzones.
> >
>
> Can you provide a fixes line for this patch?
>
From looking at git blame, it looks to be:
Fixes: 9ba7981ec992 ("ena: add communication layer for DPDK")
Please confirm that is ok.
/Bruce
Yes, this is correct.
Jan
2016-07-05 18:13 GMT+02:00 Bruce Richardson <bruce.richardson@intel.com>:
> On Mon, Jul 04, 2016 at 05:27:50PM +0100, Bruce Richardson wrote:
> > On Thu, Jun 30, 2016 at 05:04:58PM +0200, Jan Medala wrote:
> > > After allocating memzone it's required to zeroize memory in it.
> > > Freeing memzone with function dedicated for memoryzones.
> > >
> >
> > Can you provide a fixes line for this patch?
> >
>
> From looking at git blame, it looks to be:
> Fixes: 9ba7981ec992 ("ena: add communication layer for DPDK")
>
> Please confirm that is ok.
>
> /Bruce
>
>
Yes, this is correct.
Jan
2016-07-05 18:13 GMT+02:00 Bruce Richardson <bruce.richardson@intel.com>:
> On Mon, Jul 04, 2016 at 05:27:50PM +0100, Bruce Richardson wrote:
> > On Thu, Jun 30, 2016 at 05:04:58PM +0200, Jan Medala wrote:
> > > After allocating memzone it's required to zeroize memory in it.
> > > Freeing memzone with function dedicated for memoryzones.
> > >
> >
> > Can you provide a fixes line for this patch?
> >
>
> From looking at git blame, it looks to be:
> Fixes: 9ba7981ec992 ("ena: add communication layer for DPDK")
>
> Please confirm that is ok.
>
> /Bruce
>
>
@@ -62,7 +62,7 @@ typedef uint64_t dma_addr_t;
#endif
#define ena_atomic32_t rte_atomic32_t
-#define ena_mem_handle_t void *
+#define ena_mem_handle_t const struct rte_memzone *
#define SZ_256 (256U)
#define SZ_4K (4096U)
@@ -188,13 +188,15 @@ typedef uint64_t dma_addr_t;
snprintf(z_name, sizeof(z_name), \
"ena_alloc_%d", ena_alloc_cnt++); \
mz = rte_memzone_reserve(z_name, size, SOCKET_ID_ANY, 0); \
+ memset(mz->addr, 0, size); \
virt = mz->addr; \
phys = mz->phys_addr; \
+ handle = mz; \
} while (0)
#define ENA_MEM_FREE_COHERENT(dmadev, size, virt, phys, handle) \
({ ENA_TOUCH(size); ENA_TOUCH(phys); \
ENA_TOUCH(dmadev); \
- rte_free(virt); })
+ rte_memzone_free(handle); })
#define ENA_MEM_ALLOC_COHERENT_NODE(dmadev, size, virt, phys, node, dev_node) \
do { \