bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] treewide: Remove unnamed static initializations to 0
       [not found] <20210910225207.3272766-1-keescook@chromium.org>
@ 2021-09-10 23:23 ` Alexei Starovoitov
  2021-09-11  2:08   ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: Alexei Starovoitov @ 2021-09-10 23:23 UTC (permalink / raw)
  To: Kees Cook; +Cc: Linus Torvalds, linux-kernel, bpf, daniel, andrii

On Fri, Sep 10, 2021 at 03:52:07PM -0700, Kees Cook wrote:
> GCC 4.9 does not like having struct assignments to 0 when members may be
> compound types. For example, there are 186 instances of these kinds of
> errors:
> 
> drivers/virtio/virtio_vdpa.c:146:9: error: missing braces around initializer [-Werror=missing-braces ]
> drivers/cxl/core/regs.c:40:17: error: missing braces around initializer [-Werror=missing-braces]
> 
> Since "= { 0 }" and "= { }" have the same meaning ("incomplete
> initializer") they will both initialize the given variable to zero
> (modulo padding games).
> 
> After this change, I can almost build the "allmodconfig" target with
> GCC 4.9 again.
> 
> Signed-off-by: Kees Cook <keescook@chromium.org>

...

>  .../selftests/bpf/prog_tests/perf_branches.c  |   4 +-
>  .../selftests/bpf/prog_tests/sk_lookup.c      |  12 +-
>  .../selftests/bpf/prog_tests/sockmap_ktls.c   |   2 +-
>  .../selftests/bpf/prog_tests/sockmap_listen.c |   4 +-
>  .../selftests/bpf/progs/test_sk_assign.c      |   6 +-
>  .../selftests/bpf/progs/test_xdp_vlan.c       |   8 +-

Those have nothing to do with GCC. They are compiled with clang with -target bpf.
Did you check that bpf selftests still pass?
We've had issues with older clang generating different code with zero and non-zero
assignments and libbpf was confused.
It should all work now, but please run the tests.

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

* Re: [PATCH] treewide: Remove unnamed static initializations to 0
  2021-09-10 23:23 ` [PATCH] treewide: Remove unnamed static initializations to 0 Alexei Starovoitov
@ 2021-09-11  2:08   ` Kees Cook
  0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2021-09-11  2:08 UTC (permalink / raw)
  To: Alexei Starovoitov; +Cc: Linus Torvalds, linux-kernel, bpf, daniel, andrii

On Fri, Sep 10, 2021 at 04:23:03PM -0700, Alexei Starovoitov wrote:
> On Fri, Sep 10, 2021 at 03:52:07PM -0700, Kees Cook wrote:
> > GCC 4.9 does not like having struct assignments to 0 when members may be
> > compound types. For example, there are 186 instances of these kinds of
> > errors:
> > 
> > drivers/virtio/virtio_vdpa.c:146:9: error: missing braces around initializer [-Werror=missing-braces ]
> > drivers/cxl/core/regs.c:40:17: error: missing braces around initializer [-Werror=missing-braces]
> > 
> > Since "= { 0 }" and "= { }" have the same meaning ("incomplete
> > initializer") they will both initialize the given variable to zero
> > (modulo padding games).
> > 
> > After this change, I can almost build the "allmodconfig" target with
> > GCC 4.9 again.
> > 
> > Signed-off-by: Kees Cook <keescook@chromium.org>
> 
> ...
> 
> >  .../selftests/bpf/prog_tests/perf_branches.c  |   4 +-
> >  .../selftests/bpf/prog_tests/sk_lookup.c      |  12 +-
> >  .../selftests/bpf/prog_tests/sockmap_ktls.c   |   2 +-
> >  .../selftests/bpf/prog_tests/sockmap_listen.c |   4 +-
> >  .../selftests/bpf/progs/test_sk_assign.c      |   6 +-
> >  .../selftests/bpf/progs/test_xdp_vlan.c       |   8 +-
> 
> Those have nothing to do with GCC. They are compiled with clang with -target bpf.
> Did you check that bpf selftests still pass?
> We've had issues with older clang generating different code with zero and non-zero
> assignments and libbpf was confused.
> It should all work now, but please run the tests.

Sure! I think selftests/bpf/config is missing:

CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_INFO_BTF=y

I can't get much further, though:

$ make -C tools/testing/selftests gen_tar TARGETS="bpf" FORMAT=.xz
make: Entering directory '/srv/code/tools/testing/selftests'
make --no-builtin-rules ARCH=x86 -C ../../.. headers_install
make[1]: Entering directory '/srv/code'
  INSTALL ./usr/include
make[1]: Leaving directory '/srv/code'
make: *** [Makefile:162: all] Error 1
make: Leaving directory '/srv/code/tools/testing/selftests'

I'm not sure what's breaking ...

-- 
Kees Cook

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

end of thread, other threads:[~2021-09-11  2:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20210910225207.3272766-1-keescook@chromium.org>
2021-09-10 23:23 ` [PATCH] treewide: Remove unnamed static initializations to 0 Alexei Starovoitov
2021-09-11  2:08   ` Kees Cook

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