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 096E4A034F for ; Wed, 10 Nov 2021 07:50:12 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F390140142; Wed, 10 Nov 2021 07:50:11 +0100 (CET) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2082.outbound.protection.outlook.com [40.107.212.82]) by mails.dpdk.org (Postfix) with ESMTP id ECC3640142 for ; Wed, 10 Nov 2021 07:50:10 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PzfGPwBEBfKZZVTZSK01iokaZCsAjCVa+4bkCDPozQu3AeT5f/zKmTwmC5Ad11dh7eUkT4EGsC1ez6m2TtE3MBEqOUnyq1kgXIbuLUWUtKbmYwaeHQ+YGpcDTxEbuhAUasrqSN2RcPN8ZUICQK3fMXG0f4+UH//0sPmAJgGIeGj1h7yJ8lLMj429y4SCDDaBjY+1CbKEtWlM3w2gaUYVy5AC8kW/zrQ3qETwmYd8VSfcYCzgtnbhRBCLcao82m4GhbVatsl84FLWdVRoMrDv/4k623J3HHMg6+hUBzEyPagotCndn7RAZ3g2zYl01bpu5mo3i8cfVzSjxdGUCY9PPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lhsd3FCFTH7FySrtAc2rpdwjIz/Xbkke18ShOv6ON2c=; b=VjQCwvTcepAGhakytepgs17rxlNlekWCGt8T5E64HcU8Pmkk5rKwxYmEm22kD71CwSB7aSj8wOLMWFCEOeha+X6npmps8s8bVDjDqSS7o2xNXulQ8xIxoz495iUQ3cUYabmlGWm9CUXOP0cMfzp4EthdzxFvUFBA5bMbGqqTJYKl4as2oAw4i5pYSKBUwTcUbOW0XGD3KiQisWRo0jNbAU0WhOsEzO/rGgeMWKpRwQO7QzMsL/vBSDKwBExw+cV3/CjcrhXJWVKnHzqPgCNgZEvKnk3sLO5drqUzWdTmr5xRRIEtF6uXe73vfqkbYDXlhREfhu1/xn1/0hQDWmJwrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=6wind.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lhsd3FCFTH7FySrtAc2rpdwjIz/Xbkke18ShOv6ON2c=; b=APTKydTifAtyi9IM0NevyFu22Kg5zfRyMJDPbizkWlojDlM4BK/1grHGw7mwCSkY5U7M09Qa0fE92zo43155cktLpgUixLm4XcObKVncfyeMXKFj7m3qj8NCMjr5MhGFKL4o2j5+KrjKuWNwflnGux7e0yawQRKEB6QywgKGtKPxI1DCZ4awrAA4taeQkgFyEZJGoZze8jB3625s3A0mQcs5B+F6cmHiLg9MItLzV/NIqIw8c5sKynxRBuTH1qMt/3hoa1lO5NZ6imgtDf6v8DNyWQGcC58TgNaxJuglUYm9n7KQkFNk50cXQZX/gGlSIIR9BQL0cHcZ6PU8A7sj4A== Received: from BN0PR04CA0090.namprd04.prod.outlook.com (2603:10b6:408:ea::35) by MW2PR12MB2556.namprd12.prod.outlook.com (2603:10b6:907:a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.13; Wed, 10 Nov 2021 06:50:08 +0000 Received: from BN8NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ea:cafe::15) by BN0PR04CA0090.outlook.office365.com (2603:10b6:408:ea::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15 via Frontend Transport; Wed, 10 Nov 2021 06:50:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; 6wind.com; dkim=none (message not signed) header.d=none;6wind.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT005.mail.protection.outlook.com (10.13.176.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4690.15 via Frontend Transport; Wed, 10 Nov 2021 06:50:07 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 10 Nov 2021 06:49:57 +0000 From: Xueming Li To: Georg Sauthoff CC: Luca Boccassi , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Olivier Matz , dpdk stable Date: Wed, 10 Nov 2021 14:30:42 +0800 Message-ID: <20211110063216.2744012-159-xuemingl@nvidia.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211110063216.2744012-1-xuemingl@nvidia.com> References: <20211110063216.2744012-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 75fa45ee-d3a1-4875-e390-08d9a41655a9 X-MS-TrafficTypeDiagnostic: MW2PR12MB2556: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NuoVaTyKOBBhk6hPsZx924NQks6gi3ZFQiolAnoSEt6Ewu88qWGqTBl7vNg0nIzYoRZad/U8CL2tdaFTpI80KqfeVgjSulNJQMOk4z3gJGEqQe2B+RTL/iWfIqM5/QlHqRez1g/457HWzqkcOoBYvNKjVjShlw0Xnu0DIbWxMuJKYcX7kN/d4le5T6/QF12saaMjuYULbFr4sHz6+b6FmYSg87rgeLoSHhPJri5rPxj5i4Yl0sz+ALTxktqZWNRYUqCPv0O99oo3gM/YGsmRKf80TDJlWEhzkZo9PVbE0ZWLmHqggJE1T+EgfoxEjdI/86OkZn+kydY2dEpNCs9qGfor2gUeCJLhE2roaXxgliGkDHzdRBOD7eytuE8m8FGs1p0vrvVM9BuDe67+qsx1LBv4CDEgP3v/7ag4MbfkdSKPhqI0YfygRP4WgkplAKLPapMRAxetRE/3JhAYfaeMbBgdqW/rbTTahTU2pgnIlt2LbG5tLgXtZWhmzSbcG9/v6r0Gh4hIN8eW6TgEJaeYzbhlgyYW1BbiqDCWJekTMrvuQ6j5gqtzsKTa45Gr3jKIAwEEsY6qWRditNZUhk3LTNumOS51PDaA6YJDAmoZbK+cNCxncnxkMfmPXgV4COWfTYKiT4B4044NhBHUshlgxgqlKeMj/s3ZGBCyg66RAE09f+NxcKyeiwmby63IcMKVerCPTRp0253wuGzdl6lJln2NPFHe/LcC4aE0PU0+59aWhvst2Pz9kAHsdJfJg+CpReLWM4Lbkf84kgyos37mJZfKBhjGBzllhm9W50A6kdKFPKXQvD+ssHfHOcCxlJI3aL8aEqdXv1aCJbBvMjJtPg== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(66574015)(316002)(508600001)(55016002)(5660300002)(7696005)(8936002)(2906002)(70206006)(4326008)(6666004)(36756003)(966005)(54906003)(356005)(82310400003)(7636003)(86362001)(8676002)(53546011)(186003)(70586007)(426003)(6916009)(83380400001)(26005)(1076003)(36860700001)(336012)(16526019)(2616005)(47076005)(4001150100001)(6286002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2021 06:50:07.8701 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75fa45ee-d3a1-4875-e390-08d9a41655a9 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR12MB2556 Subject: [dpdk-stable] patch 'net: fix aliasing in checksum computation' has been queued to stable release 20.11.4 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 Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.4 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/12/21. 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/steevenlee/dpdk This queued commit can be viewed at: https://github.com/steevenlee/dpdk/commit/71d4385922a00ee9711471cbd54cf62eff45a664 Thanks. Xueming Li --- >From 71d4385922a00ee9711471cbd54cf62eff45a664 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 Cc: Xueming Li [ 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 b188616ab8..52ef3c8cc1 100644 --- a/lib/librte_net/rte_ip.h +++ b/lib/librte_net/rte_ip.h @@ -134,29 +134,18 @@ 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) { - /* 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.33.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-11-10 14:17:08.969388054 +0800 +++ 0158-net-fix-aliasing-in-checksum-computation.patch 2021-11-10 14:17:01.964078660 +0800 @@ -1 +1 @@ -From 24f1955d1ecd13a3c261a328c72932115732825e Mon Sep 17 00:00:00 2001 +From 71d4385922a00ee9711471cbd54cf62eff45a664 Mon Sep 17 00:00:00 2001 @@ -7,0 +8,3 @@ +Cc: Xueming Li + +[ upstream commit 24f1955d1ecd13a3c261a328c72932115732825e ] @@ -21 +23,0 @@ -Cc: stable@dpdk.org @@ -27 +29 @@ - lib/net/rte_ip.h | 27 ++++++++------------------- + lib/librte_net/rte_ip.h | 27 ++++++++------------------- @@ -30,5 +32,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 b188616ab8..52ef3c8cc1 100644 +--- a/lib/librte_net/rte_ip.h ++++ b/lib/librte_net/rte_ip.h +@@ -134,29 +134,18 @@ rte_ipv4_hdr_len(const struct rte_ipv4_hdr *ipv4_hdr)