linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* arm64: kernel/sys.c - silence initialization warnings.
@ 2021-03-12  9:55 Valdis Klētnieks
  2021-03-15 11:14 ` Catalin Marinas
  0 siblings, 1 reply; 4+ messages in thread
From: Valdis Klētnieks @ 2021-03-12  9:55 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon; +Cc: linux-arm-kernel, linux-kernel

Building arch/arm64/kernel/sys.o with W=1 throws over 300 warnings:

/usr/src/linux-next/arch/arm64/kernel/sys.c:56:40: warning: initialized field overwritten [-Woverride-init]
   56 | #define __SYSCALL(nr, sym)      [nr] = __arm64_##sym,
      |                                        ^~~~~~~~
/usr/src/linux-next/include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro '__SYSCALL'
   29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys)
      |                                     ^~~~~~~~~
/usr/src/linux-next/include/uapi/asm-generic/unistd.h:34:1: note: in expansion of macro '__SC_COMP'
   34 | __SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup)
      | ^~~~~~~~~

We know that's pretty much the file's purpose in life, so tell the
build system to not remind us.  This makes the 1 other warning a
lot more noticeable. 

Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>

diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index ed65576ce710..916b21d2b35b 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -8,6 +8,7 @@ CFLAGS_armv8_deprecated.o := -I$(src)
 CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE)
 CFLAGS_REMOVE_insn.o = $(CC_FLAGS_FTRACE)
 CFLAGS_REMOVE_return_address.o = $(CC_FLAGS_FTRACE)
+CFLAGS_sys.o += $(call cc-disable-warning, override-init)
 
 # Object file lists.
 obj-y			:= debug-monitors.o entry.o irq.o fpsimd.o		\


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: arm64: kernel/sys.c - silence initialization warnings.
  2021-03-12  9:55 arm64: kernel/sys.c - silence initialization warnings Valdis Klētnieks
@ 2021-03-15 11:14 ` Catalin Marinas
  2021-03-15 19:23   ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Catalin Marinas @ 2021-03-15 11:14 UTC (permalink / raw)
  To: Valdis Klētnieks; +Cc: Will Deacon, linux-arm-kernel, linux-kernel

On Fri, Mar 12, 2021 at 04:55:46AM -0500, Valdis Klētnieks wrote:
> Building arch/arm64/kernel/sys.o with W=1 throws over 300 warnings:
> 
> /usr/src/linux-next/arch/arm64/kernel/sys.c:56:40: warning: initialized field overwritten [-Woverride-init]
>    56 | #define __SYSCALL(nr, sym)      [nr] = __arm64_##sym,
>       |                                        ^~~~~~~~
> /usr/src/linux-next/include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro '__SYSCALL'
>    29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys)
>       |                                     ^~~~~~~~~
> /usr/src/linux-next/include/uapi/asm-generic/unistd.h:34:1: note: in expansion of macro '__SC_COMP'
>    34 | __SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup)
>       | ^~~~~~~~~
> 
> We know that's pretty much the file's purpose in life, so tell the
> build system to not remind us.  This makes the 1 other warning a
> lot more noticeable. 
> 
> Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
> 
> diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
> index ed65576ce710..916b21d2b35b 100644
> --- a/arch/arm64/kernel/Makefile
> +++ b/arch/arm64/kernel/Makefile
> @@ -8,6 +8,7 @@ CFLAGS_armv8_deprecated.o := -I$(src)
>  CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE)
>  CFLAGS_REMOVE_insn.o = $(CC_FLAGS_FTRACE)
>  CFLAGS_REMOVE_return_address.o = $(CC_FLAGS_FTRACE)
> +CFLAGS_sys.o += $(call cc-disable-warning, override-init)

We do similar initialisation in arch/arm64/kernel/sys32.c and
arch/arm64/kernel/traps.c for example. It's a pretty common pattern
throughout the kernel.

So we either treat W=1 output as diff against the vanilla kernel when
checking new patches or we remove override-init altogether from W=1.
Mark Rutland pointed me to an older thread:

https://lore.kernel.org/linux-arm-kernel/20190809083251.GA48423@lakrids.cambridge.arm.com/

