mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
To: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	 Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	 x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	 Arnd Bergmann <arnd@arndb.de>
Cc: linux-kernel@vger.kernel.org, "Mark Bloch" <mbloch@nvidia.com>,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Subject: [PATCH] x86: Use correct CHECKFLAGS for realmode code
Date: Fri, 22 May 2026 09:03:00 +0200	[thread overview]
Message-ID: <20260522-x86-sparse-boot-v1-1-b94c228d9008@linutronix.de> (raw)

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.

Technically the replacement of -D__x86_64__ is not necessary, as it will
only be added to CHECKFLAGS later in the file.
Replace it anyways for consistency.

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>
---
 arch/x86/Makefile             | 5 +++++
 arch/x86/boot/Makefile        | 1 +
 arch/x86/realmode/rm/Makefile | 1 +
 3 files changed, 7 insertions(+)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 46fec0b08487..bdafa3635dd1 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -61,6 +61,11 @@ REALMODE_CFLAGS += $(cc_stack_align4)
 REALMODE_CFLAGS += $(CLANG_FLAGS)
 export REALMODE_CFLAGS
 
+REALMODE_CHECKFLAGS := $(subst -m64, -m16, \
+		       $(subst -m32, -m16, \
+		       $(subst -D__x86_64__, -D__i386__, \
+		       $(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>


             reply	other threads:[~2026-05-22  7:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-22  7:03 Thomas Weißschuh [this message]
2026-05-24  7:01 ` Mark Bloch

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=20260522-x86-sparse-boot-v1-1-b94c228d9008@linutronix.de \
    --to=thomas.weissschuh@linutronix.de \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=mingo@redhat.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.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

all inboxes | Powered by JetHome®