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 C898645CD8; Mon, 18 Nov 2024 19:23:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 06B9942E90; Mon, 18 Nov 2024 19:22:26 +0100 (CET) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by mails.dpdk.org (Postfix) with ESMTP id AF96C4281D for ; Mon, 18 Nov 2024 19:22:16 +0100 (CET) Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2ea68cd5780so1139010a91.3 for ; Mon, 18 Nov 2024 10:22:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731954136; x=1732558936; 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=FetX8cMsVU6thAoFJcY6uUwz4bEBTm7UUsySyb6wHvk=; b=X9ScUcKpnGWCGctQCCI7tmU/TkSIOeTuyj9V2A/v2eHaqVi1LEeui0PsHeoSFTWE9k Y9M/i/Ml9Wr+JHD6P8HJMv8LHufXj0TRTQs0KpdjKQ/L/NF6OeD+9PNHncSOogl04JU1 2F8fXSPJH/ESdBRJVpybNXN22bgIDrCPOxxqiRNyTVJFmITBvE4oLZRA6KZqHWteJHQM cPbrf3MT9ELE01YylB8TGIcg4MdnBFA75o32/F14kbxRsR/Tdxs6CLA3teKFUTWaTPyq 4iEIFz1FZarKlcS63G2/HXqCNFstzOW/AqTtYc1EcsfHwg9/pKUqIHNGRrWuWQY2FIeF JIMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731954136; x=1732558936; 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=FetX8cMsVU6thAoFJcY6uUwz4bEBTm7UUsySyb6wHvk=; b=G+0Yfp2efndFx3YwB1DNL6l0GimZh/3m03r7yMQ1YwxF0iNdM6YXyGKjjEm9srb1Ot NIAkE1grTdEfN8QmeY36je+RT9YO5qHAZQU1dBbgCzU5LFeUAL2foEgVugdAAo4ka7fU 0Eojlg+PEFu63YnOkDoKkMw2QewEHMxzinwGaJGZVnwukB9UBNJkl6MZmScTTa0pccea batKB/4Wsw0SiLjCfg3afGQF0cYvEwqry4XH8dsKDGU7rjVM5T42h5VOxcxgIThUqdEv 4gZRvkmV0eGGyhLE3/cB2G/m0YJVRCaUTG0uLSmn1UQw+C17FUa0baXU1luZhqHDBkgs lYlw== X-Gm-Message-State: AOJu0YxXFkcenUcqVf0lcyS5Ft2tuOuPGTlJqu+GaM8QnwdkYHgQg+WW akIQc4TrQ9znvWf4b3BPOtPaczJ87BgMp5VZinHVYIfZKxGw0axPMhL7XvJ/iXT3IrHozSwIEqv 4 X-Google-Smtp-Source: AGHT+IHhIizpSMRuy07r4IEBI0RRPTnhVsOY8EPXIkvGr6e9+XbXSwLCoUBFztDfgjRlr6dUe5ngQQ== X-Received: by 2002:a17:90b:3e85:b0:2ea:9bc3:7ead with SMTP id 98e67ed59e1d1-2ea9bc3837bmr2087224a91.18.1731954135938; Mon, 18 Nov 2024 10:22:15 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ea61869bb2sm2916724a91.12.2024.11.18.10.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2024 10:22:15 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , nipun.gupta@nxp.com, stable@dpdk.org, Hemant Agrawal Subject: [PATCH v2 16/19] net/dpaa2: fix bitmask truncation Date: Mon, 18 Nov 2024 10:20:57 -0800 Message-ID: <20241118182153.87042-17-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241118182153.87042-1-stephen@networkplumber.org> References: <20241115060738.313190-1-stephen@networkplumber.org> <20241118182153.87042-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 Acked-by: Hemant Agrawal --- 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