From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 1D6F37CFB for ; Fri, 2 Jun 2017 18:19:59 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP; 02 Jun 2017 09:19:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,285,1493708400"; d="scan'208";a="1155879029" Received: from dpdk06.sh.intel.com ([10.239.129.195]) by fmsmga001.fm.intel.com with ESMTP; 02 Jun 2017 09:19:57 -0700 From: Jianfeng Tan To: dev@dpdk.org Cc: thomas@monjalon.net, yuanhan.liu@linux.intel.com, maxime.coquelin@redhat.com, Jianfeng Tan Date: Fri, 2 Jun 2017 16:20:51 +0000 Message-Id: <1496420451-104928-1-git-send-email-jianfeng.tan@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] eal: fix secondary process segfault on multipe virtio devices X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Jun 2017 16:20:00 -0000 Suppose we have 2 virtio devices for a VM, with only the first one, virtio0, binding to igb_uio. Start a primary DPDK process, driving only virtio0. Then start a secondary DPDK process, it encounters segfault at eth_virtio_dev_init() because hw is NULL, when trying to initialize the 2nd virtio devices. 1539 if (!hw->virtio_user_dev) { We could add a precheck to return error when hw is NULL. But the root cause is that virtio devices which are not driven by the primary process are not exluded by secondary eal probe function. To support legacy virtio devices bound to none kernel driver, we removed RTE_PCI_DRV_NEED_MAPPING in commit 962cf902e6eb ("pci: export device mapping functions"). At the boot of primary process, ether dev is allocated in rte_eth_devices array, rte_eth_dev_data is also allocated in rte_eth_dev_data array; then probe function fails; and ether dev is released. However, the entry in rte_eth_dev_data array is not cleared. Then we start secondary process, and try to attach the virtio device that not used in primary process, the field, dev_private (or hw), in rte_eth_dev_data, is NULL. To fail the dev attach, we need to clear the field, name, when we release any ether devices in primary, so that below loop in rte_eth_dev_attach_secondary() will not find any matched names. for (i = 0; i < RTE_MAX_ETHPORTS; i++) { if (strcmp(rte_eth_dev_data[i].name, name) == 0) break; } Fixes: 6d890f8ab512 ("Fixes: net/virtio: fix multiple process support") Reported-by: Reshma Pattan Signed-off-by: Jianfeng Tan --- lib/librte_ether/rte_ethdev_pci.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/librte_ether/rte_ethdev_pci.h b/lib/librte_ether/rte_ethdev_pci.h index d3bc03c..025700d 100644 --- a/lib/librte_ether/rte_ethdev_pci.h +++ b/lib/librte_ether/rte_ethdev_pci.h @@ -134,6 +134,11 @@ rte_eth_dev_pci_release(struct rte_eth_dev *eth_dev) eth_dev->data->dev_private = NULL; + /* Secondary process will use this field, name, for secondary attach, + * clear this field to avoid attaching any released ports in primary. + */ + memset(eth_dev->data->name, 0, RTE_ETH_NAME_MAX_LEN); + eth_dev->device = NULL; eth_dev->intr_handle = NULL; } -- 2.7.4