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 B7DC9A0C41 for ; Tue, 30 Nov 2021 17:40:41 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B25CE41170; Tue, 30 Nov 2021 17:40:41 +0100 (CET) Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by mails.dpdk.org (Postfix) with ESMTP id EE43041190 for ; Tue, 30 Nov 2021 17:40:40 +0100 (CET) Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id CFAF63F1ED for ; Tue, 30 Nov 2021 16:40:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1638290440; bh=7eQEFUV7AnKGY0Xy2HFYwTHfXkyhixarKeRR07zPF1U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=LxmHJUMk6/FdxLWvszfWqulp2U6EgBlIp7uCaACFnwokx26frnVD3Ko0E/vhIc1dg vtSAqd/C1TV3nd+KU7+f7HihrEYUwDHV3jXhpttKSrYKYVU+r05tBwyNmwWnmGlWKc eAX0gCcNSGbWnOGIvFtD/PHKjmhx3FY+/KwBwK/cbZJRz5pZ23Um/AmFtVOw6zuicW jH+4Iwwjeu6rVBrC7zFpSCHT9qJQMFgYF3DBqlGDP6aJUKU98AJLYR57DLPgyM7EFh rEKQ1JoxWIFpC7setqZQHzpzWiaRJ89SWMA33vlbAoqVfrnha9hYxB6uwQy1oh5KoW O81/Vyv7awBhw== Received: by mail-ed1-f70.google.com with SMTP id w4-20020aa7cb44000000b003e7c0f7cfffso17494535edt.2 for ; Tue, 30 Nov 2021 08:40:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7eQEFUV7AnKGY0Xy2HFYwTHfXkyhixarKeRR07zPF1U=; b=rfKtJn+Tf4svLHWVeWspuSvy/9O2oxvNaNHGbvHoGFX+/i5AA8Thrahq0mM9VYc59u oH9aDKsweoqGwFS/Qyag0fvyw1Z80N3Q3gkIl4drOhV1f3hKGJJB8bgbXMWdS5OGBJ89 Tmqim3xmOS2Ohf0F6Q+9o75F5mRkMQCC2gUUrOw06bS0mH8syKp3E+DegoC0INMYI7PF 3hshopP69bnbGaVpTJ5uwdJBxjY0C8aPbRIEfRW0QIDhEjmTO/If0QznTjXF2W7m9/7J 7b4zKz2jr1nx4KYBaGoiTDE7ft8+Wf5eJb+dkI/yLVuPowJ7yQ2tBpxDtdynLBLqWTpH jv0w== X-Gm-Message-State: AOAM5315ZozHi/PbQHID1nYQChxLvLjwAWONfR8NxT9DIG1pSIS32ozi k1XzQtbfYoHYnp+M8p7ihmJzzMEhQqKqrhwpxh+b17MdINL86QDz4vV9ewO+ARHQxCfIKUHaA6j dYhRKLatX7wVDvuHEM+G5yCsf X-Received: by 2002:a17:906:3647:: with SMTP id r7mr276315ejb.124.1638290440532; Tue, 30 Nov 2021 08:40:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwn08baUqdUZxKwiHZzw3OvdYpZUF+jXuLpZjULCxTvtPD7ulcCn/akxlyCQo8wW7syLkGqhg== X-Received: by 2002:a17:906:3647:: with SMTP id r7mr276296ejb.124.1638290440369; Tue, 30 Nov 2021 08:40:40 -0800 (PST) Received: from localhost.localdomain ([2001:67c:1560:8007::aac:c4ad]) by smtp.gmail.com with ESMTPSA id yd20sm9297785ejb.47.2021.11.30.08.40.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 08:40:39 -0800 (PST) From: christian.ehrhardt@canonical.com To: Georg Sauthoff Cc: =?UTF-8?q?Morten=20Br=C3=B8rup?= , Olivier Matz , dpdk stable Subject: patch 'net: fix aliasing in checksum computation' has been queued to stable release 19.11.11 Date: Tue, 30 Nov 2021 17:34:52 +0100 Message-Id: <20211130163605.2460997-88-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211130163605.2460997-1-christian.ehrhardt@canonical.com> References: <20211130163605.2460997-1-christian.ehrhardt@canonical.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 19.11.11 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before December 10th 2021. 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/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/e3285b3e8ee70b46af72121ef796a7f710c1cb80 Thanks. Christian Ehrhardt --- >From e3285b3e8ee70b46af72121ef796a7f710c1cb80 Mon Sep 17 00:00:00 2001 From: Georg Sauthoff Date: Sun, 17 Oct 2021 22:37:18 +0200 Subject: [PATCH] net: fix aliasing in checksum computation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ upstream commit 24f1955d1ecd13a3c261a328c72932115732825e ] That means a superfluous cast is removed and aliasing through a uint8_t pointer is eliminated. NB: The C standard specifies that a unsigned char pointer may alias while the C standard doesn't include such requirement for uint8_t pointers. Also simplified the loop since a modern C compiler can speed up (i.e. auto-vectorize) it in a similar way. For example, GCC auto-vectorizes it for Haswell using AVX registers while halving the number of instructions in the generated code. Fixes: 6006818cfb26 ("net: new checksum functions") Fixes: e079655c41fb ("net: fix build with gcc 4.4.7 and strict aliasing") Signed-off-by: Georg Sauthoff Reviewed-by: Morten Brørup Acked-by: Olivier Matz --- lib/librte_net/rte_ip.h | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h index cedfd27ac1..279e88ee39 100644 --- a/lib/librte_net/rte_ip.h +++ b/lib/librte_net/rte_ip.h @@ -119,29 +119,18 @@ struct rte_ipv4_hdr { static inline uint32_t __rte_raw_cksum(const void *buf, size_t len, uint32_t sum) { - /* workaround gcc strict-aliasing warning */ - uintptr_t ptr = (uintptr_t)buf; + /* extend strict-aliasing rules */ typedef uint16_t __attribute__((__may_alias__)) u16_p; - const u16_p *u16_buf = (const u16_p *)ptr; - - while (len >= (sizeof(*u16_buf) * 4)) { - sum += u16_buf[0]; - sum += u16_buf[1]; - sum += u16_buf[2]; - sum += u16_buf[3]; - len -= sizeof(*u16_buf) * 4; - u16_buf += 4; - } - while (len >= sizeof(*u16_buf)) { + const u16_p *u16_buf = (const u16_p *)buf; + const u16_p *end = u16_buf + len / sizeof(*u16_buf); + + for (; u16_buf != end; ++u16_buf) sum += *u16_buf; - len -= sizeof(*u16_buf); - u16_buf += 1; - } - /* if length is in odd bytes */ - if (len == 1) { + /* if length is odd, keeping it byte order independent */ + if (unlikely(len % 2)) { uint16_t left = 0; - *(uint8_t *)&left = *(const uint8_t *)u16_buf; + *(unsigned char *)&left = *(const unsigned char *)end; sum += left; } -- 2.34.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-11-30 16:50:11.079309029 +0100 +++ 0088-net-fix-aliasing-in-checksum-computation.patch 2021-11-30 16:50:05.878874175 +0100 @@ -1 +1 @@ -From 24f1955d1ecd13a3c261a328c72932115732825e Mon Sep 17 00:00:00 2001 +From e3285b3e8ee70b46af72121ef796a7f710c1cb80 Mon Sep 17 00:00:00 2001 @@ -8,0 +9,2 @@ +[ upstream commit 24f1955d1ecd13a3c261a328c72932115732825e ] + @@ -21 +22,0 @@ -Cc: stable@dpdk.org @@ -27 +28 @@ - lib/net/rte_ip.h | 27 ++++++++------------------- + lib/librte_net/rte_ip.h | 27 ++++++++------------------- @@ -30,5 +31,5 @@ -diff --git a/lib/net/rte_ip.h b/lib/net/rte_ip.h -index 0ef2430607..41d90ca1b9 100644 ---- a/lib/net/rte_ip.h -+++ b/lib/net/rte_ip.h -@@ -154,29 +154,18 @@ rte_ipv4_hdr_len(const struct rte_ipv4_hdr *ipv4_hdr) +diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h +index cedfd27ac1..279e88ee39 100644 +--- a/lib/librte_net/rte_ip.h ++++ b/lib/librte_net/rte_ip.h +@@ -119,29 +119,18 @@ struct rte_ipv4_hdr {