All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mem: fix DMA mask width sanity check
@ 2018-11-07  9:44 Alejandro Lucero
  2018-11-07 10:14 ` Burakov, Anatoly
  0 siblings, 1 reply; 4+ messages in thread
From: Alejandro Lucero @ 2018-11-07  9:44 UTC (permalink / raw)
  To: dev

Current code has different max DMA mask width values for 32 and 64
bits systems. IOMMU hardware could report a higher supported width
than current MAX_DMA_MASK_BITS when RTE_ARCH_64 is not defined. This
is actually true with a 32 bits kernel running in a 64 bits server
with IOMMU hardware. This could also be a problem with embedded systems
using an IOMMU designed for 64 bits in a 32 bits system.

This patch leaves a single max DMA mask width which will make sure the
mask width is within the range for 64 bits variables used for DMA mask.
This also will avoid wrong values because any value higher than
64 bits is likely wrong.

Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
---
 lib/librte_eal/common/eal_common_memory.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 87fd9921f..d47ea4938 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -439,11 +439,7 @@ check_iova(const struct rte_memseg_list *msl __rte_unused,
 	return 1;
 }
 
-#if defined(RTE_ARCH_64)
 #define MAX_DMA_MASK_BITS 63
-#else
-#define MAX_DMA_MASK_BITS 31
-#endif
 
 /* check memseg iovas are within the required range based on dma mask */
 static int __rte_experimental
@@ -453,7 +449,8 @@ check_dma_mask(uint8_t maskbits, bool thread_unsafe)
 	uint64_t mask;
 	int ret;
 
-	/* sanity check */
+	/* Sanity check. We only check width can be managed with 64 bits
+	 * variables. Indeed any higher value is likely wrong. */
 	if (maskbits > MAX_DMA_MASK_BITS) {
 		RTE_LOG(ERR, EAL, "wrong dma mask size %u (Max: %u)\n",
 				   maskbits, MAX_DMA_MASK_BITS);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mem: fix DMA mask width sanity check
  2018-11-07  9:44 [PATCH] mem: fix DMA mask width sanity check Alejandro Lucero
@ 2018-11-07 10:14 ` Burakov, Anatoly
  2018-11-07 11:47   ` Ferruh Yigit
  0 siblings, 1 reply; 4+ messages in thread
From: Burakov, Anatoly @ 2018-11-07 10:14 UTC (permalink / raw)
  To: Alejandro Lucero, dev

On 07-Nov-18 9:44 AM, Alejandro Lucero wrote:
> Current code has different max DMA mask width values for 32 and 64
> bits systems. IOMMU hardware could report a higher supported width
> than current MAX_DMA_MASK_BITS when RTE_ARCH_64 is not defined. This
> is actually true with a 32 bits kernel running in a 64 bits server
> with IOMMU hardware. This could also be a problem with embedded systems
> using an IOMMU designed for 64 bits in a 32 bits system.
> 
> This patch leaves a single max DMA mask width which will make sure the
> mask width is within the range for 64 bits variables used for DMA mask.
> This also will avoid wrong values because any value higher than
> 64 bits is likely wrong.
> 
> Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mem: fix DMA mask width sanity check
  2018-11-07 10:14 ` Burakov, Anatoly
@ 2018-11-07 11:47   ` Ferruh Yigit
  2018-11-07 13:43     ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Ferruh Yigit @ 2018-11-07 11:47 UTC (permalink / raw)
  To: Burakov, Anatoly, Alejandro Lucero, dev

On 11/7/2018 10:14 AM, Burakov, Anatoly wrote:
> On 07-Nov-18 9:44 AM, Alejandro Lucero wrote:
>> Current code has different max DMA mask width values for 32 and 64
>> bits systems. IOMMU hardware could report a higher supported width
>> than current MAX_DMA_MASK_BITS when RTE_ARCH_64 is not defined. This
>> is actually true with a 32 bits kernel running in a 64 bits server
>> with IOMMU hardware. This could also be a problem with embedded systems
>> using an IOMMU designed for 64 bits in a 32 bits system.
>>
>> This patch leaves a single max DMA mask width which will make sure the
>> mask width is within the range for 64 bits variables used for DMA mask.
>> This also will avoid wrong values because any value higher than
>> 64 bits is likely wrong.
>>
>> Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
>> ---
> 
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mem: fix DMA mask width sanity check
  2018-11-07 11:47   ` Ferruh Yigit
@ 2018-11-07 13:43     ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2018-11-07 13:43 UTC (permalink / raw)
  To: Alejandro Lucero; +Cc: dev, Ferruh Yigit, Burakov, Anatoly

07/11/2018 12:47, Ferruh Yigit:
> On 11/7/2018 10:14 AM, Burakov, Anatoly wrote:
> > On 07-Nov-18 9:44 AM, Alejandro Lucero wrote:
> >> Current code has different max DMA mask width values for 32 and 64
> >> bits systems. IOMMU hardware could report a higher supported width
> >> than current MAX_DMA_MASK_BITS when RTE_ARCH_64 is not defined. This
> >> is actually true with a 32 bits kernel running in a 64 bits server
> >> with IOMMU hardware. This could also be a problem with embedded systems
> >> using an IOMMU designed for 64 bits in a 32 bits system.
> >>
> >> This patch leaves a single max DMA mask width which will make sure the
> >> mask width is within the range for 64 bits variables used for DMA mask.
> >> This also will avoid wrong values because any value higher than
> >> 64 bits is likely wrong.
> >>
> >> Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
> >> ---
> > 
> > Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
> 
> Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>

Fixes: 223b7f1d5ef6 ("mem: add function for checking memseg IOVA")

Applied, thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-11-07 13:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-07  9:44 [PATCH] mem: fix DMA mask width sanity check Alejandro Lucero
2018-11-07 10:14 ` Burakov, Anatoly
2018-11-07 11:47   ` Ferruh Yigit
2018-11-07 13:43     ` Thomas Monjalon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.