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 A9F3945C16; Wed, 30 Oct 2024 17:31:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9EFAD43449; Wed, 30 Oct 2024 17:31:36 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2062.outbound.protection.outlook.com [40.107.92.62]) by mails.dpdk.org (Postfix) with ESMTP id E093440299 for ; Wed, 30 Oct 2024 17:31:34 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ae+lq/clayVwEmfNTBbBSec92zSTkuH0R8+GNDF/fqYkYNu/o/nlsXmnHFz8KAXjjB4+BJL9dQjNSYl2k2j1P+ZKLD8R/1Xu7yXRtrrUUE7fMvAIXRh+SLBodcUITPctMkQEW7phhIWlh2SaCIYxA3s0H301zU/6OGwfbasndO75VDca6vgjaplrTqgSZ1DtZ+3vA6hBQNO678kJqWLbZbTYd/YhCUAaq6j5SDns3Wm3W/c7AreXfR8B6Ll1yxcxv4crqphzUzAJ1thcIoLNDTcL4KYbG6P0CLBpEVv9Vk+FV94+QtB9St/rODVOC+Fli9blcq3+fzLNbkEvxQPOKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UWYRamYZD4UdCAJUuMq+pZMZD/vqOcKwEoET72gEu0M=; b=WU9GnB+pCA6sxAbnRRIsUDZVEgpVdgQnTqN4jLzVoOyMc5R86yRcJvvh586HUsMhnEI0cBvY968Vu5WR2V+Y2B78m3Gsz3snFmphs95O+OEDpV0PB1OtDH6bxleMmunqTaPL/vf/ZRNdJGAVqKT7JpUOXBN79aBelYWPEaojPBYPBMZAKc29YmDrYS6fOO1RzstwGzFgX++0IVpJMJMka7qgsi7zx4D8sDBnuaMd3GIxTTC2ULhyRLAbKuTWZMFuFb6ApRIhQpSUisgWeV5Mp/C1LbN8wyScYocYMHBraXvqTEqA5/HX5vu8+DmaBWRh4nCuxT5qIA42M7vTrhaXRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UWYRamYZD4UdCAJUuMq+pZMZD/vqOcKwEoET72gEu0M=; b=qaQG3Y8oH4jTUqjMp5TPO9XsyWv3u9xaNtEpqr0L9iXjscs5qfX2GhKmBMGPtfFV4iTbPlPLZ7+RhjHabnrWVYRra1kc8GbDNw+EeH91ZWUuw8IBhJIiwkWyb0LCQvNGPyjUi7U5y8H2smdmCp8Gc86ztmTOzB6dXDoEwKkb5xhXVt2aWGR/bZapBw8ZZ49tbcCufuZa1n7WFOpLNLgEM3BO5gShR2a1Dya8G3yVgyRABMmJIWIGluQahzrDMD0PuqPvXnd/CXIs9uRhHRXE41sTRVA0koZ1TwOcqq4UrVtUAxQ3QyZ6qQjXRNeNinlG4D1nSpFbfp1jsi1A5ZgKug== Received: from SJ0PR05CA0132.namprd05.prod.outlook.com (2603:10b6:a03:33d::17) by DS0PR12MB7971.namprd12.prod.outlook.com (2603:10b6:8:14e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.27; Wed, 30 Oct 2024 16:31:30 +0000 Received: from MWH0EPF000A672F.namprd04.prod.outlook.com (2603:10b6:a03:33d:cafe::b) by SJ0PR05CA0132.outlook.office365.com (2603:10b6:a03:33d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.13 via Frontend Transport; Wed, 30 Oct 2024 16:31:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by MWH0EPF000A672F.mail.protection.outlook.com (10.167.249.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.16 via Frontend Transport; Wed, 30 Oct 2024 16:31:29 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 30 Oct 2024 09:31:06 -0700 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 30 Oct 2024 09:31:04 -0700 From: Dariusz Sosnowski To: Viacheslav Ovsiienko , Bing Zhao , Ori Kam , Suanming Mou , Matan Azrad CC: Raslan Darawsheh , Subject: [PATCH 1/2] net/mlx5: fix dangling pointer to params Date: Wed, 30 Oct 2024 17:30:45 +0100 Message-ID: <20241030163046.495982-2-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241030163046.495982-1-dsosnowski@nvidia.com> References: <20241030163046.495982-1-dsosnowski@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A672F:EE_|DS0PR12MB7971:EE_ X-MS-Office365-Filtering-Correlation-Id: d385fe3c-8554-4355-3143-08dcf9004ec6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?C6uZk+BGK4N5sgtodQb9Z/k/QyXqKfWD98v6QwHANeFedVkeUn6A2kJiTehR?= =?us-ascii?Q?D0RvVXYODj15C5tUUPeCphlm5+wJquSR6dfdCAd8a2bS/ohKB/bNgEkiZVQc?= =?us-ascii?Q?gTPbt48XLXD2xF956ExycGmHVrYwC4JqcKHXeuoqzO0vfZVG9Fr/W0bRqHxK?= =?us-ascii?Q?Mr/7u5eAByg7VfdcDxF0e2RXuPtljw92iRdOTo9YuKwgcjjMSBZiA/l+/nGk?= =?us-ascii?Q?1IPVgxs4ShVcphLT0guBw4KiuGttf4SCRQDn0fRPvxhFkTn05We8U062KMyZ?= =?us-ascii?Q?IWHfvBg9tZmaO37h/k4OOkqs2gs9/SSd6rjvk6gPT9HjhcfzPitRtLQDeVc1?= =?us-ascii?Q?HDni7QP6O0eYw8/FTByV0jD833OkV5N7WxLOjMlov+wMuNY0XdVKAEol83gu?= =?us-ascii?Q?w5ChHCZaqoiJX0qGrArV6VtEPoxCrjNuXITswtQZ71GtQQPeo91vHLRDr8hP?= =?us-ascii?Q?IeHQHJZKyrOYFkMBogwmngIeS5ScVqeO6YDPMILXABRsbykWm3p1PvkTTUWH?= =?us-ascii?Q?69NLqtl5q+N4Id6LjO52gdqxa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-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 16:31:29.5758 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d385fe3c-8554-4355-3143-08dcf9004ec6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A672F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7971 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 Offending commits introduced 2 structures which held temporary parameters for flow rule created. These parameters were passed to "rule_acts" buffers stored inside template table and they were used only during a call to mlx5dr_rule_create(). After mlx5dr_rule_create() finished, "rule_acts" buffer is not cleared, for performance reasons, since on the next flow rule create it will be overwritten. GCC 14.2.1, when compiled with -03, issued the following warning: ``` drivers/net/mlx5/mlx5_flow_hw.c:3520:51: error: storing the address of local variable 'ap' in '*..modify_header.data' [-Werror=dangling-pointer=] 3520 | rule_acts[pos].modify_header.data = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 3521 | (uint8_t *)ap->mhdr_cmd; | ~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/mlx5/mlx5_flow_hw.c: In function 'flow_hw_async_flow_create': drivers/net/mlx5/mlx5_flow_hw.c:3925:43: note: 'ap' declared here 3925 | struct mlx5_flow_hw_action_params ap; | ^~ drivers/net/mlx5/mlx5_flow_hw.c:3910:59: note: 'table' declared here 3910 | struct rte_flow_template_table *table, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ ``` Which is technically correct. This warning could be fixed by casting "ap->mhdr_cmd" to "void *", but this is just a workaround. Since what mlx5 PMD cares about is that there is only one instance of mlx5_flow_hw_action_params per queue, this patch moves this struct from the stack to mlx5_hw_q struct. The same is done for mlx5_flow_hw_pattern_params for similar reasons. Fixes: 1d2744f5028d ("net/mlx5: remove flow action parameters from job") Fixes: 57fd15fa373d ("net/mlx5: remove flow pattern from job") Signed-off-by: Dariusz Sosnowski Acked-by: Ori Kam --- drivers/net/mlx5/mlx5.h | 28 ++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 25 ------------------------- drivers/net/mlx5/mlx5_flow_hw.c | 9 +++------ 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 503366580b..bc25d72c0e 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -425,6 +425,30 @@ enum mlx5_hw_indirect_type { #define MLX5_HW_MAX_ITEMS (16) +#define MLX5_MHDR_MAX_CMD ((MLX5_MAX_MODIFY_NUM) * 2 + 1) +#define MLX5_PUSH_MAX_LEN 128 +#define MLX5_ENCAP_MAX_LEN 132 + +/** Container for flow action data constructed during flow rule creation. */ +struct mlx5_flow_hw_action_params { + /** Array of constructed modify header commands. */ + struct mlx5_modification_cmd mhdr_cmd[MLX5_MHDR_MAX_CMD]; + /** Constructed encap/decap data buffer. */ + uint8_t encap_data[MLX5_ENCAP_MAX_LEN]; + /** Constructed IPv6 routing data buffer. */ + uint8_t ipv6_push_data[MLX5_PUSH_MAX_LEN]; +}; + +/** Container for dynamically generated flow items used during flow rule creation. */ +struct mlx5_flow_hw_pattern_params { + /** Array of dynamically generated flow items. */ + struct rte_flow_item items[MLX5_HW_MAX_ITEMS]; + /** Temporary REPRESENTED_PORT item generated by PMD. */ + struct rte_flow_item_ethdev port_spec; + /** Temporary TAG item generated by PMD. */ + struct rte_flow_item_tag tag_spec; +}; + /* HW steering flow management job descriptor. */ struct mlx5_hw_q_job { uint32_t type; /* Job type. */ @@ -449,6 +473,10 @@ struct __rte_cache_aligned mlx5_hw_q { struct rte_ring *indir_iq; /* Indirect action SW in progress queue. */ struct rte_ring *flow_transfer_pending; struct rte_ring *flow_transfer_completed; + /* Action's ARGUMENT resource buffer for rule creation. */ + struct mlx5_flow_hw_action_params ap; + /* Holds spec value for any implicitly added item. */ + struct mlx5_flow_hw_pattern_params pp; }; diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 693e07218d..d4d985fa3b 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -646,9 +646,6 @@ struct mlx5_flow_dv_matcher { struct mlx5_flow_dv_match_params mask; /**< Matcher mask. */ }; -#define MLX5_PUSH_MAX_LEN 128 -#define MLX5_ENCAP_MAX_LEN 132 - /* Encap/decap resource structure. */ struct mlx5_flow_dv_encap_decap_resource { struct mlx5_list_entry entry; @@ -1420,28 +1417,6 @@ typedef int const struct rte_flow_action *, struct mlx5dr_rule_action *); -#define MLX5_MHDR_MAX_CMD ((MLX5_MAX_MODIFY_NUM) * 2 + 1) - -/** Container for flow action data constructed during flow rule creation. */ -struct mlx5_flow_hw_action_params { - /** Array of constructed modify header commands. */ - struct mlx5_modification_cmd mhdr_cmd[MLX5_MHDR_MAX_CMD]; - /** Constructed encap/decap data buffer. */ - uint8_t encap_data[MLX5_ENCAP_MAX_LEN]; - /** Constructed IPv6 routing data buffer. */ - uint8_t ipv6_push_data[MLX5_PUSH_MAX_LEN]; -}; - -/** Container for dynamically generated flow items used during flow rule creation. */ -struct mlx5_flow_hw_pattern_params { - /** Array of dynamically generated flow items. */ - struct rte_flow_item items[MLX5_HW_MAX_ITEMS]; - /** Temporary REPRESENTED_PORT item generated by PMD. */ - struct rte_flow_item_ethdev port_spec; - /** Temporary TAG item generated by PMD. */ - struct rte_flow_item_tag tag_spec; -}; - /* rte flow action translate to DR action struct. */ struct mlx5_action_construct_data { LIST_ENTRY(mlx5_action_construct_data) next; diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 2a9ef71cd8..88d6859bac 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -3978,8 +3978,6 @@ flow_hw_async_flow_create_generic(struct rte_eth_dev *dev, .burst = attr->postpone, }; struct mlx5dr_rule_action *rule_acts; - struct mlx5_flow_hw_action_params ap; - struct mlx5_flow_hw_pattern_params pp; struct rte_flow_hw *flow = NULL; const struct rte_flow_item *rule_items; uint32_t flow_idx = 0; @@ -4035,14 +4033,14 @@ flow_hw_async_flow_create_generic(struct rte_eth_dev *dev, * No need to copy and contrust a new "actions" list based on the * user's input, in order to save the cost. */ - if (flow_hw_actions_construct(dev, flow, &ap, + if (flow_hw_actions_construct(dev, flow, &priv->hw_q[queue].ap, &table->ats[action_template_index], table->its[pattern_template_index]->item_flags, flow->table, actions, rule_acts, queue, error)) goto error; rule_items = flow_hw_get_rule_items(dev, table, items, - pattern_template_index, &pp); + pattern_template_index, &priv->hw_q[queue].pp); if (!rule_items) goto error; if (likely(!rte_flow_template_table_resizable(dev->data->port_id, &table->cfg.attr))) { @@ -4185,7 +4183,6 @@ flow_hw_async_flow_update(struct rte_eth_dev *dev, .burst = attr->postpone, }; struct mlx5dr_rule_action *rule_acts; - struct mlx5_flow_hw_action_params ap; struct rte_flow_hw *of = (struct rte_flow_hw *)flow; struct rte_flow_hw *nf; struct rte_flow_hw_aux *aux; @@ -4236,7 +4233,7 @@ flow_hw_async_flow_update(struct rte_eth_dev *dev, * No need to copy and contrust a new "actions" list based on the * user's input, in order to save the cost. */ - if (flow_hw_actions_construct(dev, nf, &ap, + if (flow_hw_actions_construct(dev, nf, &priv->hw_q[queue].ap, &table->ats[action_template_index], table->its[nf->mt_idx]->item_flags, table, actions, -- 2.39.5