* [PATCH] uapi: bitops: use UAPI-safe variant of BITS_PER_LONG again (2)
@ 2025-06-30 13:02 Thomas Weißschuh
2025-06-30 14:52 ` Yury Norov
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Weißschuh @ 2025-06-30 13:02 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Vincent Mailhol, Yury Norov,
Rasmus Villemoes
Cc: linux-kernel, Thomas Weißschuh
BITS_PER_LONG does not exist in UAPI headers, so can't be used by the UAPI
__GENMASK(). Instead __BITS_PER_LONG needs to be used.
When __GENMASK() was introduced in commit 3c7a8e190bc5 ("uapi: introduce uapi-friendly macros for GENMASK"),
the code was fine. A broken revert in 1e7933a575ed ("uapi: Revert "bitops: avoid integer overflow in GENMASK(_ULL)"")
introduced the incorrect usage of BITS_PER_LONG.
That was fixed in commit 11fcf368506d ("uapi: bitops: use UAPI-safe variant of BITS_PER_LONG again").
But a broken sync of the kernel headers with the tools/ headers in
commit fc92099902fb ("tools headers: Synchronize linux/bits.h with the kernel sources")
undid the fix.
Reapply the fix and while at it also fix the tools header.
Fixes: fc92099902fb ("tools headers: Synchronize linux/bits.h with the kernel sources")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
include/uapi/linux/bits.h | 4 ++--
tools/include/uapi/linux/bits.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/uapi/linux/bits.h b/include/uapi/linux/bits.h
index 682b406e10679dc8baa188830ab0811e7e3e13e3..a04afef9efca42f062e142fcb33f5d267512b1e5 100644
--- a/include/uapi/linux/bits.h
+++ b/include/uapi/linux/bits.h
@@ -4,9 +4,9 @@
#ifndef _UAPI_LINUX_BITS_H
#define _UAPI_LINUX_BITS_H
-#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (BITS_PER_LONG - 1 - (h))))
+#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (__BITS_PER_LONG - 1 - (h))))
-#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h))))
+#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h))))
#define __GENMASK_U128(h, l) \
((_BIT128((h)) << 1) - (_BIT128(l)))
diff --git a/tools/include/uapi/linux/bits.h b/tools/include/uapi/linux/bits.h
index 682b406e10679dc8baa188830ab0811e7e3e13e3..a04afef9efca42f062e142fcb33f5d267512b1e5 100644
--- a/tools/include/uapi/linux/bits.h
+++ b/tools/include/uapi/linux/bits.h
@@ -4,9 +4,9 @@
#ifndef _UAPI_LINUX_BITS_H
#define _UAPI_LINUX_BITS_H
-#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (BITS_PER_LONG - 1 - (h))))
+#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (__BITS_PER_LONG - 1 - (h))))
-#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h))))
+#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h))))
#define __GENMASK_U128(h, l) \
((_BIT128((h)) << 1) - (_BIT128(l)))
---
base-commit: d0b3b7b22dfa1f4b515fd3a295b3fd958f9e81af
change-id: 20250630-uapi-genmask-d36e3ffc5691
Best regards,
--
Thomas Weißschuh <thomas.weissschuh@linutronix.de>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] uapi: bitops: use UAPI-safe variant of BITS_PER_LONG again (2)
2025-06-30 13:02 [PATCH] uapi: bitops: use UAPI-safe variant of BITS_PER_LONG again (2) Thomas Weißschuh
@ 2025-06-30 14:52 ` Yury Norov
2025-07-01 21:37 ` Yury Norov
0 siblings, 1 reply; 5+ messages in thread
From: Yury Norov @ 2025-06-30 14:52 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: Arnaldo Carvalho de Melo, Vincent Mailhol, Rasmus Villemoes,
linux-kernel
On Mon, Jun 30, 2025 at 03:02:18PM +0200, Thomas Weißschuh wrote:
> BITS_PER_LONG does not exist in UAPI headers, so can't be used by the UAPI
> __GENMASK(). Instead __BITS_PER_LONG needs to be used.
>
> When __GENMASK() was introduced in commit 3c7a8e190bc5 ("uapi: introduce uapi-friendly macros for GENMASK"),
> the code was fine. A broken revert in 1e7933a575ed ("uapi: Revert "bitops: avoid integer overflow in GENMASK(_ULL)"")
> introduced the incorrect usage of BITS_PER_LONG.
> That was fixed in commit 11fcf368506d ("uapi: bitops: use UAPI-safe variant of BITS_PER_LONG again").
> But a broken sync of the kernel headers with the tools/ headers in
> commit fc92099902fb ("tools headers: Synchronize linux/bits.h with the kernel sources")
> undid the fix.
>
> Reapply the fix and while at it also fix the tools header.
>
> Fixes: fc92099902fb ("tools headers: Synchronize linux/bits.h with the kernel sources")
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
Arnaldo, do you want to move it yourself or with my branch?
> ---
> include/uapi/linux/bits.h | 4 ++--
> tools/include/uapi/linux/bits.h | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/uapi/linux/bits.h b/include/uapi/linux/bits.h
> index 682b406e10679dc8baa188830ab0811e7e3e13e3..a04afef9efca42f062e142fcb33f5d267512b1e5 100644
> --- a/include/uapi/linux/bits.h
> +++ b/include/uapi/linux/bits.h
> @@ -4,9 +4,9 @@
> #ifndef _UAPI_LINUX_BITS_H
> #define _UAPI_LINUX_BITS_H
>
> -#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (BITS_PER_LONG - 1 - (h))))
> +#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (__BITS_PER_LONG - 1 - (h))))
>
> -#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h))))
> +#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h))))
>
> #define __GENMASK_U128(h, l) \
> ((_BIT128((h)) << 1) - (_BIT128(l)))
> diff --git a/tools/include/uapi/linux/bits.h b/tools/include/uapi/linux/bits.h
> index 682b406e10679dc8baa188830ab0811e7e3e13e3..a04afef9efca42f062e142fcb33f5d267512b1e5 100644
> --- a/tools/include/uapi/linux/bits.h
> +++ b/tools/include/uapi/linux/bits.h
> @@ -4,9 +4,9 @@
> #ifndef _UAPI_LINUX_BITS_H
> #define _UAPI_LINUX_BITS_H
>
> -#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (BITS_PER_LONG - 1 - (h))))
> +#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (__BITS_PER_LONG - 1 - (h))))
>
> -#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h))))
> +#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h))))
>
> #define __GENMASK_U128(h, l) \
> ((_BIT128((h)) << 1) - (_BIT128(l)))
>
> ---
> base-commit: d0b3b7b22dfa1f4b515fd3a295b3fd958f9e81af
> change-id: 20250630-uapi-genmask-d36e3ffc5691
>
> Best regards,
> --
> Thomas Weißschuh <thomas.weissschuh@linutronix.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] uapi: bitops: use UAPI-safe variant of BITS_PER_LONG again (2)
2025-06-30 14:52 ` Yury Norov
@ 2025-07-01 21:37 ` Yury Norov
2025-07-08 6:26 ` Thomas Weißschuh
0 siblings, 1 reply; 5+ messages in thread
From: Yury Norov @ 2025-07-01 21:37 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: Arnaldo Carvalho de Melo, Vincent Mailhol, Rasmus Villemoes,
linux-kernel
On Mon, Jun 30, 2025 at 10:52:54AM -0400, Yury Norov wrote:
> On Mon, Jun 30, 2025 at 03:02:18PM +0200, Thomas Weißschuh wrote:
> > BITS_PER_LONG does not exist in UAPI headers, so can't be used by the UAPI
> > __GENMASK(). Instead __BITS_PER_LONG needs to be used.
> >
> > When __GENMASK() was introduced in commit 3c7a8e190bc5 ("uapi: introduce uapi-friendly macros for GENMASK"),
> > the code was fine. A broken revert in 1e7933a575ed ("uapi: Revert "bitops: avoid integer overflow in GENMASK(_ULL)"")
> > introduced the incorrect usage of BITS_PER_LONG.
> > That was fixed in commit 11fcf368506d ("uapi: bitops: use UAPI-safe variant of BITS_PER_LONG again").
> > But a broken sync of the kernel headers with the tools/ headers in
> > commit fc92099902fb ("tools headers: Synchronize linux/bits.h with the kernel sources")
> > undid the fix.
> >
> > Reapply the fix and while at it also fix the tools header.
> >
> > Fixes: fc92099902fb ("tools headers: Synchronize linux/bits.h with the kernel sources")
> > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
>
> Acked-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
>
> Arnaldo, do you want to move it yourself or with my branch?
OK, added this in bitmap-for-next together with the MAINTAINERS patch.
Thanks Tomas for looking after that!
Thanks,
Yury
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] uapi: bitops: use UAPI-safe variant of BITS_PER_LONG again (2)
2025-07-01 21:37 ` Yury Norov
@ 2025-07-08 6:26 ` Thomas Weißschuh
2025-07-08 14:47 ` Yury Norov
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Weißschuh @ 2025-07-08 6:26 UTC (permalink / raw)
To: Yury Norov
Cc: Arnaldo Carvalho de Melo, Vincent Mailhol, Rasmus Villemoes,
linux-kernel
On Tue, Jul 01, 2025 at 05:37:40PM -0400, Yury Norov wrote:
> On Mon, Jun 30, 2025 at 10:52:54AM -0400, Yury Norov wrote:
> > On Mon, Jun 30, 2025 at 03:02:18PM +0200, Thomas Weißschuh wrote:
> > > BITS_PER_LONG does not exist in UAPI headers, so can't be used by the UAPI
> > > __GENMASK(). Instead __BITS_PER_LONG needs to be used.
> > >
> > > When __GENMASK() was introduced in commit 3c7a8e190bc5 ("uapi: introduce uapi-friendly macros for GENMASK"),
> > > the code was fine. A broken revert in 1e7933a575ed ("uapi: Revert "bitops: avoid integer overflow in GENMASK(_ULL)"")
> > > introduced the incorrect usage of BITS_PER_LONG.
> > > That was fixed in commit 11fcf368506d ("uapi: bitops: use UAPI-safe variant of BITS_PER_LONG again").
> > > But a broken sync of the kernel headers with the tools/ headers in
> > > commit fc92099902fb ("tools headers: Synchronize linux/bits.h with the kernel sources")
> > > undid the fix.
> > >
> > > Reapply the fix and while at it also fix the tools header.
> > >
> > > Fixes: fc92099902fb ("tools headers: Synchronize linux/bits.h with the kernel sources")
> > > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> >
> > Acked-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
> >
> > Arnaldo, do you want to move it yourself or with my branch?
>
> OK, added this in bitmap-for-next together with the MAINTAINERS patch.
Thanks!
Any chance to get the fix into v6.16 again?
This currently triggers warnings in my code in -next [0], which is intended
to go into v6.17.
[0] https://lore.kernel.org/all/20250708160830.36ddf20f@canb.auug.org.au/
Thomas
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] uapi: bitops: use UAPI-safe variant of BITS_PER_LONG again (2)
2025-07-08 6:26 ` Thomas Weißschuh
@ 2025-07-08 14:47 ` Yury Norov
0 siblings, 0 replies; 5+ messages in thread
From: Yury Norov @ 2025-07-08 14:47 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: Arnaldo Carvalho de Melo, Vincent Mailhol, Rasmus Villemoes,
linux-kernel
On Tue, Jul 08, 2025 at 08:26:49AM +0200, Thomas Weißschuh wrote:
> On Tue, Jul 01, 2025 at 05:37:40PM -0400, Yury Norov wrote:
> > On Mon, Jun 30, 2025 at 10:52:54AM -0400, Yury Norov wrote:
> > > On Mon, Jun 30, 2025 at 03:02:18PM +0200, Thomas Weißschuh wrote:
> > > > BITS_PER_LONG does not exist in UAPI headers, so can't be used by the UAPI
> > > > __GENMASK(). Instead __BITS_PER_LONG needs to be used.
> > > >
> > > > When __GENMASK() was introduced in commit 3c7a8e190bc5 ("uapi: introduce uapi-friendly macros for GENMASK"),
> > > > the code was fine. A broken revert in 1e7933a575ed ("uapi: Revert "bitops: avoid integer overflow in GENMASK(_ULL)"")
> > > > introduced the incorrect usage of BITS_PER_LONG.
> > > > That was fixed in commit 11fcf368506d ("uapi: bitops: use UAPI-safe variant of BITS_PER_LONG again").
> > > > But a broken sync of the kernel headers with the tools/ headers in
> > > > commit fc92099902fb ("tools headers: Synchronize linux/bits.h with the kernel sources")
> > > > undid the fix.
> > > >
> > > > Reapply the fix and while at it also fix the tools header.
> > > >
> > > > Fixes: fc92099902fb ("tools headers: Synchronize linux/bits.h with the kernel sources")
> > > > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> > >
> > > Acked-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
> > >
> > > Arnaldo, do you want to move it yourself or with my branch?
> >
> > OK, added this in bitmap-for-next together with the MAINTAINERS patch.
>
> Thanks!
>
> Any chance to get the fix into v6.16 again?
Yes, just sent a pull request.
> This currently triggers warnings in my code in -next [0], which is intended
> to go into v6.17.
>
> [0] https://lore.kernel.org/all/20250708160830.36ddf20f@canb.auug.org.au/
>
>
> Thomas
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-07-08 14:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-30 13:02 [PATCH] uapi: bitops: use UAPI-safe variant of BITS_PER_LONG again (2) Thomas Weißschuh
2025-06-30 14:52 ` Yury Norov
2025-07-01 21:37 ` Yury Norov
2025-07-08 6:26 ` Thomas Weißschuh
2025-07-08 14:47 ` Yury Norov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).