include/asm-generic/bitsperlong.h | 8 -------- 1 file changed, 8 deletions(-)
A FIXME in this header asks to fix x86-64 and reenable the check
between BITS_PER_LONG and __BITS_PER_LONG. However, this check
cannot be enabled because the two values can legitimately differ
when building the compat vDSO.
BITS_PER_LONG is derived from CONFIG_64BIT and reflects the
kernel's configured word size, while __BITS_PER_LONG reflects
the compiler target ABI.
The existing sanity checks validate __BITS_PER_LONG against the
actual C type 'long'. For regular kernel builds, this also detects
mismatches between BITS_PER_LONG and __BITS_PER_LONG, since
BITS_PER_LONG matches the kernel's native word size.
Remove the dead check and the misleading FIXME.
Signed-off-by: Fang Xieyan <fangxy@xiaopeng.com>
---
The preprocessed output of this header is unchanged in 64-bit, 32-bit
and compat vDSO (-m32 with CONFIG_64BIT) builds. Build-tested on x86_64
defconfig (IA32_EMULATION=y), including the vdso32 build.
include/asm-generic/bitsperlong.h | 8 --------
1 file changed, 8 deletions(-)
diff --git a/include/asm-generic/bitsperlong.h b/include/asm-generic/bitsperlong.h
index 90e8aeebfd2f..5183b50d3080 100644
--- a/include/asm-generic/bitsperlong.h
+++ b/include/asm-generic/bitsperlong.h
@@ -11,14 +11,6 @@
#define BITS_PER_LONG 32
#endif /* CONFIG_64BIT */
-/*
- * FIXME: The check currently breaks x86-64 build, so it's
- * temporarily disabled. Please fix x86-64 and reenable
- */
-#if 0 && BITS_PER_LONG != __BITS_PER_LONG
-#error Inconsistent word size. Check asm/bitsperlong.h
-#endif
-
#if __CHAR_BIT__ * __SIZEOF_LONG__ != __BITS_PER_LONG
#error Inconsistent word size. Check asm/bitsperlong.h
#endif
--
2.50.1
On Sat, Nov 21, 2026, at 15:04, Fang Xieyan wrote:
> A FIXME in this header asks to fix x86-64 and reenable the check
> between BITS_PER_LONG and __BITS_PER_LONG. However, this check
> cannot be enabled because the two values can legitimately differ
> when building the compat vDSO.
I think the correct fix would be to stop the x86 vdso from including
this header. The general rule is that any VDSO code should only
include headers from include/vdso/, but not include/linux or include/asm.
Arnd
On Mon, Nov 23, 2026, at 09:08, Arnd Bergmann wrote: > I think the correct fix would be to stop the x86 vdso from including > this header. The general rule is that any VDSO code should only > include headers from include/vdso/, but not include/linux or > include/asm. Thanks, that makes sense. The compat vDSO ABI difference is valid, but it should not require the VDSO to include this kernel-internal header. I'll drop this removal. I re-enabled the check in a test build to see what actually breaks. On x86-64 the vdso32 build passes, because fake_32bit_build.h undefines CONFIG_64BIT to fake a 32-bit configuration. The failures are the realmode build (32-bit code with the real 64-bit config), and the arm64/parisc compat vDSO builds, which include this header via <vdso/gettime.h> -> <linux/types.h> without faking the config. I'll investigate the include chains and look into removing the dependencies on include/linux and include/asm before revisiting the check. Thanks, Fang Xieyan
Hi Arnd, Thomas,
A follow-up with the build evidence I promised.
I temporarily re-enabled the check and replayed the exact saved
compile commands for each x86-64 build scenario:
- The check fails for 23 objects in arch/x86/boot and 12 objects
in arch/x86/realmode. They are compiled with -m16 (which uses
the 32-bit C data model) but retain the actual 64-bit kernel
configuration, so BITS_PER_LONG is 64 while __BITS_PER_LONG is
32. Both paths reach the header via <linux/types.h>: boot.h
includes it directly, while the realmode path reaches it
through <linux/linkage.h> -> <asm/ibt.h>.
- boot/compressed (-m64) and vdso64 pass. vdso32 also passes
because its build force-includes fake_32bit_build.h, which
undefines CONFIG_64BIT and defines CONFIG_X86_32.
One correction to my earlier reply: boot fails as well, not just
realmode. I missed it because bzImage is only built after vmlinux,
and the realmode failure stopped the build before boot was reached.
So there seem to be two separate issues:
1. boot/realmode: 32-bit C code compiled with -m16 while
retaining the 64-bit kernel configuration.
2. vDSO header isolation: the sanctioned include/vdso headers
still include <linux/types.h>, and the <linux/types.h>
dependency chain eventually reaches the kernel-internal
include/asm-generic/bitsperlong.h. I verified this with
compiler -H traces.
Would you treat these as separate issues? In particular, should
the BITS_PER_LONG check be scoped to native kernel compilation,
with boot/realmode handled separately?
For the vDSO, would you prefer VDSO-specific basic type
definitions, or a sanitized subset of UAPI types that can be used
without pulling in kernel-internal headers?
Thomas, is there any ongoing work in this area?
Thanks,
Fang Xieyan
© 2016 - 2026 Red Hat, Inc.