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 7DE08606A322 for ; Wed, 2 Dec 2026 17:32:14 +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=GHG5NpgN Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 492EF402DD; Wed, 2 Dec 2026 18:32:13 +0100 (CET) Received: from mail-dy1-f171.google.com (mail-dy1-f171.google.com [74.125.82.171]) by mails.dpdk.org (Postfix) with ESMTPS id 3F85A402DD for ; Wed, 2 Dec 2026 18:32:11 +0100 (CET) Received: by mail-dy1-f171.google.com with SMTP id 5a478bee46e88-38644aedba1so22472306eec.0 for ; Wed, 02 Dec 2026 09:32:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796232729; x=1796837529; darn=dpdk.org; h=content-transfer-encoding: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=5Ss/GMaGpdV4oZa45vxd8gBxa15mKdvdCW9jHJiihRg=; b=GHG5NpgNXJUd7/xvdFTLUDxct9zeOmjGXvcgAWZ3S/5aXRCQvDfL7EmI/Kj+5rFfAz ejUTE0CR80jth9h1DbEVJiNL3IzF7mfFwgAOHE5XPC5YczTWC4RiS84ncRFhcLXqkT0I Zta5MS3F89AKo44fEq5dL7EAZNDNqmkSbxzFCcvSbclud+tsaa6NEa8uILrqFTzS0H0x 4qdiCpv8nYUk02IAzbUxOV/OmvYG2RxbphQhFLgLkKtMgXTfVP/KoHvUVQcRr/fW1t/b fltmj5opg41Jr3nHK4YyMyBvUlM2Xlp+PJHLHhQ2gevLkXMFmIbc8mzed9KrrxQ1sQpu j/pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796232729; x=1796837529; h=content-transfer-encoding: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=5Ss/GMaGpdV4oZa45vxd8gBxa15mKdvdCW9jHJiihRg=; b=dmLSbId/gw3jxiMkoqtcCCJdfcPHXBWFj/z6S+xkb8rhLK+7R/QjJICsPDFR+7I7Oj +tt8l/ea/xHsOR0cdoNjQ3ANSVB9UvM6NZFwIl7mWH2jdfnimqSjdVN78I7pYPUrK/AI eR7Uqp8RKvZe6WWUFSHLWThfyI+lgkghJIfp51PLZN952Q6iZQ635ILF0HkCpzdTZwpb M/Yb8jvsAvjZuO8JPMCfiQHFFSPp+btw6hN0Q+VxXrIMx3CtLMUQCMx8ew7cgEwK0o8M HsAjH3PNs+OjiD4c2c1gel8/HPrbdRqZo4sRfi2rMulcIDkZvFjVhBOjjJC4bFWKGL+B oauQ== X-Gm-Message-State: APuU4Z/peQUAxNNUdW0opD9gJRDlzpoMGZ6OGkQOO3y82vUj6HdB/K4K Hp+LKU3+MbkoJD7yCjQ+4A3jdoPsx19m+o9tYJyMsv38teEneIbuI7I7MseH+Q== X-Gm-Gg: AZFdTZcj4K4khk+ERHt0UPbQNKwK+kcVCguLPKorwnF7Zuz7wISMtPrHGp68byGyujL I2omSzCVp45LyvsAE/AgGboamA9EIUB7C5PIn/yMHex6RfTvUpxruguTVWyTIDB93TUYftFZ/kT E7QU1dAWoWYTXb75eB8YlWVQEmI8eXldTeE5MaMBpJhmbGS4kaDJgPsV8uQPdzwqwtaOgzy+638 10cv797exaPtYpDIVSDOyfWsclEW+EgSjrJFgQMHB9aBJ3DMXEWj/dkHU9pV7cm5usDmg9Qm3tK XIn76TTAIcH609oqFREUPPg9ltemf+d2jTH+L0iNnqsIy/iv2bdWMuwCfBD7iL11TqdN3201NF1 OtbDaBAnxLYHVy2WZfNhgcOucxC8jqd/QFNNbDNq/glILFKvsALH3ToPMiXIs9W1Vfcwv6/Mkob ThKr2rlXJ5Ry/Rxf/vLW6MkkL84S17OqcZh7bAp1NkO5jG6jbsjOKT75TN/+FxTkPg26+xq22CF L/F0t1u6zVO0Ir3wZLHogQw/rskRVmajHpIB/YzBpxewVjSrk39iD9otr8bra8tDP8qOTbjxAq6 KtUopn7Pc1hyLCaATqH1zFqm3pnZGtkKaJI1k0A89XaKTev1R7fAN4tn6UR6TX0zQFw1rfgnyQ= = X-Received: by 2002:a05:7301:1402:b0:375:ed63:5f12 with SMTP id 5a478bee46e88-3856fe564admr45326309eec.22.1796232729463; Wed, 02 Dec 2026 09:32:09 -0800 (PST) Received: from mr41p01nt-relayp02.apple.com ([17.199.97.123]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-38566fdce48sm127974242eec.14.2026.12.02.09.32.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 02 Dec 2026 09:32:08 -0800 (PST) From: Scott Mitchell To: dev@dpdk.org Cc: mb@smartsharesystems.com, david.marchand@redhat.com, thomas@monjalon.net, stephen@networkplumber.org, Scott Mitchell , Cyril Chemparathy , stable@dpdk.org Subject: [PATCH v21] eal: add may_alias to unaligned typedefs Date: Wed, 2 Dec 2026 09:30:51 -0800 Message-ID: <20261202173051.59927-1-scott.k.mitch1@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261201201801.23189-1-scott.k.mitch1@gmail.com> References: <20261201201801.23189-1-scott.k.mitch1@gmail.com> X-Archived-By: MIME-Version: 1.0 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 to the non-MSVC typedefs as a leading attribute, so the existing __rte_aligned(1) declarations are unchanged, 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 --- 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 | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index fed373f412..b25db73862 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -132,4 +132,13 @@ extern "C" { #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 @@ -152,4 +161,5 @@ 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 @@ -158,6 +168,9 @@ typedef __unaligned uint32_t unaligned_uint32_t; typedef __unaligned uint16_t unaligned_uint16_t; #else +__rte_may_alias 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); #endif @@ -178,13 +191,4 @@ typedef uint16_t unaligned_uint16_t __rte_aligned(1); #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 -- 2.54.0 (Apple Git-157)