arch/x86/Makefile | 3 +++ arch/x86/boot/Makefile | 1 + arch/x86/realmode/rm/Makefile | 1 + 3 files changed, 5 insertions(+)
Currently the CHECKFLAGS from the normal build are also used for the
realmode code. This leads to inconsistent flags confusing sparse and
the logic in the kernel headers. Since recently this inconsistent state
is detected by asm-generic/bitsperlong.h, triggering a warning.
Fix the CHECKFLAGS to let sparse properly check this code and
also avoid the warning.
At this point -m32/-m64 and -D__i386__/-D__x86_64__ are not yet added to
CHECKFLAGS, so no replacement is necessary.
Reported-by: Mark Bloch <mbloch@nvidia.com>
Closes: https://lore.kernel.org/lkml/3bbcf456-322c-46f9-b238-88fb8ad227b2@nvidia.com/
Fixes: 62357a5888ea ("asm-generic/bitsperlong.h: Add sanity checks for __BITS_PER_LONG")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
Changes in v2:
- Drop -m32/-m64 replacement logic
- export REALMODE_CHECKFLAGS
- Link to v1: https://patch.msgid.link/20260522-x86-sparse-boot-v1-1-b94c228d9008@linutronix.de
---
arch/x86/Makefile | 3 +++
arch/x86/boot/Makefile | 1 +
arch/x86/realmode/rm/Makefile | 1 +
3 files changed, 5 insertions(+)
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 46fec0b08487..d3678483c486 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -61,6 +61,9 @@ REALMODE_CFLAGS += $(cc_stack_align4)
REALMODE_CFLAGS += $(CLANG_FLAGS)
export REALMODE_CFLAGS
+REALMODE_CHECKFLAGS := $(CHECKFLAGS) -m16 -D__i386__
+export REALMODE_CHECKFLAGS
+
# BITS is used as extension for files which are available in a 32 bit
# and a 64 bit version to simplify shared Makefiles.
# e.g.: obj-y += foo_$(BITS).o
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
index 3f9fb3698d66..20b569930229 100644
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -55,6 +55,7 @@ KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
KBUILD_CFLAGS += $(CONFIG_CC_IMPLICIT_FALLTHROUGH)
+CHECKFLAGS := $(REALMODE_CHECKFLAGS)
$(obj)/bzImage: asflags-y := $(SVGA_MODE)
diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
index a0fb39abc5c8..725c5ef6cdf1 100644
--- a/arch/x86/realmode/rm/Makefile
+++ b/arch/x86/realmode/rm/Makefile
@@ -67,3 +67,4 @@ KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP -D_WAKEUP \
-I$(srctree)/arch/x86/boot
KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
+CHECKFLAGS := $(REALMODE_CHECKFLAGS)
---
base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
change-id: 20260521-x86-sparse-boot-cb427318607d
Best regards,
--
Thomas Weißschuh <thomas.weissschuh@linutronix.de>
On Mon, Jun 01, 2026 at 08:44:48AM +0200, Thomas Weißschuh wrote:
> Currently the CHECKFLAGS from the normal build are also used for the
> realmode code. This leads to inconsistent flags confusing sparse and
> the logic in the kernel headers. Since recently this inconsistent state
> is detected by asm-generic/bitsperlong.h, triggering a warning.
>
> Fix the CHECKFLAGS to let sparse properly check this code and
> also avoid the warning.
>
> At this point -m32/-m64 and -D__i386__/-D__x86_64__ are not yet added to
> CHECKFLAGS, so no replacement is necessary.
>
> Reported-by: Mark Bloch <mbloch@nvidia.com>
> Closes: https://lore.kernel.org/lkml/3bbcf456-322c-46f9-b238-88fb8ad227b2@nvidia.com/
> Fixes: 62357a5888ea ("asm-generic/bitsperlong.h: Add sanity checks for __BITS_PER_LONG")
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Please ignore thispatch . It doesn't work correctly for the peculiar build
setup of arch/x86/boot/compressed/.
I'll try to come up with something better.
Thomas
© 2016 - 2026 Red Hat, Inc.