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 413C0A0544 for ; Fri, 11 Nov 2022 12:39:19 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 342604014F; Fri, 11 Nov 2022 12:39:19 +0100 (CET) Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by mails.dpdk.org (Postfix) with ESMTP id 3EC7E40141 for ; Fri, 11 Nov 2022 12:39:18 +0100 (CET) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.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-1.canonical.com (Postfix) with ESMTPS id 011E5412C6 for ; Fri, 11 Nov 2022 11:39:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1668166758; bh=eXg2hrGJUNakY1uKu4g+1ORfmJyw9XuMEtPzbzqGJtw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=jNGWMFgqyJmmRIOJow7Bkdjr4N27SkMQmXOfd+0YDus30jOBm7DJ4m7A+ZZd6F5UQ TOfh6bQ0FDIRzTgFsoQfwPHi/9KSh6lV5huYJx8qSjoLbeSBt7veF6xpyvke8V9eHs iQ0YKya8nT3yiG/gmTTOAg6CsXPExlzXR3Ph71v65adYcYdnU8sTeGd1QbfcnpQvxu dyUU2m1s3n0S0D2CjlGdYiviFodPgLaI7hkFIWXldct7tHsztVLdfM85KC4NRGSvDP Bha5brGlCXs4nE7+Lg2owjJuneXMYcbpm3liBK2zmtiODiREfsEkINr6sfzZ0+9IS0 prM43GAYesKlA== Received: by mail-ej1-f70.google.com with SMTP id dn14-20020a17090794ce00b007ae5d040ca8so2904825ejc.17 for ; Fri, 11 Nov 2022 03:39:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=eXg2hrGJUNakY1uKu4g+1ORfmJyw9XuMEtPzbzqGJtw=; b=7aNWR9ax3qDT6wydSsbuEynwMHpDpXfkN1Za+WCK/0wscuOhloozUFCoMyOEvkY7cd poavKNYkYcPEqQlzfVU5ELwZU7czMh2VDPLFjEDkKAiKi8a4SQq0gdl32hMeV80FbOmy 9XSKq5F37gm9ykFwdNYCigjT9eL10YDE6s4rosLbckYwuvoQFLBLTNof3dW41X4bxa7i Fyg914nYnlSEf7oMfwy60dM61QyacMxSkglfsxYWkgM22T1ulN0Vz1p3sxRLbNDJsvzk 3Kgr5vxjhxAjqXBGN1xl6bpdaodMXn/mZhxgtk/qiRz5SzsVAMQsnFSbEx9vUTLOYicy vv2g== X-Gm-Message-State: ANoB5plnbidCbI4NH/gJz/1poIvOBmDrQYFOmOi+fPbSl3NVxCJgS288 s3Po3fPfF4A9Kh0CMDzzPvoXqTIPUIBlmw1HcPLgl1RLN+vizarV29PhTnAkhSod3x4TddeYC1Y DK6jdcFD4IU8tL2LrXvTOWzBu X-Received: by 2002:a17:907:1b89:b0:7ad:b51d:39d0 with SMTP id mz9-20020a1709071b8900b007adb51d39d0mr1451713ejc.571.1668166757721; Fri, 11 Nov 2022 03:39:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf7o+undJj9lfR+xz50gJc6mwR7L4yW9Maeg5HpgzPjSZD0hIAzc6qHaSm2RyN0no2rOgRj0RQ== X-Received: by 2002:a17:907:1b89:b0:7ad:b51d:39d0 with SMTP id mz9-20020a1709071b8900b007adb51d39d0mr1451704ejc.571.1668166757493; Fri, 11 Nov 2022 03:39:17 -0800 (PST) Received: from localhost.localdomain ([2a02:6d40:39af:c100:1891:6c61:50fd:e567]) by smtp.gmail.com with ESMTPSA id vi2-20020a170907d40200b007933047f923sm774128ejc.118.2022.11.11.03.39.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 03:39:17 -0800 (PST) From: christian.ehrhardt@canonical.com To: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Cc: Olivier Matz , dpdk stable Subject: patch 'net: accept unaligned data in checksum routines' has been queued to stable release 19.11.14 Date: Fri, 11 Nov 2022 12:38:19 +0100 Message-Id: <20221111113904.1549618-2-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221111113904.1549618-1-christian.ehrhardt@canonical.com> References: <20221111113904.1549618-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.14 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/18/22. 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/8803ccb7fdf7f7c76463b871d36eeb685fae38b8 Thanks. Christian Ehrhardt --- >From 8803ccb7fdf7f7c76463b871d36eeb685fae38b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Date: Mon, 11 Jul 2022 14:11:32 +0200 Subject: [PATCH] net: accept unaligned data in checksum routines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ upstream commit 1c9a7fba5c90e0422b517404499ed106f647bcff ] __rte_raw_cksum() (used by rte_raw_cksum() among others) accessed its data through an uint16_t pointer, which allowed the compiler to assume the data was 16-bit aligned. This in turn would, with certain architectures and compiler flag combinations, result in code with SIMD load or store instructions with restrictions on data alignment. This patch keeps the old algorithm, but data is read using memcpy() instead of direct pointer access, forcing the compiler to always generate code that handles unaligned input. The __may_alias__ GCC attribute is no longer needed. The data on which the Internet checksum functions operates are almost always 16-bit aligned, but there are exceptions. In particular, the PDCP protocol header may (literally) have an odd size. Performance impact seems to range from none to a very slight regression. Bugzilla ID: 1035 Fixes: 6006818cfb26 ("net: new checksum functions") Signed-off-by: Mattias Rönnblom Acked-by: Olivier Matz --- lib/librte_net/rte_ip.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h index 279e88ee39..9ad8f0f3f4 100644 --- a/lib/librte_net/rte_ip.h +++ b/lib/librte_net/rte_ip.h @@ -119,18 +119,21 @@ struct rte_ipv4_hdr { static inline uint32_t __rte_raw_cksum(const void *buf, size_t len, uint32_t sum) { - /* extend strict-aliasing rules */ - typedef uint16_t __attribute__((__may_alias__)) u16_p; - const u16_p *u16_buf = (const u16_p *)buf; - const u16_p *end = u16_buf + len / sizeof(*u16_buf); + const void *end; - for (; u16_buf != end; ++u16_buf) - sum += *u16_buf; + for (end = RTE_PTR_ADD(buf, RTE_ALIGN_FLOOR(len, sizeof(uint16_t))); + buf != end; buf = RTE_PTR_ADD(buf, sizeof(uint16_t))) { + uint16_t v; + + memcpy(&v, buf, sizeof(uint16_t)); + sum += v; + } /* if length is odd, keeping it byte order independent */ if (unlikely(len % 2)) { uint16_t left = 0; - *(unsigned char *)&left = *(const unsigned char *)end; + + memcpy(&left, end, 1); sum += left; } -- 2.38.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-11-11 12:35:04.873728886 +0100 +++ 0002-net-accept-unaligned-data-in-checksum-routines.patch 2022-11-11 12:35:04.697191643 +0100 @@ -1 +1 @@ -From 1c9a7fba5c90e0422b517404499ed106f647bcff Mon Sep 17 00:00:00 2001 +From 8803ccb7fdf7f7c76463b871d36eeb685fae38b8 Mon Sep 17 00:00:00 2001 @@ -8,0 +9,2 @@ +[ upstream commit 1c9a7fba5c90e0422b517404499ed106f647bcff ] + @@ -29 +30,0 @@ -Cc: stable@dpdk.org @@ -34 +35 @@ - lib/net/rte_ip.h | 17 ++++++++++------- + lib/librte_net/rte_ip.h | 17 ++++++++++------- @@ -37,5 +38,5 @@ -diff --git a/lib/net/rte_ip.h b/lib/net/rte_ip.h -index b502481670..ecd250e9be 100644 ---- a/lib/net/rte_ip.h -+++ b/lib/net/rte_ip.h -@@ -160,18 +160,21 @@ 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 279e88ee39..9ad8f0f3f4 100644 +--- a/lib/librte_net/rte_ip.h ++++ b/lib/librte_net/rte_ip.h +@@ -119,18 +119,21 @@ struct rte_ipv4_hdr {