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 29ACCA00C2 for ; Thu, 3 Nov 2022 10:28:06 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ED85140694; Thu, 3 Nov 2022 10:28:05 +0100 (CET) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by mails.dpdk.org (Postfix) with ESMTP id E160E40693 for ; Thu, 3 Nov 2022 10:28:04 +0100 (CET) Received: by mail-wr1-f42.google.com with SMTP id k8so1747798wrh.1 for ; Thu, 03 Nov 2022 02:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=S9BW5M+RPlPXIABlHOIFIpT3FKM+uNzeFAgAQ6CSh2k=; b=Fr6YpMmNpRLTI9YH9SSU2hle7Nq6OZm1BkMI3zn9vlEjRcXARmKQb+3U+PxFoYbTuf aqslp9v77Ds0wCOSBRP+nbDd0VQhhf4dm8ICr5JbJydK7LSe8j0xyMfPb6auTnV4AKuV DTpnl6GJ1xml8nWQfnIMU3SRCQHyAru18Tvp2zpcRUVsyHzqhkMzw88V/vEadyh7lWce fO2f5CwyEjM8YJQ1zb1elDicXApV5izLjH9UBVzUavnWxvnnrSYMFOtew3YKhwLz5J+7 m0OZ965QyOuBW4zyw0y0UhcfRwYkbpwBE4EIro76OnKUEt0OSkOSmb4+Q/IE8iRjHyqV bOxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=S9BW5M+RPlPXIABlHOIFIpT3FKM+uNzeFAgAQ6CSh2k=; b=wzuvymxaLyfqJeb4LEREH7LuN4MeXRHNJfzOETntjky4dQ+zeQV5EzJwIG0A8jNblF 8gR/sFltKK14kJKJnGIh3uKarmFksRm2K8BvO2s6t0hQ7sFeN+/tJ7lXgIWCItGbpcA6 IS8bGU9y71c6eI655kZ6YUdCTBxhcsE+CtWJFDxsWxamWMuDaiNBJaZzJPMWmMas+c8d fvxXLTkEVgFjZM8jipARRtJXp2Du6xJdvSMn9eY455I8fD1YhkdoVw+U4PzllieCk82f 84vJQBmacoA3ylF0TfsxMncEPPjf1rMFabZu6ceo3ty0aQi/HLhi7jWGRhAuO4yAiBCy 6vPA== X-Gm-Message-State: ACrzQf10soXQpMhBVTGNwxCN0XY+wLoEZYvePILcYLvJaNLjJ7RAzn1I dcUfkPsfWgDpoa1PzlPpOoEUUzosV1mEpQ== X-Google-Smtp-Source: AMsMyM5P4dFTKlIcSk7+vsNJBxi7JnMUlX72Xy4c9XfI8jYZcagzvw7B/xTI88jdC+kS9wzNlJNKzA== X-Received: by 2002:a05:6000:22f:b0:236:4f8e:a913 with SMTP id l15-20020a056000022f00b002364f8ea913mr17615037wrz.240.1667467684335; Thu, 03 Nov 2022 02:28:04 -0700 (PDT) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id bu15-20020a056000078f00b00228d67db06esm399555wrb.21.2022.11.03.02.28.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 02:28:03 -0700 (PDT) From: luca.boccassi@gmail.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 20.11.7 Date: Thu, 3 Nov 2022 09:26:19 +0000 Message-Id: <20221103092758.1099402-1-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.34.1 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 20.11.7 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/05/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/370afad50d5df10bd6feb291aaaf3aced7f71531 Thanks. Luca Boccassi --- >From 370afad50d5df10bd6feb291aaaf3aced7f71531 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 52ef3c8cc1..ac59ee1339 100644 --- a/lib/librte_net/rte_ip.h +++ b/lib/librte_net/rte_ip.h @@ -134,18 +134,21 @@ rte_ipv4_hdr_len(const struct rte_ipv4_hdr *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.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-11-03 09:27:25.614123807 +0000 +++ 0001-net-accept-unaligned-data-in-checksum-routines.patch 2022-11-03 09:27:25.293420892 +0000 @@ -1 +1 @@ -From 1c9a7fba5c90e0422b517404499ed106f647bcff Mon Sep 17 00:00:00 2001 +From 370afad50d5df10bd6feb291aaaf3aced7f71531 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 52ef3c8cc1..ac59ee1339 100644 +--- a/lib/librte_net/rte_ip.h ++++ b/lib/librte_net/rte_ip.h +@@ -134,18 +134,21 @@ rte_ipv4_hdr_len(const struct rte_ipv4_hdr *ipv4_hdr)