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 2A026A0542 for ; Wed, 5 Oct 2022 18:34:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 24A14427FF; Wed, 5 Oct 2022 18:34:43 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 88A8B42685 for ; Wed, 5 Oct 2022 18:34:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664987681; 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=ZyxMWSPr/lrFaxM1ZhzC3HuxTW5Ih4a8Y4g0lEcAzXk=; b=AMIID/2quVdCKXmAuEmANPeruzLsxIYcD4ZW1rJ8WgD2u7NXhxgtGICiynmAJjEpLsW29o OqDKZX6X9PGij3sd9IfYxpxkz8YNwt+gk90NYd7JTUV4LUCuYUPClIv8gMeYH89UgAFgpc 5JWwIXqzGI7Thjt0su3VykluA6+JoxI= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-465-Pi-p3e11PG-E7Ee1mO9aJQ-1; Wed, 05 Oct 2022 12:34:34 -0400 X-MC-Unique: Pi-p3e11PG-E7Ee1mO9aJQ-1 Received: by mail-pj1-f69.google.com with SMTP id w15-20020a17090a8a0f00b0020afece09efso199539pjn.5 for ; Wed, 05 Oct 2022 09:34:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=ZyxMWSPr/lrFaxM1ZhzC3HuxTW5Ih4a8Y4g0lEcAzXk=; b=LtyT/ClNqz+Fe3J0hi0wuZUtwI4mpScZxvOmzTIQvKsBiSeOtKawPpYyL8eKHoP4on JMeZUmxJd11r0u6P32aqdDCZ+ipRwtuh62Vhx7J8eIOINcNhD2QLBNx6WBuxcBXIvEg/ uOnmWBDsjwn0PS7NUGdLPQxme1iQhHxqL/2T7LPjPaK1bRX0GeynHiMSvp+1e/D1DsIt bCibQMMnpU/Yf7GaGs69EMAbbLyst/bhdbjY9o+LXgb6cCMn3LYcKPpu20Ku3GJKv7ri kDdWQMEibsobf8XGyp6cOMn4hswTcfjee+RkHf/oG49XQRSfCJAgV/IQv0BZrscQ5WdG dABg== X-Gm-Message-State: ACrzQf1Vton0Pb4wGHqm2nASj937Obsf4E/1H+cemtoHovB1FZRspkhZ xZCs4fSBpLSlFg2p++h16H1fe0RvCvOm6zJUOz87t4IL1VKglJCFhJzYXPWLdLZtSiJa8gqBfMk jgyMtCX7PiGfKhsCGJAGdqEI= X-Received: by 2002:a63:5b58:0:b0:452:2ba4:f86b with SMTP id l24-20020a635b58000000b004522ba4f86bmr518523pgm.223.1664987673469; Wed, 05 Oct 2022 09:34:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4HMy/LZZAp5PteBK0MbACH8D6YCNRACsvl89XdM38iTiOWQkyUrV39TQwbr++lHer0cWloZSuEjoMftfMBCEE= X-Received: by 2002:a63:5b58:0:b0:452:2ba4:f86b with SMTP id l24-20020a635b58000000b004522ba4f86bmr518500pgm.223.1664987673155; Wed, 05 Oct 2022 09:34:33 -0700 (PDT) MIME-Version: 1.0 References: <20221005151159.72366-1-maxime.coquelin@redhat.com> In-Reply-To: From: David Marchand Date: Wed, 5 Oct 2022 18:34:18 +0200 Message-ID: Subject: Re: [PATCH v2] vhost: fix compilation issue in async path To: Maxime Coquelin Cc: dev@dpdk.org, cheng1.jiang@intel.com, chenbo.xia@intel.com, zhoumin@loongson.cn, thomas@monjalon.net, stable@dpdk.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Wed, Oct 5, 2022 at 5:36 PM Maxime Coquelin wrote: > On 10/5/22 17:11, Maxime Coquelin wrote: > > This patch fixes a compilation issue met with GCC 12 on > > LoongArch64: > > > > In function =E2=80=98mbuf_to_desc=E2=80=99, > > inlined from =E2=80=98vhost_enqueue_async_packed=E2=80=99 at ../..= /../dpdk/lib/vhost/virtio_net.c:1822:6, > > inlined from =E2=80=98virtio_dev_rx_async_packed=E2=80=99 at ../..= /../dpdk/lib/vhost/virtio_net.c:1836:6, > > inlined from =E2=80=98virtio_dev_rx_async_submit_packed=E2=80=99 a= t ../../../dpdk/lib/vhost/virtio_net.c:1895:7: > > ../../../dpdk/lib/vhost/virtio_net.c:1159:18: error: =E2=80=98buf_vec[0= ].buf_addr=E2=80=99 may be used uninitialized [-Werror=3Dmaybe-uninitialize= d] > > 1159 | buf_addr =3D buf_vec[vec_idx].buf_addr; > > | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ > > ../../../dpdk/lib/vhost/virtio_net.c: In function =E2=80=98virtio_dev_r= x_async_submit_packed=E2=80=99: > > ../../../dpdk/lib/vhost/virtio_net.c:1834:27: note: =E2=80=98buf_vec=E2= =80=99 declared here > > 1834 | struct buf_vector buf_vec[BUF_VECTOR_MAX]; > > | ^~~~~~~ > > > > It happens because the compiler assumes that 'size' > > variable in vhost_enqueue_async_packed could wrap to 0 since > > 'size' is uint32_t and pkt->pkt_len too. > > > > In practice, it would never happen since 'pkt->pkt_len' is > > unlikely to be close to UINT32_MAX, but let's just change > > 'size' to uint64_t to make the compiler happy without > > having to add runtime checks. > > > > Fixes: 873e8dad6f49 ("vhost: support packed ring in async datapath") > > Cc: stable@dpdk.org > > > > Signed-off-by: Maxime Coquelin > > Forgot to report the R-by from David on v1: > Reviewed-by: David Marchand After retesting with other arches, I have an error for cross compiling ARM, on another part of the code. C compiler for the host machine: ccache aarch64-linux-gnu-gcc (gcc 12.0.1 "aarch64-linux-gnu-gcc (GCC) 12.0.1 20220205 (experimental) [master revision f49b8d25b1ff96e9cd09326666cc510b3a3accde]") Same symptom: [251/2797] Compiling C object lib/librte_vhost.a.p/vhost_virtio_net.c.o FAILED: lib/librte_vhost.a.p/vhost_virtio_net.c.o ccache aarch64-linux-gnu-gcc -Ilib/librte_vhost.a.p -Ilib -I../../../git/pub/dpdk.org/main/lib -Ilib/vhost -I../../../git/pub/dpdk.org/main/lib/vhost -I. -I../../../git/pub/dpdk.org/main -Iconfig -I../../../git/pub/dpdk.org/main/config -Ilib/eal/include -I../../../git/pub/dpdk.org/main/lib/eal/include -Ilib/eal/linux/include -I../../../git/pub/dpdk.org/main/lib/eal/linux/include -Ilib/eal/arm/include -I../../../git/pub/dpdk.org/main/lib/eal/arm/include -Ilib/eal/common -I../../../git/pub/dpdk.org/main/lib/eal/common -Ilib/eal -I../../../git/pub/dpdk.org/main/lib/eal -Ilib/kvargs -I../../../git/pub/dpdk.org/main/lib/kvargs -Ilib/metrics -I../../../git/pub/dpdk.org/main/lib/metrics -Ilib/telemetry -I../../../git/pub/dpdk.org/main/lib/telemetry -Ilib/ethdev -I../../../git/pub/dpdk.org/main/lib/ethdev -Ilib/net -I../../../git/pub/dpdk.org/main/lib/net -Ilib/mbuf -I../../../git/pub/dpdk.org/main/lib/mbuf -Ilib/mempool -I../../../git/pub/dpdk.org/main/lib/mempool -Ilib/ring -I../../../git/pub/dpdk.org/main/lib/ring -Ilib/meter -I../../../git/pub/dpdk.org/main/lib/meter -Ilib/cryptodev -I../../../git/pub/dpdk.org/main/lib/cryptodev -Ilib/rcu -I../../../git/pub/dpdk.org/main/lib/rcu -Ilib/hash -I../../../git/pub/dpdk.org/main/lib/hash -Ilib/pci -I../../../git/pub/dpdk.org/main/lib/pci -Ilib/dmadev -I../../../git/pub/dpdk.org/main/lib/dmadev -fdiagnostics-color=3Dalways -D_FILE_OFFSET_BITS=3D64 -Wall -Winvalid-pch -Wextra -Werror -O2 -g -include rte_config.h -Wcast-qual -Wdeprecated -Wformat -Wformat-nonliteral -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wsign-compare -Wstrict-prototypes -Wundef -Wwrite-strings -Wno-address-of-packed-member -Wno-packed-not-aligned -Wno-missing-field-initializers -Wno-zero-length-bounds -D_GNU_SOURCE -fPIC -march=3Darmv8-a+crc -moutline-atomics -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -Wno-format-truncation -DVHOST_GCC_UNROLL_PRAGMA -fno-strict-aliasing -DRTE_LOG_DEFAULT_LOGTYPE=3Dlib.vhost -MD -MQ lib/librte_vhost.a.p/vhost_virtio_net.c.o -MF lib/librte_vhost.a.p/vhost_virtio_net.c.o.d -o lib/librte_vhost.a.p/vhost_virtio_net.c.o -c ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c In function =E2=80=98mbuf_to_desc=E2=80=99, inlined from =E2=80=98vhost_enqueue_single_packed=E2=80=99 at ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c:1321:6, inlined from =E2=80=98virtio_dev_rx_single_packed=E2=80=99 at ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c:1506:6, inlined from =E2=80=98virtio_dev_rx_packed=E2=80=99 at ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c:1540:7: ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c:1159:18: error: =E2=80=98buf_vec[0].buf_addr=E2=80=99 may be used uninitialized [-Werror=3Dmaybe-uninitialized] 1159 | buf_addr =3D buf_vec[vec_idx].buf_addr; | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c: In function =E2=80=98virtio_dev_rx_packed=E2=80=99: ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c:1503:27: note: =E2=80=98buf_vec=E2=80=99 declared here 1503 | struct buf_vector buf_vec[BUF_VECTOR_MAX]; | ^~~~~~~ In function =E2=80=98mbuf_to_desc=E2=80=99, inlined from =E2=80=98vhost_enqueue_single_packed=E2=80=99 at ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c:1321:6, inlined from =E2=80=98virtio_dev_rx_single_packed=E2=80=99 at ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c:1506:6, inlined from =E2=80=98virtio_dev_rx_packed=E2=80=99 at ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c:1540:7: ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c:1160:18: error: =E2=80=98buf_vec[0].buf_iova=E2=80=99 may be used uninitialized [-Werror=3Dmaybe-uninitialized] 1160 | buf_iova =3D buf_vec[vec_idx].buf_iova; | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c: In function =E2=80=98virtio_dev_rx_packed=E2=80=99: ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c:1503:27: note: =E2=80=98buf_vec=E2=80=99 declared here 1503 | struct buf_vector buf_vec[BUF_VECTOR_MAX]; | ^~~~~~~ In function =E2=80=98mbuf_to_desc=E2=80=99, inlined from =E2=80=98vhost_enqueue_single_packed=E2=80=99 at ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c:1321:6, inlined from =E2=80=98virtio_dev_rx_single_packed=E2=80=99 at ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c:1506:6, inlined from =E2=80=98virtio_dev_rx_packed=E2=80=99 at ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c:1540:7: ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c:1161:35: error: =E2=80=98buf_vec[0].buf_len=E2=80=99 may be used uninitialized [-Werror=3Dmaybe-uninitialized] 1161 | buf_len =3D buf_vec[vec_idx].buf_len; | ~~~~~~~~~~~~~~~~^~~~~~~~ ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c: In function =E2=80=98virtio_dev_rx_packed=E2=80=99: ../../../git/pub/dpdk.org/main/lib/vhost/virtio_net.c:1503:27: note: =E2=80=98buf_vec=E2=80=99 declared here 1503 | struct buf_vector buf_vec[BUF_VECTOR_MAX]; | ^~~~~~~ cc1: all warnings being treated as errors And same fix: @@ -1277,7 +1277,7 @@ vhost_enqueue_single_packed(struct virtio_net *dev, uint16_t buf_id =3D 0; uint32_t len =3D 0; uint16_t desc_count; - uint32_t size =3D pkt->pkt_len + sizeof(struct virtio_net_hdr_mrg_r= xbuf); + uint64_t size =3D pkt->pkt_len + sizeof(struct virtio_net_hdr_mrg_r= xbuf); uint16_t num_buffers =3D 0; uint32_t buffer_len[vq->size]; uint16_t buffer_buf_id[vq->size]; I suspect we may need some code inspection. I see two other locations with the same pattern. --=20 David Marchand