[dpdk-dev] eal: force IOVA PA mode if KNI module inserted

Message ID 20171102000600.85309-1-ferruh.yigit@intel.com (mailing list archive)
State Accepted, archived
Headers

Checks

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

Commit Message

Ferruh Yigit Nov. 2, 2017, 12:06 a.m. UTC
  Fix kernel crash with KNI because KNI requires physical addresses.

When IOVA VA mode used, memzones and mbufs physical address fields
contain virtual addresses. But KNI relies on these fields to enable
kernel access for buffers. Those fields having virtual address cause
crash in kernel.

This is a workaround until KNI fixed properly to work with virtual
addresses.

Fixes: 72d013644bd6 ("mem: honor IOVA mode in malloc virt2phy")

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
Cc: Jianfeng Tan <jianfeng.tan@intel.com>
Cc: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Cc: Santosh Shukla <santosh.shukla@caviumnetworks.com>
Cc: Thomas Monjalon <thomas@monjalon.net>

This patch superseded following one:
http://dpdk.org/dev/patchwork/patch/31071/
---
 lib/librte_eal/linuxapp/eal/eal.c | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Comments

Thomas Monjalon Nov. 6, 2017, 11:25 p.m. UTC | #1
02/11/2017 01:06, Ferruh Yigit:
> Fix kernel crash with KNI because KNI requires physical addresses.
> 
> When IOVA VA mode used, memzones and mbufs physical address fields
> contain virtual addresses. But KNI relies on these fields to enable
> kernel access for buffers. Those fields having virtual address cause
> crash in kernel.
> 
> This is a workaround until KNI fixed properly to work with virtual
> addresses.
> 
> Fixes: 72d013644bd6 ("mem: honor IOVA mode in malloc virt2phy")
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 017c402ed..29912a4e5 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -808,6 +808,15 @@  rte_eal_init(int argc, char **argv)
 	/* autodetect the iova mapping mode (default is iova_pa) */
 	rte_eal_get_configuration()->iova_mode = rte_bus_get_iommu_class();
 
+	/* Workaround for KNI which requires physical address to work */
+	if (rte_eal_get_configuration()->iova_mode == RTE_IOVA_VA &&
+			rte_eal_check_module("rte_kni") == 1) {
+		rte_eal_get_configuration()->iova_mode = RTE_IOVA_PA;
+		RTE_LOG(WARNING, EAL,
+			"Some devices want iova as va but pa will be used because.. "
+			"KNI module inserted\n");
+	}
+
 	if (internal_config.no_hugetlbfs == 0 &&
 			internal_config.process_type != RTE_PROC_SECONDARY &&
 			eal_hugepage_info_init() < 0) {