From: Anton Protopopov <a.s.protopopov@gmail.com>
To: Eduard Zingerman <eddyz87@gmail.com>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Anton Protopopov <aspsk@isovalent.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Quentin Monnet <qmo@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>
Subject: Re: [PATCH v10 bpf-next 11/11] selftests/bpf: add C-level selftests for indirect jumps
Date: Wed, 5 Nov 2025 07:26:06 +0000 [thread overview]
Message-ID: <aQr8Dr+yJRlpm3f3@mail.gmail.com> (raw)
In-Reply-To: <e72db29a74ce5e7ac43068e6bf8005c7a3c7cfa2.camel@gmail.com>
On 25/11/03 12:45PM, Eduard Zingerman wrote:
> On Sun, 2025-11-02 at 20:57 +0000, Anton Protopopov wrote:
>
> [...]
>
> > diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_gotox.c b/tools/testing/selftests/bpf/prog_tests/bpf_gotox.c
> > new file mode 100644
> > index 000000000000..2a55fa91e1fa
> > --- /dev/null
> > +++ b/tools/testing/selftests/bpf/prog_tests/bpf_gotox.c
> > @@ -0,0 +1,272 @@
>
> [...]
>
> > +static void check_simple_fentry(struct bpf_gotox *skel,
> > + struct bpf_program *prog,
> > + __u64 ctx_in,
> > + __u64 expected)
> > +{
> > + skel->bss->in_user = ctx_in;
> > + skel->bss->ret_user = 0;
> > +
> > + /* trigger */
> > + usleep(1);
> > +
> > + if (!ASSERT_EQ(skel->bss->ret_user, expected, "skel->bss->ret_user"))
> > + return;
> > +}
>
> [...]
>
> > +static void check_other_sec(struct bpf_gotox *skel)
> > +{
> > + __u64 in[] = {0, 1, 2, 3, 4, 5, 77};
> > + __u64 out[] = {2, 3, 4, 5, 7, 19, 19};
> > + int i;
> > +
> > + bpf_program__attach(skel->progs.simple_test_other_sec);
> > + for (i = 0; i < ARRAY_SIZE(in); i++)
> > + check_simple_fentry(skel, skel->progs.simple_test_other_sec, in[i], out[i]);
> > +}
>
> The above means that fentry programs are accumulated for 'sys_nanosleep', right?
> In all 3 test cases that use check_simple_fentry() the identical 'out'
> values are used. Should the programs be detached here to avoid
> possible masking of a misbehaving program?
yes, thanks, will detach it
>
> [...]
>
> > diff --git a/tools/testing/selftests/bpf/progs/bpf_gotox.c b/tools/testing/selftests/bpf/progs/bpf_gotox.c
> > new file mode 100644
> > index 000000000000..8a84f4b225b2
> > --- /dev/null
> > +++ b/tools/testing/selftests/bpf/progs/bpf_gotox.c
>
> +SEC("fentry/" SYS_PREFIX "sys_nanosleep")
> +int use_nonstatic_global_other_sec(void *ctx)
> +{
> + return __nonstatic_global(in_user);
> +}
>
> Should this check for target process pid?
And here will add a fix as well. Thanks
> [...]
>
> > +#define SKIP_TEST(TEST_NAME) \
> > + SEC("syscall") int TEST_NAME(void *ctx) \
> > + { \
> > + return 0; \
> > + }
> > +
> > +SKIP_TEST(one_switch);
> > +SKIP_TEST(one_switch_non_zero_sec_off);
> > +SKIP_TEST(simple_test_other_sec);
> > +SKIP_TEST(two_switches);
> > +SKIP_TEST(big_jump_table);
> > +SKIP_TEST(one_jump_two_maps);
> > +SKIP_TEST(one_map_two_jumps);
> > +SKIP_TEST(use_static_global1);
> > +SKIP_TEST(use_static_global2);
> > +SKIP_TEST(use_static_global_other_sec);
> > +SKIP_TEST(use_nonstatic_global1);
> > +SKIP_TEST(use_nonstatic_global2);
> > +SKIP_TEST(use_nonstatic_global_other_sec);
>
> Nice.
> I double checked and tests are skipped when old clang is used and pass
> when new clang is used.
>
> > +#endif /* __BPF_FEATURE_GOTOX */
> > +
> > +char _license[] SEC("license") = "GPL";
prev parent reply other threads:[~2025-11-05 7:19 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-02 20:57 [PATCH v10 bpf-next 00/11] BPF indirect jumps Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 01/11] bpf, x86: add new map type: instructions array Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 02/11] selftests/bpf: add selftests for new insn_array map Anton Protopopov
2025-11-04 2:10 ` Alexei Starovoitov
2025-11-04 13:52 ` Anton Protopopov
2025-11-04 16:49 ` Alexei Starovoitov
2025-11-05 6:35 ` Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 03/11] bpf: support instructions arrays with constants blinding Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 04/11] selftests/bpf: test instructions arrays with blinding Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 05/11] bpf, x86: allow indirect jumps to r8...r15 Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 06/11] bpf, x86: add support for indirect jumps Anton Protopopov
2025-11-02 21:20 ` bot+bpf-ci
2025-11-02 22:00 ` Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 07/11] bpf: disasm: add support for BPF_JMP|BPF_JA|BPF_X Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 08/11] libbpf: support llvm-generated indirect jumps Anton Protopopov
2025-11-02 21:13 ` bot+bpf-ci
2025-11-02 21:36 ` Anton Protopopov
2025-11-02 21:38 ` Anton Protopopov
2025-11-03 0:32 ` Ihor Solodrai
2025-11-03 0:58 ` Chris Mason
2025-11-03 8:29 ` Anton Protopopov
2025-11-03 8:21 ` Anton Protopopov
2025-11-04 1:15 ` Eduard Zingerman
2025-11-04 1:30 ` Eduard Zingerman
2025-11-04 5:26 ` Yonghong Song
2025-11-04 18:31 ` Eduard Zingerman
2025-11-05 8:12 ` Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 09/11] bpftool: Recognize insn_array map type Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 10/11] selftests/bpf: add new verifier_gotox test Anton Protopopov
2025-11-02 20:57 ` [PATCH v10 bpf-next 11/11] selftests/bpf: add C-level selftests for indirect jumps Anton Protopopov
2025-11-03 20:45 ` Eduard Zingerman
2025-11-05 7:26 ` Anton Protopopov [this message]
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=aQr8Dr+yJRlpm3f3@mail.gmail.com \
--to=a.s.protopopov@gmail.com \
--cc=andrii@kernel.org \
--cc=aspsk@isovalent.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=qmo@kernel.org \
--cc=yonghong.song@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.