Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF7DD606A322 for ; Thu, 3 Dec 2026 16:28:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=F3dSEHST Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E541140658; Thu, 3 Dec 2026 17:28:02 +0100 (CET) Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) by mails.dpdk.org (Postfix) with ESMTPS id B186440291 for ; Thu, 3 Dec 2026 17:28:01 +0100 (CET) Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-94961d90b79so1420405385a.3 for ; Thu, 03 Dec 2026 08:28:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796315280; x=1796920080; darn=dpdk.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=xf9oFPxe/SLOyFj5b4pR9eIp5Ad+wJY/xehN6CZcsFQ=; b=F3dSEHSTtUkVI8PWOUN68J8stMjN4LfB6GNnG6BlZ9BSRAb2QWSBnjBlbJGygpWDIz POSbEGA3KVQH5ae6MuoPG+zsPSK08rymzo7l9QxBo9PN2Zkt/27UtavqXULMWktl8XDB yQm8Q0fdTVUnc4KktmtFebQHntlOzwk6dPlTY+Tbmt+FIKNIuOPEBKiXUIdMEW8J2QGM iP19BMWz6Ab6KfIoES1L0PmrOlNNKOc7iRUNy+EyS/2jnBTfY59WCrlsyvRVtQB/C3tu d2JnxocYR1uGljJP6mL8yVtoVxBkMNlZKk6KrXWGfRZmDuyrviJ1z4R+a+1iFCqlPjJY nfOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796315280; x=1796920080; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=xf9oFPxe/SLOyFj5b4pR9eIp5Ad+wJY/xehN6CZcsFQ=; b=Da9j0FGhQWDVucDbUuUZfr351Vc3+5ivcBe9jWkJFpNgalDJA3ka2hq2nSn0d7SGXS 1SpAhu0HEdQ/JDQWywuZftboMA1oGXFwXUCLj85+TQOoI59nXZGW/FtNz6Qb85/YcO+1 hOoPkaCMYvHkbMUPFvwB/wU385y9K7IUqaf8Cvb0r9QeCQzYqKM3ikL9PPcv/JC8+0fq 4dO0tdFNDhpiocdawwpbHb0i5LzU7s6E/IY6B8U38gDLDfcYoI9OgS6RRDGsILb8qwVE uu/acz1h0XSoWNOBQZgMd7rvOKRlsoqKVssH7Pqz4EEyUrK964qd1k1SM7/sftpCg+Nf s0CA== X-Gm-Message-State: APuU4Z91GNgGfi7xYTm6hmUS7vtUxLnrrrF3A0sLODGuAF6TLstI9JIM 4KsbMUrgedFwoZ0e968tAguZCnH7z0ohDy4A873NLAWpoFIrdn//dk73af0VRQ== X-Gm-Gg: AZFdTZfcmfirjSDmDE+DVz4nGP1k2cgGiBZH9nGdGUOqolY4yU+7hns+BibIlQPYGlk cnUhgEHIS1d3ty8IYzcDjjL7jxbtPQMrvsnpD12rnHawKgtaQWnA9TLPxf6nA2E9fFhgXZg55Aq xJFnsPC71Qi0w6jcA/6Wneb3gidi65u2LMVu2kwSC6YZCMckmVxhjukVjIlm+LsEYmIKTz/4XA0 UwERaOV6tDk3u/C/CC8Y36a9kgnslWWvm9POAoWXI7fThV4eSMJ5J74/Ftu+pNQ3yN4CurMRWLx +KAl0Nkdln16m6kCtw/gvTUs+O8Az+SHDCk3glJaT17oTfkszuL+8laKMT3e5WeXCye1uDQDB7Z hBWr2oxGvrppjBuf5v4+71FXt77hvONJHeTG45ItMDDULpQWp8XEdgCLF/jZfxy6fSIVk/i8I6D wVoFbuOAq5EbJEkd8fFBr8qIcxN9Fgr3dMiZVz4cljJfhYe+CM5LKVBKrmPUL2vctflOjMeKtxF R/HESe+GlrqneKTNbN0vtRU+FMo97N1j24sP53tnmDdstRcVfsIuMmpu4bnAHPlL/+OHlKxc1fH NsSdrfaiOcpcWZUR+gGMRzYTqIbOgCtsE5QPeCsJfN5ecqnZi3VCAArmxtqByMehehVKAvclUtd +SVd4akgvgiI7abK4vXlfvNQzupG/cGSogkljXvsw4F4UQoTrHPyernhHq8GVTQ== X-Received: by 2002:a05:620a:462a:b0:949:3302:1d9f with SMTP id af79cd13be357-949bab350e3mr7912595885a.78.1796315280483; Thu, 03 Dec 2026 08:28:00 -0800 (PST) Received: from st47p01nt-relayp01.apple.com ([185.104.139.140]) by smtp.gmail.com with ESMTPSA id af79cd13be357-949ca98d9d6sm3183986085a.18.2026.12.03.08.27.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 03 Dec 2026 08:28:00 -0800 (PST) From: Scott Mitchell To: dev@dpdk.org Cc: stephen@networkplumber.org, thomas@monjalon.net, david.marchand@redhat.com, mb@smartsharesystems.com, Scott Mitchell , Cyril Chemparathy , stable@dpdk.org Subject: [PATCH v22] eal: add may_alias to unaligned typedefs Date: Thu, 3 Dec 2026 08:27:48 -0800 Message-ID: <20261203162748.36009-1-scott.k.mitch1@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261202173051.59927-1-scott.k.mitch1@gmail.com> References: <20261202173051.59927-1-scott.k.mitch1@gmail.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 The unaligned_uint{16,32,64}_t types may be used to read memory that was written through other types, e.g. checksumming a packet header that was just filled in field by field. Without may_alias, type-based alias analysis may assume those reads do not alias the preceding stores and move them ahead of the stores. clang 22 does this to a raw checksum loop reading through unaligned_uint16_t, producing TCP checksums over stale header bytes. Add __rte_may_alias next to __rte_aligned(1) in the non-MSVC typedefs, and move its definition above them. MSVC keeps __unaligned and has no type-based alias analysis to disable. Fixes: 7621d6a8d0bd ("eal: add and use unaligned integer types") Cc: Cyril Chemparathy Cc: stable@dpdk.org Signed-off-by: Scott Mitchell Reviewed-by: Morten Brørup --- v22: * Place __rte_may_alias next to __rte_aligned(1) in the typedefs, and update the commit message to match. (Morten) * checkpatch's check_aligned_attributes warns on these lines because __rte_aligned is used outside a struct/union; this is expected. v21: * Commit message says "may be used to". (Morten) * Use __rte_may_alias, with its definition moved above __rte_aligned(), instead of spelling out the attribute. (Morten) * Keep it as a leading attribute so the __rte_aligned(1) typedef lines are unchanged. v19 changed those lines, which checkpatch flags in check_aligned_attributes: https://patches.dpdk.org/project/dpdk/patch/20260202044841.90945-2-scott.k.mitch1@gmail.com/ The leading form takes effect with gcc 11 and clang 21 and 23. lib/eal/include/rte_common.h | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index fed373f412..c386c42789 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -131,6 +131,15 @@ extern "C" { #define __rte_ptr_arith_add_zero #endif +/** + * Macro to mark a type that is not subject to type-based aliasing rules + */ +#ifdef RTE_TOOLCHAIN_MSVC +#define __rte_may_alias +#else +#define __rte_may_alias __attribute__((__may_alias__)) +#endif + /** * Force type alignment * @@ -151,15 +160,16 @@ extern "C" { /** * Integer types with no alignment requirement. + * They may alias other types, e.g. to read a header written field by field. */ #ifdef RTE_TOOLCHAIN_MSVC typedef __unaligned uint64_t unaligned_uint64_t; typedef __unaligned uint32_t unaligned_uint32_t; typedef __unaligned uint16_t unaligned_uint16_t; #else -typedef uint64_t unaligned_uint64_t __rte_aligned(1); -typedef uint32_t unaligned_uint32_t __rte_aligned(1); -typedef uint16_t unaligned_uint16_t __rte_aligned(1); +typedef uint64_t unaligned_uint64_t __rte_aligned(1) __rte_may_alias; +typedef uint32_t unaligned_uint32_t __rte_aligned(1) __rte_may_alias; +typedef uint16_t unaligned_uint16_t __rte_aligned(1) __rte_may_alias; #endif /** @@ -177,15 +187,6 @@ typedef uint16_t unaligned_uint16_t __rte_aligned(1); #define __rte_packed_end __attribute__((__packed__)) #endif -/** - * Macro to mark a type that is not subject to type-based aliasing rules - */ -#ifdef RTE_TOOLCHAIN_MSVC -#define __rte_may_alias -#else -#define __rte_may_alias __attribute__((__may_alias__)) -#endif - /******* Macro to mark functions and fields scheduled for removal *****/ #ifdef RTE_TOOLCHAIN_MSVC #define __rte_deprecated -- 2.54.0 (Apple Git-157)