-- 
Catalin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: arm64: kernel/sys.c - silence initialization warnings.
  2021-03-15 11:14 ` Catalin Marinas
@ 2021-03-15 19:23   ` Christoph Hellwig
  2021-03-16  0:30     ` Valdis Klētnieks
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2021-03-15 19:23 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Valdis Kl??tnieks, Will Deacon, linux-arm-kernel, linux-kernel

On Mon, Mar 15, 2021 at 11:14:34AM +0000, Catalin Marinas wrote:
> We do similar initialisation in arch/arm64/kernel/sys32.c and
> arch/arm64/kernel/traps.c for example. It's a pretty common pattern
> throughout the kernel.
> 
> So we either treat W=1 output as diff against the vanilla kernel when
> checking new patches or we remove override-init altogether from W=1.
> Mark Rutland pointed me to an older thread:

Please just remove the override-init warning, it is not helpful at all.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: arm64: kernel/sys.c - silence initialization warnings.
  2021-03-15 19:23   ` Christoph Hellwig
@ 2021-03-16  0:30     ` Valdis Klētnieks
  0 siblings, 0 replies; 4+ messages in thread
From: Valdis Klētnieks @ 2021-03-16  0:30 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Catalin Marinas, Will Deacon, linux-arm-kernel, linux-kernel

On Mon, 15 Mar 2021 19:23:00 -0000, Christoph Hellwig said:
> On Mon, Mar 15, 2021 at 11:14:34AM +0000, Catalin Marinas wrote:
> > We do similar initialisation in arch/arm64/kernel/sys32.c and
> > arch/arm64/kernel/traps.c for example. It's a pretty common pattern
> > throughout the kernel.
> > 
> > So we either treat W=1 output as diff against the vanilla kernel when
> > checking new patches or we remove override-init altogether from W=1.
> > Mark Rutland pointed me to an older thread:
>
> Please just remove the override-init warning, it is not helpful at all.

The tl;dr: Christoph is *probably* correct that it's not flagging any actual
bugs. And since *my* interest is "get the kernel tree to a point where W=1
or sparse throwing a warning is something worth looking at",  I'm not opposed
to a patch to remove it from W=1 tree-wide if it has essentially zero chance of
flagging an actual bug.

The longer version:

So I did a quick analysis...

For an x86_64 allmodconfig, there's not that many left:

     16 drivers/ata/ahci.h
      1 drivers/ata/pata_atiixp.c
      1 drivers/ata/pata_cs5520.c
      1 drivers/ata/pata_cs5530.c
      1 drivers/ata/pata_sc1200.c
      1 drivers/ata/pata_serverworks.c
      1 drivers/ata/sata_mv.c
      4 drivers/ata/sata_nv.c
      1 drivers/ata/sata_sil24.c
      1 drivers/block/drbd/drbd_main.c
      6 drivers/gpu/drm/amd/amdgpu/../include/asic_reg/dce/dce_6_0_d.h
      2 drivers/gpu/drm/amd/amdgpu/../include/asic_reg/dce/dce_6_0_sh_mask.h
      1 drivers/input/serio/i8042-x86ia64io.h
      1 include/linux/blkdev.h
      1 kernel/bpf/btf.c
      4 kernel/time/hrtimer.c
      1 lib/errname.c

The drivers/ata *.c warnings all appear to be the same type of thing:

static struct scsi_host_template serverworks_osb4_sht = {
        ATA_BMDMA_SHT(DRV_NAME),
        .sg_tablesize   = LIBATA_DUMB_MAX_PRD,
};

The preprocessor macro defining the struct contents, and then
overriding one predefined value. So that's half of x64_64 done right there.

There's a few corners still need looking at, like why drivers/ata/ahci.h
throws 16 warnings on x64, but 30 on arm and 28 on arm64, and why
there's 4 warnings on include/linux/stddef.h on arm64 but not arm or x86.

But the number is certainly small enough that it's only a day or two's work
at most to check every single one.  If I go through the rest of x86 and arm
and they're all legit, I'll send a patch to nuke it kernel-wide rather than piecemeal.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-16  0:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-12  9:55 arm64: kernel/sys.c - silence initialization warnings Valdis Klētnieks
2021-03-15 11:14 ` Catalin Marinas
2021-03-15 19:23   ` Christoph Hellwig
2021-03-16  0:30     ` Valdis Klētnieks

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).