patch 'bitops: clarify power-of-two alignment limits' has been queued to stable release 24.11.9
luca.boccassi at gmail.com
luca.boccassi at gmail.com
Fri Nov 20 21:29:32 CET 2026
Hi,
FYI, your patch has been queued to stable release 24.11.9
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/22/26. 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/bluca/dpdk-stable
This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/f1c1d01fecacddf24e0718a0c6fc99b9701936ad
Thanks.
Luca Boccassi
---
>From f1c1d01fecacddf24e0718a0c6fc99b9701936ad Mon Sep 17 00:00:00 2001
From: Jack Bond-Preston <jack.bond-preston at foss.arm.com>
Date: Mon, 16 Nov 2026 14:37:59 +0000
Subject: [PATCH] bitops: clarify power-of-two alignment limits
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[ upstream commit c3377176033715a1487228e111cd7129caa00888 ]
rte_align32pow2 and rte_align62pow2 will overflow and return incorrect
values for input values exceeding 1<<31 and 1<<63, respectively. There
is no way to return a valid result here: the next power of two above
these values is unrepresentable with 32/64 bit unsigned integers.
Adjust the documentation for these functions to clarify that input
values above these limits will return invalid results, and thus should
not be provided to these functions. Additionally, document an existing
edge case of the implementation: when the input is 0, it returns 0 (not
a power of 2).
Fixes: 7253e3d2a5b6 ("bitops: move bit count functions")
Reported-by: Mark Bulatov <ms.bulatov7 at gmail.com>
Signed-off-by: Jack Bond-Preston <jack.bond-preston at foss.arm.com>
Acked-by: Morten Brørup <mb at smartsharesystems.com>
---
lib/eal/include/rte_bitops.h | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/lib/eal/include/rte_bitops.h b/lib/eal/include/rte_bitops.h
index 09c4aba794..e0054e50fa 100644
--- a/lib/eal/include/rte_bitops.h
+++ b/lib/eal/include/rte_bitops.h
@@ -1231,10 +1231,16 @@ rte_is_power_of_2(uint32_t n)
* Aligns input parameter to the next power of 2
*
* @param x
- * The integer value to align
+ * The integer value to align.
+ * Must be less than or equal to 1 << 31 (0x80000000).
*
* @return
- * The smallest power of 2 which is greater than or equal to @c x.
+ * The smallest power of 2 which is greater than or equal to @c x,
+ * or 0 if @c x is 0.
+ *
+ * @note If the input parameter exceeds 1 << 31 (0x80000000),
+ * then the expected result is unrepresentable and the return value is invalid.
+ * @note For the input value 0, this function returns 0, which is not a power of 2.
*/
static inline uint32_t
rte_align32pow2(uint32_t x)
@@ -1266,10 +1272,16 @@ rte_align32prevpow2(uint32_t x)
* Aligns 64b input parameter to the next power of 2
*
* @param v
- * The 64b value to align
+ * The 64b value to align.
+ * Must be less than or equal to 1 << 63 (0x8000000000000000).
*
* @return
- * The smallest power of 2 which is greater than or equal to @c v.
+ * The smallest power of 2 which is greater than or equal to @c v,
+ * or 0 if @c v is 0.
+ *
+ * @note If the input parameter exceeds 1 << 63 (0x8000000000000000),
+ * then the expected result is unrepresentable and the return value is invalid.
+ * @note For the input value 0, this function returns 0, which is not a power of 2.
*/
static inline uint64_t
rte_align64pow2(uint64_t v)
--
2.47.3
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2026-11-20 20:29:05.338120432 +0000
+++ 0003-bitops-clarify-power-of-two-alignment-limits.patch 2026-11-20 20:29:05.168111711 +0000
@@ -1 +1 @@
-From c3377176033715a1487228e111cd7129caa00888 Mon Sep 17 00:00:00 2001
+From f1c1d01fecacddf24e0718a0c6fc99b9701936ad Mon Sep 17 00:00:00 2001
@@ -8,0 +9,2 @@
+[ upstream commit c3377176033715a1487228e111cd7129caa00888 ]
+
@@ -21 +22,0 @@
-Cc: stable at dpdk.org
@@ -31 +32 @@
-index 45255b68aa..24119c77be 100644
+index 09c4aba794..e0054e50fa 100644
@@ -34 +35 @@
-@@ -1261,10 +1261,16 @@ rte_is_power_of_2(uint32_t n)
+@@ -1231,10 +1231,16 @@ rte_is_power_of_2(uint32_t n)
@@ -53 +54 @@
-@@ -1296,10 +1302,16 @@ rte_align32prevpow2(uint32_t x)
+@@ -1266,10 +1272,16 @@ rte_align32prevpow2(uint32_t x)
More information about the stable
mailing list