From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B922C41CF4; Mon, 20 Feb 2023 07:08:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 67E1F42F9E; Mon, 20 Feb 2023 07:08:47 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id B7E6C40691; Mon, 20 Feb 2023 07:08:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676873325; x=1708409325; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BkNZZyLjSfwaVQe0dtb33lYkpf26a0PUfmfA6D420Ps=; b=KfTUCRseT7ieVX+nF9bCLd4d9LB65nhEZco5GkgX6mxwMFYT5mIllQpm o/5pAMZy0IOVBV4M2akl2hv4ocpUm2kRN8i1ZYK79UrhL87fQpzahyHfJ T1oYS34c481DqexdqeGwq95scFFGDCBOfDj+gZ8EeV0Mh7lGoSDzAiZPO wzKth6AD/L2IbtdKi/oQduRi3KZYzKRCDi/mwvrm40Rle1Q8CI5dbaXOO iFVx47dibQDeRj0zZipRVvqVNPZmDJg039dPSKoHyVHEg/Tg/xu55Fnj0 in9Y0yJH4n7B4EuHnrXkQSE83GV6Gn1OA7NZI7/FZIzqgdHrtO+s5xmlz A==; X-IronPort-AV: E=McAfee;i="6500,9779,10626"; a="334532133" X-IronPort-AV: E=Sophos;i="5.97,311,1669104000"; d="scan'208";a="334532133" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Feb 2023 22:08:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10626"; a="648722858" X-IronPort-AV: E=Sophos;i="5.97,311,1669104000"; d="scan'208";a="648722858" Received: from txandevlnx321.an.intel.com ([10.123.117.43]) by orsmga006.jf.intel.com with ESMTP; 19 Feb 2023 22:08:43 -0800 From: Ashok Kaladi To: jerinj@marvell.com, thomas@monjalon.net Cc: dev@dpdk.org, s.v.naga.harish.k@intel.com, erik.g.carrillo@intel.com, abhinandan.gujjar@intel.com, stable@dpdk.org Subject: [PATCH 2/2] ethdev: fix race condition in fast-path ops setup Date: Mon, 20 Feb 2023 00:08:39 -0600 Message-Id: <20230220060839.1267349-2-ashok.k.kaladi@intel.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20230220060839.1267349-1-ashok.k.kaladi@intel.com> References: <20230220060839.1267349-1-ashok.k.kaladi@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org If ethdev enqueue or dequeue function is called during eth_dev_fp_ops_setup(), it may get pre-empted after setting the function pointers, but before setting the pointer to port data. In this case the newly registered enqueue/dequeue function will use dummy port data and end up in seg fault. This patch moves the updation of each data pointers before updating corresponding function pointers. Fixes: c87d435a4d79 ("ethdev: copy fast-path API into separate structure") Cc: stable@dpdk.org Signed-off-by: Ashok Kaladi diff --git a/lib/ethdev/ethdev_private.c b/lib/ethdev/ethdev_private.c index 48090c879a..a0232c669f 100644 --- a/lib/ethdev/ethdev_private.c +++ b/lib/ethdev/ethdev_private.c @@ -270,17 +270,17 @@ void eth_dev_fp_ops_setup(struct rte_eth_fp_ops *fpo, const struct rte_eth_dev *dev) { + fpo->rxq.data = dev->data->rx_queues; fpo->rx_pkt_burst = dev->rx_pkt_burst; + fpo->txq.data = dev->data->tx_queues; fpo->tx_pkt_burst = dev->tx_pkt_burst; fpo->tx_pkt_prepare = dev->tx_pkt_prepare; fpo->rx_queue_count = dev->rx_queue_count; fpo->rx_descriptor_status = dev->rx_descriptor_status; fpo->tx_descriptor_status = dev->tx_descriptor_status; - fpo->rxq.data = dev->data->rx_queues; fpo->rxq.clbk = (void **)(uintptr_t)dev->post_rx_burst_cbs; - fpo->txq.data = dev->data->tx_queues; fpo->txq.clbk = (void **)(uintptr_t)dev->pre_tx_burst_cbs; } -- 2.25.1