[dpdk-dev,v3,5/6] ena: fix memory management issue

Message ID 1467299099-32498-6-git-send-email-jan@semihalf.com (mailing list archive)
State Accepted, archived
Delegated to: Bruce Richardson
Headers

Commit Message

Jan Medala June 30, 2016, 3:04 p.m. UTC
  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

Bruce Richardson July 4, 2016, 4:27 p.m. UTC | #1
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
>
  
Bruce Richardson July 5, 2016, 4:13 p.m. UTC | #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
  
Jan Medala July 5, 2016, 5:03 p.m. UTC | #3
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
>
>
  
Jan Medala July 5, 2016, 5:03 p.m. UTC | #4
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
>
>
  

Patch

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 {								\