Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Yonghong Song <yhs@fb.com>
Cc: Andrii Nakryiko <andriin@fb.com>, bpf <bpf@vger.kernel.org>,
	Networking <netdev@vger.kernel.org>,
	Alexei Starovoitov <ast@fb.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH v2 bpf-next 2/5] selftests/bpf: test TYPE_EXISTS and TYPE_SIZE CO-RE relocations
Date: Wed, 19 Aug 2020 12:29:49 -0700	[thread overview]
Message-ID: <CAEf4Bzb=6hpK_tURacWUKB7guQN-v3mfOM6sFWiiqbo32L4_yg@mail.gmail.com> (raw)
In-Reply-To: <8840d113-86bb-bd55-b97c-1d5a869472fe@fb.com>

On Wed, Aug 19, 2020 at 9:31 AM Yonghong Song <yhs@fb.com> wrote:
>
>
>
> On 8/18/20 10:28 PM, Andrii Nakryiko wrote:
> > Add selftests for TYPE_EXISTS and TYPE_SIZE relocations, testing correctness
> > of relocations and handling of type compatiblity/incompatibility.
> >
> > If __builtin_preserve_type_info() is not supported by compiler, skip tests.
> >
> > Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> > ---
> >   .../selftests/bpf/prog_tests/core_reloc.c     | 125 +++++++++--
> >   .../bpf/progs/btf__core_reloc_type_based.c    |   3 +
> >   ...btf__core_reloc_type_based___all_missing.c |   3 +
> >   .../btf__core_reloc_type_based___diff_sz.c    |   3 +
> >   ...f__core_reloc_type_based___fn_wrong_args.c |   3 +
> >   .../btf__core_reloc_type_based___incompat.c   |   3 +
> >   .../selftests/bpf/progs/core_reloc_types.h    | 203 +++++++++++++++++-
> >   .../bpf/progs/test_core_reloc_kernel.c        |   2 +
> >   .../bpf/progs/test_core_reloc_type_based.c    | 125 +++++++++++
> >   9 files changed, 448 insertions(+), 22 deletions(-)
> >   create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_type_based.c
> >   create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_type_based___all_missing.c
> >   create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_type_based___diff_sz.c
> >   create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_type_based___fn_wrong_args.c
> >   create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_type_based___incompat.c
> >   create mode 100644 tools/testing/selftests/bpf/progs/test_core_reloc_type_based.c
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/core_reloc.c b/tools/testing/selftests/bpf/prog_tests/core_reloc.c
> > index 4d650e99be28..b775ce0ede41 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/core_reloc.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/core_reloc.c
> > @@ -177,14 +177,13 @@
> >       .fails = true,                                                  \
> >   }
> >
> [...]
> > +/* func_proto with incompatible signature */
> > +typedef void (*func_proto_typedef___fn_wrong_ret1)(long);
> > +typedef int * (*func_proto_typedef___fn_wrong_ret2)(long);
> > +typedef struct { int x; } int_struct_typedef;
> > +typedef int_struct_typedef (*func_proto_typedef___fn_wrong_ret3)(long);
> > +typedef int (*func_proto_typedef___fn_wrong_arg)(void *);
> > +typedef int (*func_proto_typedef___fn_wrong_arg_cnt1)(long, long);
> > +typedef int (*func_proto_typedef___fn_wrong_arg_cnt2)(void);
> > +
> > +struct core_reloc_type_based___fn_wrong_args {
> > +     /* one valid type to make sure relos still work */
> > +     struct a_struct f1;
> > +     func_proto_typedef___fn_wrong_ret1 f2;
> > +     func_proto_typedef___fn_wrong_ret2 f3;
> > +     func_proto_typedef___fn_wrong_ret3 f4;
> > +     func_proto_typedef___fn_wrong_arg f5;
> > +     func_proto_typedef___fn_wrong_arg_cnt1 f6;
> > +     func_proto_typedef___fn_wrong_arg_cnt2 f7;
> > +};
> > +
>
> empty line at the end of file?

you cut the line showing which file it is, so I had to guess :) but fixed

