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 D589945D0B; Fri, 15 Nov 2024 07:09:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3F64942F89; Fri, 15 Nov 2024 07:08:53 +0100 (CET) Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by mails.dpdk.org (Postfix) with ESMTP id 476CC42F69 for ; Fri, 15 Nov 2024 07:08:49 +0100 (CET) Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-7e6cbf6cd1dso942708a12.3 for ; Thu, 14 Nov 2024 22:08:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731650928; x=1732255728; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jPbB6rJLwxI/soDyVlG5LUGuY4dYc9UldMkkJvFjHdg=; b=k66791RDZYPVH3VMNU95kil3Gi8vwBWUKUsfVFs/oSWDUykaoteiv4liBGuQVjmgGX +4b+Tvq5lWd/LcGEojURB2oWzuPrCkgfWYmgdbKb5oAfBXGltP9twUdRkyDfNvsxiyh+ 58FqyrJNoFc8w+6PpycRJKU2qLrujKlNr3gYH+wEVYAOIuhQrp3atDNV7lQtgFpNQ6ty bY3vGBIm93kQPXVc08D8OwyyNDJB4V1QXu3slXvW1WOnon+WtU7BqPBljnHShu3zGuqH vBRRc7pKkwjcMV8D0LpvbzdeVGBskjsRvPVn+qVBULu+VmLLatXp/48AdK8Bjhg2ioGa LooA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731650928; x=1732255728; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jPbB6rJLwxI/soDyVlG5LUGuY4dYc9UldMkkJvFjHdg=; b=QwZA+8sYNAaAmTLzP7h6h+0JU33scmnRZNeogpmZ5osrjc+DD+FLwk6RtVU2RvzZAN uZGu69hqK6nK88VBBFJrJ7NWY0dMV/6v4qhK0GaB9G+8YE061IMs19tE0k37JKJKWi+o N9ezgpSK37509o5MTPYoaaabFUllopR4NxTUYH4tKwQxXRlIENK3Kyb0VKZhWBp+SppQ 7T3u83NpYCdVCmjJcElc8xK4iTSRlAwQLitu5uaALcEL2evSe4Zb8fRCh8yOSYxdLQtW tApoNE37Br4hw5+FQRnqvKptgdOEhHn6QLptgIGBAozTql7arXUi/xuPiP+GJAYKLnKg W46Q== X-Gm-Message-State: AOJu0YxZST6pHNyr/QnpzA4VzjcxB/jvA3fp3dvAqNAF2sCWQj4SYQCB ESJdboR4g21z1u6B4NYqV/DX6AaOmE+94v8F7SS0H22blLvPtAT70e1AaxoJ1mBuBWj1sdQJw+S t X-Google-Smtp-Source: AGHT+IFFk1z/mfi24Ayja4R3+eJJlQT0dBa5vcPTxl08wbakOlf8C0YYMvN+CeKlvxlvoMSIoqpLTg== X-Received: by 2002:a05:6300:808b:b0:1d9:fbc:457c with SMTP id adf61e73a8af0-1dc90be897amr1465525637.36.1731650928462; Thu, 14 Nov 2024 22:08:48 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ea06f4856esm2123781a91.23.2024.11.14.22.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2024 22:08:47 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , nipun.gupta@nxp.com, stable@dpdk.org, Hemant Agrawal , Sachin Saxena , Nipun Gupta Subject: [PATCH 16/16] net/dpaa2: fix bitmask truncation Date: Thu, 14 Nov 2024 22:05:53 -0800 Message-ID: <20241115060738.313190-17-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241115060738.313190-1-stephen@networkplumber.org> References: <20241115060738.313190-1-stephen@networkplumber.org> 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 The dqrr_held mask is 64 bit but updates were getting truncated because 1 is of type int (32 bit) and the result shift of int is of type int (32 bit); therefore any value >= 32 would get truncated. Link: https://pvs-studio.com/en/blog/posts/cpp/1183/ Fixes: 2d3788631862 ("net/dpaa2: support atomic queues") Cc: nipun.gupta@nxp.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/net/dpaa2/dpaa2_rxtx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_rxtx.c b/drivers/net/dpaa2/dpaa2_rxtx.c index e3b6c7e460..e253bccecd 100644 --- a/drivers/net/dpaa2/dpaa2_rxtx.c +++ b/drivers/net/dpaa2/dpaa2_rxtx.c @@ -933,7 +933,7 @@ dpaa2_dev_process_atomic_event(struct qbman_swp *swp __rte_unused, dqrr_index = qbman_get_dqrr_idx(dq); *dpaa2_seqn(ev->mbuf) = dqrr_index + 1; DPAA2_PER_LCORE_DQRR_SIZE++; - DPAA2_PER_LCORE_DQRR_HELD |= 1 << dqrr_index; + DPAA2_PER_LCORE_DQRR_HELD |= UINT64_C(1) << dqrr_index; DPAA2_PER_LCORE_DQRR_MBUF(dqrr_index) = ev->mbuf; } @@ -1317,7 +1317,7 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) flags[loop] = QBMAN_ENQUEUE_FLAG_DCA | dqrr_index; DPAA2_PER_LCORE_DQRR_SIZE--; - DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dqrr_index); + DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C(1) << dqrr_index); *dpaa2_seqn(*bufs) = DPAA2_INVALID_MBUF_SEQN; } @@ -1575,7 +1575,7 @@ dpaa2_set_enqueue_descriptor(struct dpaa2_queue *dpaa2_q, dq_idx = *dpaa2_seqn(m) - 1; qbman_eq_desc_set_dca(eqdesc, 1, dq_idx, 0); DPAA2_PER_LCORE_DQRR_SIZE--; - DPAA2_PER_LCORE_DQRR_HELD &= ~(1 << dq_idx); + DPAA2_PER_LCORE_DQRR_HELD &= ~(UINT64_C(1) << dq_idx); } *dpaa2_seqn(m) = DPAA2_INVALID_MBUF_SEQN; } -- 2.45.2