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 DE7CBA054A for ; Tue, 25 Oct 2022 17:08:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AC49C42C3F; Tue, 25 Oct 2022 17:08:07 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 6921E42C34 for ; Tue, 25 Oct 2022 17:08:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666710485; 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=4O6NdI5i7kdVzfrxBi85W28qwjuMTCf0Cc7xyIpUoio=; b=H+MHUtkoJm09gU346SZWqlK4y2eOjK7wpgdaNK5MjIi3njDteQ/3b/Mg0fz4C4AaRoLWyL FKK3dyMUTFxnb0XycZiN03Dyv2ir6zIDCzFFSx77TqciR6/C0WYgL2/yTHugFGjPUp/wb1 mYkfmN+UW3W8tksacn7FH0hd+9E9Dvg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-346-gf-3S2aGP82zRjNsP7LG5w-1; Tue, 25 Oct 2022 11:08:02 -0400 X-MC-Unique: gf-3S2aGP82zRjNsP7LG5w-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 26A3B3C0F229; Tue, 25 Oct 2022 15:08:00 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.192.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1ED884A9254; Tue, 25 Oct 2022 15:07:58 +0000 (UTC) From: Kevin Traynor 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 21.11.3 Date: Tue, 25 Oct 2022 16:05:57 +0100 Message-Id: <20221025150734.142189-2-ktraynor@redhat.com> In-Reply-To: <20221025150734.142189-1-ktraynor@redhat.com> References: <20221025150734.142189-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 21.11.3 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/01/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/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/ac8fea22795ed3fd09ddb70f090636ee1a034d3d Thanks. Kevin --- >From ac8fea22795ed3fd09ddb70f090636ee1a034d3d 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/net/rte_ip.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/net/rte_ip.h b/lib/net/rte_ip.h index c575250852..615e5b125e 100644 --- a/lib/net/rte_ip.h +++ b/lib/net/rte_ip.h @@ -155,16 +155,19 @@ 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.37.3 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-10-25 14:18:58.640593252 +0100 +++ 0002-net-accept-unaligned-data-in-checksum-routines.patch 2022-10-25 14:18:58.348797865 +0100 @@ -1 +1 @@ -From 1c9a7fba5c90e0422b517404499ed106f647bcff Mon Sep 17 00:00:00 2001 +From ac8fea22795ed3fd09ddb70f090636ee1a034d3d Mon Sep 17 00:00:00 2001 @@ -8,0 +9,2 @@ +[ upstream commit 1c9a7fba5c90e0422b517404499ed106f647bcff ] + @@ -29 +30,0 @@ -Cc: stable@dpdk.org @@ -38 +39 @@ -index b502481670..ecd250e9be 100644 +index c575250852..615e5b125e 100644 @@ -41 +42 @@ -@@ -161,16 +161,19 @@ static inline uint32_t +@@ -155,16 +155,19 @@ static inline uint32_t