From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 51CACA046B for ; Mon, 24 Jun 2019 14:16:56 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7E6C61BEC8; Mon, 24 Jun 2019 14:16:54 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id 8996D1BE5F; Mon, 24 Jun 2019 14:16:53 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us2.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 09D363400AA; Mon, 24 Jun 2019 12:16:51 +0000 (UTC) Received: from [192.168.38.17] (91.220.146.112) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 24 Jun 2019 13:16:45 +0100 To: "Ananyev, Konstantin" , Ivan Malov , Olivier Matz CC: "dev@dpdk.org" , "Kulasek, TomaszX" , "stable@dpdk.org" References: <20190529173337.31157-1-ivan.malov@oktetlabs.ru> <2601191342CEEE43887BDE71AB97725801689E3F36@IRSMSX104.ger.corp.intel.com> From: Andrew Rybchenko Message-ID: Date: Mon, 24 Jun 2019 15:16:41 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: <2601191342CEEE43887BDE71AB97725801689E3F36@IRSMSX104.ger.corp.intel.com> Content-Language: en-GB X-Originating-IP: [91.220.146.112] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ukex01.SolarFlarecom.com (10.17.10.4) X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24708.003 X-TM-AS-Result: No-23.156000-8.000000-10 X-TMASE-MatchedRID: /77LoUQXvQ9xoTdUZcCiFPZvT2zYoYOwt3aeg7g/usAutoY2UtFqGE4a fTHuzVFfl8V6ZKEJA0+TH1CW/TkdqqX7JaGNhSXtAZ0lncqeHqFxR6rIK7qIWasoAw12Y1UT7Be h9xYLMx5I1QgwW8thwd46dDnRgVrAb9we5T8mWkzxWp8B+pjaLBpxmKWTfsQIUHcBn70iJQei5p cT+t5JmVuaa7S4XvX11Q1cikrSnkbys+NfDoX1KLwfXVYjoVWNzVE3gQTykCrsvb7MYS5s3hQsE kt6gTBx7JbRgmgy0l6qvQrjP8O+uiHhSBQfglfsA9lly13c/gHmTPEuA2FKKUdPzlcG3i6rDhYj fgV723PyaxIfJlHWeus/R8F1ytlNUnIaLQxicB+8l09dlf9jm0kQGNGmCuF47a71bENFnTNWZu+ LmJooCleKAPivBsEKeNTW3/0OSYK095XvZRQZT4dlc1JaOB1TZ/rAPfrtWC0fVuGrjP7J9HZQrr FTqfg/4fc7vL8MhEvhhLoXIby/KBWVVkGuW6JrIj0zFI5DoJKCQxfA+iO7F6zG9MIKeG/Ghf3lQ uFtLYCbuQcHZubU2u3OpvA0OqzcA6LoO88aPa9mNCKOCsW/OivnqYJI3/w7Oyxd6V963VS48WuR FQVdauLzNWBegCW2RYvisGWbbS+3sNbcHjySQTsAVzN+Ov/sg1r58HUaZsqibqGRoyrro7x9yHK PnRlqMsocHMzFNupulb4OT6B7ug== X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--23.156000-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24708.003 X-MDID: 1561378612-kw16pJ0ye-aN Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH] net: fix the way how L4 checksum choice is tested X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 6/24/19 3:01 PM, Ananyev, Konstantin wrote: > >> -----Original Message----- >> From: Ananyev, Konstantin >> Sent: Monday, June 24, 2019 12:52 PM >> To: 'Ivan Malov' ; Olivier Matz >> Cc: dev@dpdk.org; Kulasek, TomaszX ; stable@dpdk.org >> Subject: RE: [dpdk-dev] [PATCH] net: fix the way how L4 checksum choice is tested >> >> >>> The API to prepare checksum offloads mistreats L4 >>> checksum type enum values as self-contained flags. >>> >>> Turning these flag checks into enum checks causes >>> warnings by GCC about possibly uninitialised IPv4 >>> header pointer. The issue was found to show up in >>> the case of GCC versions 4.8.5 and 5.4.0, however, >>> it might be the case for a wider variety of other >>> versions. As GCC version 7.4.0 is not susceptible >>> to the said false positive assessment, this patch >>> maintains a compiler barrier for earlier versions. >>> >>> Fixes: 4fb7e803eb1a ("ethdev: add Tx preparation") >>> Cc: Tomasz Kulasek >>> Cc: stable@dpdk.org >>> >>> Signed-off-by: Ivan Malov >>> --- >>> lib/librte_net/rte_net.h | 16 ++++++++++++++-- >>> 1 file changed, 14 insertions(+), 2 deletions(-) >>> >>> diff --git a/lib/librte_net/rte_net.h b/lib/librte_net/rte_net.h >>> index 7088584..fb09431 100644 >>> --- a/lib/librte_net/rte_net.h >>> +++ b/lib/librte_net/rte_net.h >>> @@ -151,7 +151,19 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m, >>> ipv4_hdr->hdr_checksum = 0; >>> } >>> >> As I remember, saw something similar before... >> Probably the eaiser way to overcome it, is just to always initialize ipv4_hdr above, >> something like: >> >> +ipv4_hdr = NULL; >> if (ol_flags & PKT_TX_IPV4) { >> ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, >> inner_l3_offset); >> >> if (ol_flags & PKT_TX_IP_CKSUM) >> ipv4_hdr->hdr_checksum = 0; >> } > As another possible option always initialisze both, and then use either one or another, > depending on flags: > > ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, inner_l3_offset); > ipv6_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *, inner_l3_offset); > .... We have discussed the solution locally and rejected it since it just kills the compiler help. It makes it possible to use invalid header and compiler will not save you. Suggested solution looks ugly, but at least it does not kill help from compiler. >>> - if ((ol_flags & PKT_TX_UDP_CKSUM) == PKT_TX_UDP_CKSUM) { >>> +#ifdef GCC_VERSION >>> +#if GCC_VERSION < 70400 >>> + /* >>> + * Earlier versions of GCC suspect access to possibly >>> + * uninitialised ipv4_hdr in the code below, although >>> + * the said variable is properly initialised above. >>> + * Use compiler barrier to cope with the problem. >>> + */ >>> + rte_compiler_barrier(); >>> +#endif >>> +#endif >>> + >>> + if ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_UDP_CKSUM) { >>> if (ol_flags & PKT_TX_IPV4) { >>> udp_hdr = (struct rte_udp_hdr *)((char *)ipv4_hdr + >>> m->l3_len); >>> @@ -167,7 +179,7 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m, >>> udp_hdr->dgram_cksum = rte_ipv6_phdr_cksum(ipv6_hdr, >>> ol_flags); >>> } >>> - } else if ((ol_flags & PKT_TX_TCP_CKSUM) || >>> + } else if ((ol_flags & PKT_TX_L4_MASK) == PKT_TX_TCP_CKSUM || >>> (ol_flags & PKT_TX_TCP_SEG)) { >>> if (ol_flags & PKT_TX_IPV4) { >>> /* non-TSO tcp or TSO */ >>> -- >>> 1.8.3.1