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 9C436454E9 for ; Tue, 25 Jun 2024 02:01:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 94C05410DC; Tue, 25 Jun 2024 02:01:33 +0200 (CEST) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mails.dpdk.org (Postfix) with ESMTP id 6790D40EDD for ; Tue, 25 Jun 2024 02:01:32 +0200 (CEST) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-421f4d1c057so40370915e9.3 for ; Mon, 24 Jun 2024 17:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719273692; x=1719878492; 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=yg690lLRtkDhVwrBH5kFbhaSG0XYnhGe4je92wSYuMs=; b=EMA6sn6wyuAo0QPvZZMSbATC3ETdn+3Ab9AzoxmZ0kuUC1cbzrtRaqmypxxEBEsBna pte2tH0SpGepwYlVJxCKE6SZL+cjFx7uvO3dqMI/Lz33DjTFrtwxIYEcvjv5wa4RgK7d ossLV50SwB/l3lwleHOAzvBnDM4gxaVqaaZZiKlKeJ2yiYQRqgEM3GhXutJECIxNQfMs llnhVMcV4EOwJO2w7HB84z62F4NtTkMynr0BBvAqHbrikEu8LO95g77IQajWjm1r6cvW 2C3cGKd2Po+1PF55mUDPJLqfApkHXDlrR0qoLO0iXKcg9aG6mfTAlrHbNPW5bEkcfU7E iaIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719273692; x=1719878492; 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=yg690lLRtkDhVwrBH5kFbhaSG0XYnhGe4je92wSYuMs=; b=XGQ1fJCwOPrc9gZmBwDv42lSq3raCX9c8AsOB884ESvbgPsWNKnyUG8kG4MU69+w4m XjoYPBHsCuovry5MPEB8hxpVs3Xu2YRYZnbb3/kODroZQ406hzDDR2IvgkYHPAg0TLGn F+GctYOgBpV4DMZFg53q3fLqWMhTslp2HiNXRMQ+dSCh4RqTlu8ic1nL+nXe2B1xjMOa Wm2i1GiyiaJiKNIxtfDGf9QP3kTS4ERFdg++2c3G1R2KwclKZb3aXqQjXd0Y2AeEVSzE qsSMBxiY5ck55ggizdpGwNI+MTgjZtwCgNXoiGguBeZffbRHXcFgI+OHhAx3PUrq9mG0 y6yw== X-Forwarded-Encrypted: i=1; AJvYcCVG2pSgnNRAcB6qzF94m+Cc8OjikP5WnuFuSYqhM7/aDJFcZk889165tV38H3C2EgktiXbNCDKNAj1e294y/yM= X-Gm-Message-State: AOJu0YznKNZWKAH7Ur7fcvqL+kvFUrQ0Xx8SZbUWuQQCn7jPnAzb9B/N 2kbrSInuYbogJRDfN7lu/I3jfChniu+hW5/ljx+QJGhUi3mYjZTR X-Google-Smtp-Source: AGHT+IH8tqfnRQqa4U7El8hqQgj7DH9H2TEx+4wbP4Y1/gg0oULNryupHk1/UdIjPn5ivD/zbt+xIg== X-Received: by 2002:a7b:cbd4:0:b0:424:7e0f:df51 with SMTP id 5b1f17b1804b1-4248b9f0b3fmr43484895e9.33.1719273691939; Mon, 24 Jun 2024 17:01:31 -0700 (PDT) Received: from localhost ([137.220.120.171]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424819224d9sm157458345e9.45.2024.06.24.17.01.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 17:01:31 -0700 (PDT) From: luca.boccassi@gmail.com To: Luca Vizzarro Cc: Paul Szczepanek , Nick Connolly , Maxime Coquelin , dpdk stable Subject: patch 'vhost: fix build with GCC 13' has been queued to stable release 22.11.6 Date: Tue, 25 Jun 2024 00:58:30 +0100 Message-Id: <20240624235907.885628-44-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240624235907.885628-1-luca.boccassi@gmail.com> References: <20240624235907.885628-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 22.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 06/27/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/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/6267610fffce83f71ac52256964bb737b1d6400c Thanks. Luca Boccassi --- >From 6267610fffce83f71ac52256964bb737b1d6400c Mon Sep 17 00:00:00 2001 From: Luca Vizzarro Date: Wed, 10 Apr 2024 16:21:01 +0100 Subject: [PATCH] vhost: fix build with GCC 13 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ upstream commit 8db1acabeea3fa4b0c673588cfff2b01e0ae9615 ] This patch resolves a build error with GCC 13 and arm/aarch32 as targets: In function ‘mbuf_to_desc’, inlined from ‘vhost_enqueue_async_packed’ at ../lib/vhost/virtio_net.c:1828:6, inlined from ‘virtio_dev_rx_async_packed’ at ../lib/vhost/virtio_net.c:1842:6, inlined from ‘virtio_dev_rx_async_submit_packed’ at ../lib/vhost/virtio_net.c:1900:7: ../lib/vhost/virtio_net.c:1159:18: error: ‘buf_vec[0].buf_addr’ may be used uninitialized [-Werror=maybe-uninitialized] 1159 | buf_addr = buf_vec[vec_idx].buf_addr; | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ ../lib/vhost/virtio_net.c:1160:18: error: ‘buf_vec[0].buf_iova’ may be used uninitialized [-Werror=maybe-uninitialized] 1160 | buf_iova = buf_vec[vec_idx].buf_iova; | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ ../lib/vhost/virtio_net.c:1161:35: error: ‘buf_vec[0].buf_len’ may be used uninitialized [-Werror=maybe-uninitialized] 1161 | buf_len = buf_vec[vec_idx].buf_len; | ~~~~~~~~~~~~~~~~^~~~~~~~ GCC complains about the possible runtime path where the while loop which fills buf_vec (in vhost_enqueue_async_packed) is not run. As a consequence it correctly thinks that buf_vec is not initialized while being accessed anyways. This scenario is actually very unlikely as the only way this can occur is if size has overflowed to 0. Meaning that the total packet length would be close to UINT64_MAX (or actually UINT32_MAX). At first glance, the code suggests that this may never happen as the type of size has been changed to 64-bit. For a 32-bit architecture such as arm (e.g. armv7-a) and aarch32, this still happens because the operand types (pkt->pkt_len and sizeof) are 32-bit wide, performing 32-bit arithmetic first (where the overflow can happen) and widening to 64-bit later. The proposed fix simply guarantees to the compiler that the scope which fills buf_vec is accessed at least once, while not disrupting the actual logic. This is based on the assumption that size will always be greater than 0, as suggested by the sizeof, and the packet length will never be as big as UINT32_MAX, and causing an overflow. Fixes: 873e8dad6f49 ("vhost: support packed ring in async datapath") Signed-off-by: Luca Vizzarro Reviewed-by: Paul Szczepanek Reviewed-by: Nick Connolly Reviewed-by: Maxime Coquelin --- .mailmap | 2 +- lib/vhost/virtio_net.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.mailmap b/.mailmap index 7e7c1a75cb..1c0d974460 100644 --- a/.mailmap +++ b/.mailmap @@ -983,7 +983,7 @@ Nemanja Marjanovic Netanel Belgazal Netanel Gonen Niall Power -Nick Connolly +Nick Connolly Nick Nunley Niclas Storm Nicolas Chautru diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c index 3061275753..9f314f83c7 100644 --- a/lib/vhost/virtio_net.c +++ b/lib/vhost/virtio_net.c @@ -1796,7 +1796,7 @@ vhost_enqueue_async_packed(struct virtio_net *dev, else max_tries = 1; - while (size > 0) { + do { /* * if we tried all available ring items, and still * can't get enough buf, it means something abnormal @@ -1823,7 +1823,7 @@ vhost_enqueue_async_packed(struct virtio_net *dev, avail_idx += desc_count; if (avail_idx >= vq->size) avail_idx -= vq->size; - } + } while (size > 0); if (unlikely(mbuf_to_desc(dev, vq, pkt, buf_vec, nr_vec, *nr_buffers, true) < 0)) return -1; -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-06-25 00:22:16.195109621 +0100 +++ 0044-vhost-fix-build-with-GCC-13.patch 2024-06-25 00:22:13.169185323 +0100 @@ -1 +1 @@ -From 8db1acabeea3fa4b0c673588cfff2b01e0ae9615 Mon Sep 17 00:00:00 2001 +From 6267610fffce83f71ac52256964bb737b1d6400c Mon Sep 17 00:00:00 2001 @@ -8,0 +9,2 @@ +[ upstream commit 8db1acabeea3fa4b0c673588cfff2b01e0ae9615 ] + @@ -55 +56,0 @@ -Cc: stable@dpdk.org @@ -67 +68 @@ -index 111dbb0ac3..ed63605a15 100644 +index 7e7c1a75cb..1c0d974460 100644 @@ -70 +71,2 @@ -@@ -1030,7 +1030,7 @@ Netanel Belgazal +@@ -983,7 +983,7 @@ Nemanja Marjanovic + Netanel Belgazal @@ -73 +74,0 @@ - Nicholas Pratte @@ -80 +81 @@ -index b406b5d7d9..370402d849 100644 +index 3061275753..9f314f83c7 100644 @@ -83 +84 @@ -@@ -1935,7 +1935,7 @@ vhost_enqueue_async_packed(struct virtio_net *dev, +@@ -1796,7 +1796,7 @@ vhost_enqueue_async_packed(struct virtio_net *dev, @@ -92 +93 @@ -@@ -1962,7 +1962,7 @@ vhost_enqueue_async_packed(struct virtio_net *dev, +@@ -1823,7 +1823,7 @@ vhost_enqueue_async_packed(struct virtio_net *dev,