[3/6] eal: check hugepages within dma mask range

Message ID 1530034653-28299-4-git-send-email-alejandro.lucero@netronome.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [1/6] eal: add internal dma mask |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Alejandro Lucero June 26, 2018, 5:37 p.m. UTC
  Hugepages get an iova address which could be out of range
for devices with addressing limitations. This patch checks
hugepages are withint the range if dma mask is set by a device.

Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
---
 lib/librte_eal/common/eal_private.h | 3 +++
 lib/librte_eal/linuxapp/eal/eal.c   | 4 ++++
 2 files changed, 7 insertions(+)
  

Patch

diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
index 462226f..05db535 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -224,4 +224,7 @@ 
  */
 struct rte_bus *rte_bus_find_by_device_name(const char *str);
 
+/* if dma mask set by a device, check hugepages are not out of range */
+int rte_eal_memory_dma_mask_check(void);
+
 #endif /* _EAL_PRIVATE_H_ */
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 229eec9..eaa9325 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -960,6 +960,10 @@  static void rte_eal_init_alert(const char *msg)
 		return -1;
 	}
 
+	/* If dma mask set, check hugepages iovas are within the range */
+	if (rte_eal_memory_dma_mask_check() < 0)
+		rte_panic("iovas out of range\n");
+
 	/* initialize default service/lcore mappings and start running. Ignore
 	 * -ENOTSUP, as it indicates no service coremask passed to EAL.
 	 */