>
> > diff --git a/tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c b/tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c
> > index aba928fd60d3..145028b52ad8 100644
> > --- a/tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c
> > +++ b/tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c
> > @@ -3,6 +3,7 @@
> >
> >   #include <linux/bpf.h>
> >   #include <stdint.h>
> > +#include <stdbool.h>
> >   #include <bpf/bpf_helpers.h>
> >   #include <bpf/bpf_core_read.h>
> >
> > @@ -11,6 +12,7 @@ char _license[] SEC("license") = "GPL";
> >   struct {
> >       char in[256];
> >       char out[256];
> > +     bool skip;
> >       uint64_t my_pid_tgid;
> >   } data = {};
> >
> [...]
> > +
> > +SEC("raw_tracepoint/sys_enter")
> > +int test_core_type_based(void *ctx)
> > +{
> > +#if __has_builtin(__builtin_preserve_type_info)
> > +     struct core_reloc_type_based_output *out = (void *)&data.out;
> > +
> > +     out->struct_exists = bpf_core_type_exists(struct a_struct);
> > +     out->union_exists = bpf_core_type_exists(union a_union);
> > +     out->enum_exists = bpf_core_type_exists(enum an_enum);
> > +     out->typedef_named_struct_exists = bpf_core_type_exists(named_struct_typedef);
> > +     out->typedef_anon_struct_exists = bpf_core_type_exists(anon_struct_typedef);
> > +     out->typedef_struct_ptr_exists = bpf_core_type_exists(struct_ptr_typedef);
> > +     out->typedef_int_exists = bpf_core_type_exists(int_typedef);
> > +     out->typedef_enum_exists = bpf_core_type_exists(enum_typedef);
> > +     out->typedef_void_ptr_exists = bpf_core_type_exists(void_ptr_typedef);
> > +     out->typedef_func_proto_exists = bpf_core_type_exists(func_proto_typedef);
> > +     out->typedef_arr_exists = bpf_core_type_exists(arr_typedef);
> > +
> > +     out->struct_sz = bpf_core_type_size(struct a_struct);
> > +     out->union_sz = bpf_core_type_size(union a_union);
> > +     out->enum_sz = bpf_core_type_size(enum an_enum);
> > +     out->typedef_named_struct_sz = bpf_core_type_size(named_struct_typedef);
> > +     out->typedef_anon_struct_sz = bpf_core_type_size(anon_struct_typedef);
> > +     out->typedef_struct_ptr_sz = bpf_core_type_size(struct_ptr_typedef);
> > +     out->typedef_int_sz = bpf_core_type_size(int_typedef);
> > +     out->typedef_enum_sz = bpf_core_type_size(enum_typedef);
> > +     out->typedef_void_ptr_sz = bpf_core_type_size(void_ptr_typedef);
> > +     out->typedef_func_proto_sz = bpf_core_type_size(func_proto_typedef);
> > +     out->typedef_arr_sz = bpf_core_type_size(arr_typedef);
> > +#else
> > +     data.skip = true;
> > +#endif
> > +     return 0;
> > +}
> > +
>
> empty line at the end of file?

fixed

  reply	other threads:[~2020-08-19 19:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-19  5:28 [PATCH v2 bpf-next 0/5] Add support for type-based and enum value-based " Andrii Nakryiko
2020-08-19  5:28 ` [PATCH v2 bpf-next 1/5] libbpf: implement type-based CO-RE relocations support Andrii Nakryiko
2020-08-19  5:28 ` [PATCH v2 bpf-next 2/5] selftests/bpf: test TYPE_EXISTS and TYPE_SIZE CO-RE relocations Andrii Nakryiko
2020-08-19 16:30   ` Yonghong Song
2020-08-19 19:29     ` Andrii Nakryiko [this message]
2020-08-19  5:28 ` [PATCH v2 bpf-next 3/5] selftests/bpf: add CO-RE relo test for TYPE_ID_LOCAL/TYPE_ID_TARGET Andrii Nakryiko
2020-08-19 16:43   ` Yonghong Song
2020-08-19 19:30     ` Andrii Nakryiko
2020-08-19  5:28 ` [PATCH v2 bpf-next 4/5] libbpf: implement enum value-based CO-RE relocations Andrii Nakryiko
2020-08-19  5:28 ` [PATCH v2 bpf-next 5/5] selftests/bpf: add tests for ENUMVAL_EXISTS/ENUMVAL_VALUE relocations Andrii Nakryiko
2020-08-19 16:44   ` Yonghong Song
2020-08-19 16:24 ` [PATCH v2 bpf-next 0/5] Add support for type-based and enum value-based CO-RE relocations Yonghong Song

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='CAEf4Bzb=6hpK_tURacWUKB7guQN-v3mfOM6sFWiiqbo32L4_yg@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=yhs@fb.com \
    --subject='Re: [PATCH v2 bpf-next 2/5] selftests/bpf: test TYPE_EXISTS and TYPE_SIZE CO-RE relocations' \
    /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

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