From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 6956B2BE1 for ; Sat, 1 Jul 2017 16:10:22 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 1C4E420961; Sat, 1 Jul 2017 10:10:22 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Sat, 01 Jul 2017 10:10:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=BPEHLzmE7lMa4sM cSISlncXMhQR/9ulRighUB2GrcZE=; b=ROMyWB5SNIOBzpWUZFP3LpExh/7k57a oVHSgKXjdRQ+tYeRkVEi46l2crg9VzOoar7fGr4qh36OZXYdamIXyUrtMfrGQ1lr kAZomXezrz6dHqE6JgmO5HXY/5R1kJhecAq1uvb3s1MtvnbwFaMc2RnViKwi22kM Oj6867baKbek= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=BPEHLzmE7lMa4sMcSISlncXMhQR/9ulRighUB2GrcZE=; b=cSp0Vh60 +aS9E7aqa/oKhBolze74l/rq6enMVZU4llh1A3IhKFV1EmVpclJMlAnKB29a8cf5 of9jB5xNpFypYUl6SF7O8NuRkuBAegPDK1MA5uKzTlhJ1eCU9XUviBNd7jLi1FTg bXAOdkvEiX0DdI2AfWFJOIc8jVzbynsLwkASxerwRFhaP07LaxvbwhfPL1dGM4hz UsxTiXHy02eO4sccQWtrWeXpFHciByyZT6A1FELZyJnw0wYMQDoXHFvt/Z5EyUhW G3WZkNqoqoU0TKTCzVaCQXocVnisWZTuzw4dvqZb1OOQ92hzGN6tkMlZ4f6kx8Qp 9fCHZTgl/kOEVg== X-ME-Sender: X-Sasl-enc: sBgWjvAEJcPDRltd2LohlpYrdERx+G/J4UjfXLJ/ssCL 1498918221 Received: from xps.localnet (221.17.136.77.rev.sfr.net [77.136.17.221]) by mail.messagingengine.com (Postfix) with ESMTPA id 9D08D24726; Sat, 1 Jul 2017 10:10:21 -0400 (EDT) From: Thomas Monjalon To: Jianfeng Tan Cc: dev@dpdk.org, yuanhan.liu@linux.intel.com, maxime.coquelin@redhat.com Date: Sat, 01 Jul 2017 16:10:19 +0200 Message-ID: <34094937.BVuX3fK5it@xps> In-Reply-To: <1496420451-104928-1-git-send-email-jianfeng.tan@intel.com> References: <1496420451-104928-1-git-send-email-jianfeng.tan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [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: Sat, 01 Jul 2017 14:10:22 -0000 02/06/2017 18:20, Jianfeng Tan: > 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") It probably needs to be Cc: stable@dpdk.org > Reported-by: Reshma Pattan > Signed-off-by: Jianfeng Tan > --- [...] > 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); I think it may be sufficient to set an empty string: eth_dev->data->name = '\0';