patch 'vhost: fix build with GCC 13' has been queued to stable release 21.11.8
Kevin Traynor
ktraynor at redhat.com
Fri Aug 23 18:17:42 CEST 2024
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/2f6234f1d916d6244a26249c929b5aee0b136751
Thanks.
Kevin
---
>From 2f6234f1d916d6244a26249c929b5aee0b136751 Mon Sep 17 00:00:00 2001
From: Luca Vizzarro <luca.vizzarro at arm.com>
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;
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
<snip>
../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;
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
<snip>
../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 <luca.vizzarro at arm.com>
Reviewed-by: Paul Szczepanek <paul.szczepanek at arm.com>
Reviewed-by: Nick Connolly <nick.connolly at arm.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
.mailmap | 2 +-
lib/vhost/virtio_net.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.mailmap b/.mailmap
index ed9ed73919..41d1bdb972 100644
--- a/.mailmap
+++ b/.mailmap
@@ -985,5 +985,5 @@ Netanel Belgazal <netanel at amazon.com>
Netanel Gonen <netanelg at mellanox.com>
Niall Power <niall.power at intel.com>
-Nick Connolly <nick.connolly at mayadata.io>
+Nick Connolly <nick.connolly at arm.com> <nick.connolly at mayadata.io>
Nick Nunley <nicholas.d.nunley at intel.com>
Niclas Storm <niclas.storm at ericsson.com>
diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
index fa0779d03d..9f74a3c997 100644
--- a/lib/vhost/virtio_net.c
+++ b/lib/vhost/virtio_net.c
@@ -1592,5 +1592,5 @@ vhost_enqueue_async_packed(struct virtio_net *dev,
max_tries = 1;
- while (size > 0) {
+ do {
/*
* if we tried all available ring items, and still
@@ -1619,5 +1619,5 @@ vhost_enqueue_async_packed(struct virtio_net *dev,
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))
--
2.46.0
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2024-08-23 17:18:10.968779446 +0100
+++ 0034-vhost-fix-build-with-GCC-13.patch 2024-08-23 17:18:09.671429934 +0100
@@ -1 +1 @@
-From 8db1acabeea3fa4b0c673588cfff2b01e0ae9615 Mon Sep 17 00:00:00 2001
+From 2f6234f1d916d6244a26249c929b5aee0b136751 Mon Sep 17 00:00:00 2001
@@ -8,0 +9,2 @@
+[ upstream commit 8db1acabeea3fa4b0c673588cfff2b01e0ae9615 ]
+
@@ -55 +56,0 @@
-Cc: stable at dpdk.org
@@ -67 +68 @@
-index 111dbb0ac3..ed63605a15 100644
+index ed9ed73919..41d1bdb972 100644
@@ -70 +71,2 @@
-@@ -1031,5 +1031,5 @@ Netanel Gonen <netanelg at mellanox.com>
+@@ -985,5 +985,5 @@ Netanel Belgazal <netanel at amazon.com>
+ Netanel Gonen <netanelg at mellanox.com>
@@ -72 +73,0 @@
- Nicholas Pratte <npratte at iol.unh.edu>
@@ -78 +79 @@
-index b406b5d7d9..370402d849 100644
+index fa0779d03d..9f74a3c997 100644
@@ -81 +82 @@
-@@ -1936,5 +1936,5 @@ vhost_enqueue_async_packed(struct virtio_net *dev,
+@@ -1592,5 +1592,5 @@ vhost_enqueue_async_packed(struct virtio_net *dev,
@@ -88 +89 @@
-@@ -1963,5 +1963,5 @@ vhost_enqueue_async_packed(struct virtio_net *dev,
+@@ -1619,5 +1619,5 @@ vhost_enqueue_async_packed(struct virtio_net *dev,
More information about the stable
mailing list