From patchwork Mon Feb 20 06:08:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Kaladi X-Patchwork-Id: 124165 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5BDE841CF4; Mon, 20 Feb 2023 07:08:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 021FD42F84; Mon, 20 Feb 2023 07:08:45 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 4AF1040691; Mon, 20 Feb 2023 07:08:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676873323; x=1708409323; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=wJFDS5XXDsLIgj7qmKaSPDR89CXCSWj0utBHxTZrS1w=; b=jzbmM9gXBc0pm/E3DMuNrg7SqAN3v9TxDQ+jYq0KIbRI4aUNMGvc6liX iOAU3jBBiCo8hFfWINsiJADnXR4CAV3CFbHtBPq9bz9aQKf5L4XWQqc3E yOUiN4nBJoRJ2SxXZf9Klr9dEGcacJQ6t2YeE+RDt7bsoE8crmyfrwxgn ztJwqRo8QSTbxhU9Z3CI98lq6E4MrolYkqsIkhshWid3MqgPbjIOmwBQC orZluJhwnFZdRFOg8nlVAzByCIlWafZE9DawrWvmcJmYiAW7/HrJWodPk CuuHhlSX0W1l/LTRjPZxjUqj7O1z6hhr6vN4YSTvsd7aN/C+VjY4igZ2p w==; X-IronPort-AV: E=McAfee;i="6500,9779,10626"; a="334532123" X-IronPort-AV: E=Sophos;i="5.97,311,1669104000"; d="scan'208";a="334532123" 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:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10626"; a="648722850" X-IronPort-AV: E=Sophos;i="5.97,311,1669104000"; d="scan'208";a="648722850" Received: from txandevlnx321.an.intel.com ([10.123.117.43]) by orsmga006.jf.intel.com with ESMTP; 19 Feb 2023 22:08:41 -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 1/2] eventdev: fix race condition in fast-path set function Date: Mon, 20 Feb 2023 00:08:38 -0600 Message-Id: <20230220060839.1267349-1-ashok.k.kaladi@intel.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 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 eventdev enqueue or dequeue function is called during event_dev_fp_ops_set(), 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 data element to the beginning of event_dev_fp_ops_set() function. Fixes: d35e61322de5 ("eventdev: move inline APIs into separate structure") Cc: stable@dpdk.org Signed-off-by: Ashok Kaladi diff --git a/.mailmap b/.mailmap index 5015494210..bbf6744278 100644 --- a/.mailmap +++ b/.mailmap @@ -132,6 +132,7 @@ Ashish Jain Ashish Paul Ashish Sadanandan Ashish Shah +Ashok Kaladi Ashwin Sekhar T K Asim Jamshed Aviad Yehezkel diff --git a/lib/eventdev/eventdev_private.c b/lib/eventdev/eventdev_private.c index 1d3d9d357e..539aade780 100644 --- a/lib/eventdev/eventdev_private.c +++ b/lib/eventdev/eventdev_private.c @@ -107,6 +107,7 @@ void event_dev_fp_ops_set(struct rte_event_fp_ops *fp_op, const struct rte_eventdev *dev) { + fp_op->data = dev->data->ports; fp_op->enqueue = dev->enqueue; fp_op->enqueue_burst = dev->enqueue_burst; fp_op->enqueue_new_burst = dev->enqueue_new_burst; @@ -117,5 +118,4 @@ event_dev_fp_ops_set(struct rte_event_fp_ops *fp_op, fp_op->txa_enqueue = dev->txa_enqueue; fp_op->txa_enqueue_same_dest = dev->txa_enqueue_same_dest; fp_op->ca_enqueue = dev->ca_enqueue; - fp_op->data = dev->data->ports; } From patchwork Mon Feb 20 06:08:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Kaladi X-Patchwork-Id: 124166 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org 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 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; }