DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH v3 3/5] eal: make unaligned really unaligned
Date: Mon,  7 Sep 2026 11:31:22 -0700	[thread overview]
Message-ID: <20260907183239.629053-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20260907183239.629053-1-stephen@networkplumber.org>

The common tests that expected unaligned to really have no
guaranteed alignment would fail with UBSAN. The root cause
was the definition of unaligned still implied alignment on x86.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 doc/guides/rel_notes/release_26_11.rst |  6 ++++++
 lib/eal/include/rte_common.h           | 13 ++++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index 4cadfc1918..4b219cbc97 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -109,6 +109,12 @@ API Changes
     compile with an integer argument, but this is deprecated usage: existing code
     should use ``RTE_ALIGN``, ``RTE_ALIGN_CEIL`` or ``RTE_ALIGN_FLOOR`` instead.
 
+* **eal: Unaligned integer types are now really unaligned.**
+
+  ``unaligned_uint16_t``, ``unaligned_uint32_t`` and ``unaligned_uint64_t``
+  are now declared with an alignment of 1 on all architectures.
+  The compiler may generate narrower loads and stores than before.
+
 
 ABI Changes
 -----------
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index ed037be399..bb7dfb8ba5 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -149,14 +149,17 @@ extern "C" {
 #define __rte_aligned(a) __attribute__((__aligned__(a)))
 #endif
 
-#ifdef RTE_ARCH_STRICT_ALIGN
+/**
+ * Integer types with no alignment requirement.
+ */
+#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);
-#else
-typedef uint64_t unaligned_uint64_t;
-typedef uint32_t unaligned_uint32_t;
-typedef uint16_t unaligned_uint16_t;
 #endif
 
 /**
-- 
2.53.0


  parent reply	other threads:[~2026-09-07 18:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 22:09 [RFC 0/3] eal: make unaligned types really unaligned Stephen Hemminger
2026-09-04 22:09 ` [RFC 1/3] eal: make unaligned " Stephen Hemminger
2026-09-04 22:09 ` [RFC 2/3] net/mlx5: drop unnecessary STRICT_ALIGN Stephen Hemminger
2026-09-05 10:00   ` Morten Brørup
2026-09-04 22:09 ` [RFC 3/3] arm: remove no longer used RTE_ARCH_STRICT_ALIGN Stephen Hemminger
2026-09-06 17:09 ` [PATCH v2 0/5] eal: RTE_PTR_ADD qualifiers and real unaligned types Stephen Hemminger
2026-09-06 17:09   ` [PATCH v2 1/5] test: fix jhash 32 bit key type Stephen Hemminger
2026-09-06 17:09   ` [PATCH v2 2/5] eal: RTE_PTR_ADD/SUB API improvements Stephen Hemminger
2026-09-06 17:09   ` [PATCH v2 3/5] eal: make unaligned really unaligned Stephen Hemminger
2026-09-06 17:09   ` [PATCH v2 4/5] net/mlx5: drop unnecessary STRICT_ALIGN Stephen Hemminger
2026-09-06 17:09   ` [PATCH v2 5/5] arm: remove no longer used RTE_ARCH_STRICT_ALIGN Stephen Hemminger
2026-09-06 20:14   ` [PATCH v2 0/5] eal: RTE_PTR_ADD qualifiers and real unaligned types Morten Brørup
2026-09-07 18:31 ` [PATCH v3 0/5] eal: RTE_PTR_ADD and fix " Stephen Hemminger
2026-09-07 18:31   ` [PATCH v3 1/5] test: fix jhash 32 bit key type Stephen Hemminger
2026-09-07 18:31   ` [PATCH v3 2/5] eal: RTE_PTR_ADD/SUB API improvements Stephen Hemminger
2026-09-07 18:31   ` Stephen Hemminger [this message]
2026-09-07 18:31   ` [PATCH v3 4/5] net/mlx5: drop unnecessary STRICT_ALIGN Stephen Hemminger
2026-09-07 18:31   ` [PATCH v3 5/5] arm: remove no longer used RTE_ARCH_STRICT_ALIGN Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260907183239.629053-4-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox