[patch 1/2] x86/vdso: Tweak CHECKFLAGS for 32-bit VDSO build

Thomas Gleixner posted 2 patches 3 weeks, 3 days ago
[patch 1/2] x86/vdso: Tweak CHECKFLAGS for 32-bit VDSO build
Posted by Thomas Gleixner 3 weeks, 3 days ago
Sparse complains about a too large shift in the VDSO32 source file:

  arch/x86/entry/vdso/vdso32/vclock_gettime.c: note: in included file (through /home/tglx/work/kernel/tip/tip/arch/x86/entry/vdso/vdso32/../vclock_gettime.c):
  arch/x86/entry/vdso/vdso32/../../../../../lib/vdso/gettimeofday.c:454:26: warning: shift too big (40) for type unsigned long

That's because sparse is invoked with -D__x86_64__ -m64 on the command
line, which causes it to use __BITS_PER_LONG = 64. That causes __GENMASK()
to use a way too big shift value.

Give the CHECKFLAGS which are handed to sparse a similar treatment as
KBUILD_CFLAGS get for the 32-bit VDSO build.

Signed-off-by: Thomas Gleixner <tglx@kernel.org>
---
 arch/x86/entry/vdso/Makefile |    4 ++++
 1 file changed, 4 insertions(+)

--- a/arch/x86/entry/vdso/Makefile
+++ b/arch/x86/entry/vdso/Makefile
@@ -144,6 +144,10 @@ endif
 
 $(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
 
+CHECKFLAGS_32 := $(subst -m64,-m32,$(CHECKFLAGS))
+CHECKFLAGS_32 := $(subst -D__x86_64__,-D__i386__,$(CHECKFLAGS_32))
+$(obj)/vdso32.so.dbg: CHECKFLAGS = $(CHECKFLAGS_32)
+
 $(obj)/vdso32.so.dbg: $(obj)/vdso32/vdso32.lds $(vobjs32) FORCE
 	$(call if_changed,vdso_and_check)
Re: [patch 1/2] x86/vdso: Tweak CHECKFLAGS for 32-bit VDSO build
Posted by Thomas Weißschuh 3 weeks, 2 days ago
On Sat, Jan 17, 2026 at 10:58:25PM +0100, Thomas Gleixner wrote:
> Sparse complains about a too large shift in the VDSO32 source file:
> 
>   arch/x86/entry/vdso/vdso32/vclock_gettime.c: note: in included file (through /home/tglx/work/kernel/tip/tip/arch/x86/entry/vdso/vdso32/../vclock_gettime.c):
>   arch/x86/entry/vdso/vdso32/../../../../../lib/vdso/gettimeofday.c:454:26: warning: shift too big (40) for type unsigned long
> 
> That's because sparse is invoked with -D__x86_64__ -m64 on the command
> line, which causes it to use __BITS_PER_LONG = 64. That causes __GENMASK()
> to use a way too big shift value.
> 
> Give the CHECKFLAGS which are handed to sparse a similar treatment as
> KBUILD_CFLAGS get for the 32-bit VDSO build.
> 
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>

Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>

> ---
>  arch/x86/entry/vdso/Makefile |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> --- a/arch/x86/entry/vdso/Makefile
> +++ b/arch/x86/entry/vdso/Makefile
> @@ -144,6 +144,10 @@ endif
>  
>  $(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
>  
> +CHECKFLAGS_32 := $(subst -m64,-m32,$(CHECKFLAGS))
> +CHECKFLAGS_32 := $(subst -D__x86_64__,-D__i386__,$(CHECKFLAGS_32))
> +$(obj)/vdso32.so.dbg: CHECKFLAGS = $(CHECKFLAGS_32)

It would be nice if we had a strict variant of $(subst ...) which errors
out if nothing is substituted.

> +
>  $(obj)/vdso32.so.dbg: $(obj)/vdso32/vdso32.lds $(vobjs32) FORCE
>  	$(call if_changed,vdso_and_check)
>  
> 
Re: [patch 1/2] x86/vdso: Tweak CHECKFLAGS for 32-bit VDSO build
Posted by Thomas Gleixner 2 weeks, 5 days ago
On Mon, Jan 19 2026 at 08:18, Thomas Weißschuh wrote:
> On Sat, Jan 17, 2026 at 10:58:25PM +0100, Thomas Gleixner wrote:
>>  $(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
>>  
>> +CHECKFLAGS_32 := $(subst -m64,-m32,$(CHECKFLAGS))
>> +CHECKFLAGS_32 := $(subst -D__x86_64__,-D__i386__,$(CHECKFLAGS_32))
>> +$(obj)/vdso32.so.dbg: CHECKFLAGS = $(CHECKFLAGS_32)
>
> It would be nice if we had a strict variant of $(subst ...) which errors
> out if nothing is substituted.

Which would fail a arch=i386 build then, no? :)