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 3957145804 for ; Fri, 23 Aug 2024 18:23:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3400C4336F; Fri, 23 Aug 2024 18:23:59 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 3ACB44336D for ; Fri, 23 Aug 2024 18:23:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724430236; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uSB5v3y0K4OZtc8vDSbP2F3QNwppef0uMOPAQY6dYqs=; b=Ns5iXjHZ1R7u7gSb0vFhTjnhRRdwkFKlx8rjUWosj/WC+QCHgnRtVjPkgN5hOab9t1AT5y ZIbWM8SAY4ZWwYLkvGA/L50YhI0oVtyzguTOpbaz2kRk+DvqrUAAVZOBmRkT1x7+KkkNu0 zbKY+GZxS//cDiUdXcKSZLPhCY4EeW8= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-286-wx6nok6VPRyaIosQ5sVr6g-1; Fri, 23 Aug 2024 12:23:53 -0400 X-MC-Unique: wx6nok6VPRyaIosQ5sVr6g-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 88E1D195608A; Fri, 23 Aug 2024 16:23:52 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.193.224]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 230451956053; Fri, 23 Aug 2024 16:23:50 +0000 (UTC) From: Kevin Traynor To: Ed Czeck Cc: Ferruh Yigit , dpdk stable Subject: patch 'net/ark: fix index arithmetic' has been queued to stable release 21.11.8 Date: Fri, 23 Aug 2024 17:19:11 +0100 Message-ID: <20240823161929.1004778-123-ktraynor@redhat.com> In-Reply-To: <20240823161929.1004778-1-ktraynor@redhat.com> References: <20240823161929.1004778-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 21.11.8 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 08/28/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/356b9ccb045b876814d3775342a12acd7958c0a8 Thanks. Kevin --- >From 356b9ccb045b876814d3775342a12acd7958c0a8 Mon Sep 17 00:00:00 2001 From: Ed Czeck Date: Wed, 17 Jul 2024 16:38:30 -0400 Subject: [PATCH] net/ark: fix index arithmetic [ upstream commit 73c0e26c8ed9f59f867ff251fbb2a50c8dfa06c5 ] Behavior for signed integer overflow is not defined which can causes undesired behavior at values near max and min bounds. The used of unsigned is defined as to use modulo arithmetic which is the desired behavior. This patch replaces int32_t with uint32_t except for necessary casts. Fixes: 9ee9e0d3b85e ("net/ark: update to reflect FPGA updates") Signed-off-by: Ed Czeck Acked-by: Ferruh Yigit --- drivers/net/ark/ark_ethdev_tx.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/net/ark/ark_ethdev_tx.c b/drivers/net/ark/ark_ethdev_tx.c index 676e4115d3..09147173ba 100644 --- a/drivers/net/ark/ark_ethdev_tx.c +++ b/drivers/net/ark/ark_ethdev_tx.c @@ -40,6 +40,6 @@ struct ark_tx_queue { /* 3 indexes to the paired data rings. */ - int32_t prod_index; /* where to put the next one */ - int32_t free_index; /* mbuf has been freed */ + uint32_t prod_index; /* where to put the next one */ + uint32_t free_index; /* mbuf has been freed */ /* The queue Id is used to identify the HW Q */ @@ -50,5 +50,5 @@ struct ark_tx_queue { /* next cache line - fields written by device */ RTE_MARKER cacheline1 __rte_cache_min_aligned; - volatile int32_t cons_index; /* hw is done, can be freed */ + volatile uint32_t cons_index; /* hw is done, can be freed */ } __rte_cache_aligned; @@ -124,5 +124,5 @@ eth_ark_xmit_pkts(void *vtxq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) int stat; - int32_t prod_index_limit; + uint32_t prod_index_limit; uint16_t nb; uint8_t user_len = 0; @@ -139,6 +139,11 @@ eth_ark_xmit_pkts(void *vtxq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) prod_index_limit = queue->queue_size + queue->free_index - 4; + /* Populate the buffer bringing prod_index up to or slightly beyond + * prod_index_limit. Prod_index will increment by 2 or more each + * iteration. Note: indexes are uint32_t, cast to (signed) int32_t + * to catch the slight overage case; e.g. (200 - 201) + */ for (nb = 0; - (nb < nb_pkts) && (prod_index_limit - queue->prod_index) > 0; + (nb < nb_pkts) && (int32_t)(prod_index_limit - queue->prod_index) > 0; ++nb) { mbuf = tx_pkts[nb]; @@ -210,5 +215,5 @@ eth_ark_tx_jumbo(struct ark_tx_queue *queue, struct rte_mbuf *mbuf, { struct rte_mbuf *next; - int32_t free_queue_space; + uint32_t free_queue_space; uint8_t flags = ARK_DDM_SOP; @@ -216,5 +221,5 @@ eth_ark_tx_jumbo(struct ark_tx_queue *queue, struct rte_mbuf *mbuf, (queue->prod_index - queue->free_index); /* We need up to 4 mbufs for first header and 2 for subsequent ones */ - if (unlikely(free_queue_space < (2 + (2 * mbuf->nb_segs)))) + if (unlikely(free_queue_space < (2U + (2U * mbuf->nb_segs)))) return -1; @@ -425,8 +430,9 @@ free_completed_tx(struct ark_tx_queue *queue) struct rte_mbuf *mbuf; union ark_tx_meta *meta; - int32_t top_index; + uint32_t top_index; top_index = queue->cons_index; /* read once */ - while ((top_index - queue->free_index) > 0) { + + while ((int32_t)(top_index - queue->free_index) > 0) { meta = &queue->meta_q[queue->free_index & queue->queue_mask]; if (likely((meta->flags & ARK_DDM_SOP) != 0)) { -- 2.46.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-08-23 17:18:13.413667259 +0100 +++ 0123-net-ark-fix-index-arithmetic.patch 2024-08-23 17:18:09.886430685 +0100 @@ -1 +1 @@ -From 73c0e26c8ed9f59f867ff251fbb2a50c8dfa06c5 Mon Sep 17 00:00:00 2001 +From 356b9ccb045b876814d3775342a12acd7958c0a8 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 73c0e26c8ed9f59f867ff251fbb2a50c8dfa06c5 ] + @@ -13 +14,0 @@ -Cc: stable@dpdk.org @@ -22 +23 @@ -index 9c89c85f50..ca6cd297a1 100644 +index 676e4115d3..09147173ba 100644 @@ -25 +26 @@ -@@ -40,6 +40,6 @@ struct __rte_cache_aligned ark_tx_queue { +@@ -40,6 +40,6 @@ struct ark_tx_queue { @@ -34 +35 @@ -@@ -50,5 +50,5 @@ struct __rte_cache_aligned ark_tx_queue { +@@ -50,5 +50,5 @@ struct ark_tx_queue { @@ -36 +37 @@ - alignas(RTE_CACHE_LINE_MIN_SIZE) RTE_MARKER cacheline1; + RTE_MARKER cacheline1 __rte_cache_min_aligned; @@ -39 +40 @@ - }; + } __rte_cache_aligned; @@ -41 +42 @@ -@@ -109,5 +109,5 @@ eth_ark_xmit_pkts(void *vtxq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) +@@ -124,5 +124,5 @@ eth_ark_xmit_pkts(void *vtxq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) @@ -48 +49 @@ -@@ -124,6 +124,11 @@ eth_ark_xmit_pkts(void *vtxq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) +@@ -139,6 +139,11 @@ eth_ark_xmit_pkts(void *vtxq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) @@ -61 +62 @@ -@@ -195,5 +200,5 @@ eth_ark_tx_jumbo(struct ark_tx_queue *queue, struct rte_mbuf *mbuf, +@@ -210,5 +215,5 @@ eth_ark_tx_jumbo(struct ark_tx_queue *queue, struct rte_mbuf *mbuf, @@ -68 +69 @@ -@@ -201,5 +206,5 @@ eth_ark_tx_jumbo(struct ark_tx_queue *queue, struct rte_mbuf *mbuf, +@@ -216,5 +221,5 @@ eth_ark_tx_jumbo(struct ark_tx_queue *queue, struct rte_mbuf *mbuf, @@ -75 +76 @@ -@@ -393,8 +398,9 @@ free_completed_tx(struct ark_tx_queue *queue) +@@ -425,8 +430,9 @@ free_completed_tx(struct ark_tx_queue *queue)