From: Anton Protopopov <a.s.protopopov@gmail.com>
To: Eduard Zingerman <eddyz87@gmail.com>
Cc: Yonghong Song <yonghong.song@linux.dev>,
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>
Subject: Re: [PATCH v7 bpf-next 12/12] selftests/bpf: add C-level selftests for indirect jumps
Date: Tue, 28 Oct 2025 10:59:16 +0000 [thread overview]
Message-ID: <aQCiBNHFYENQdNvL@mail.gmail.com> (raw)
In-Reply-To: <ee2274f3293eb82c3c4671de8cefcbf6d679c0b3.camel@gmail.com>
On 25/10/27 04:25PM, Eduard Zingerman wrote:
> On Sun, 2025-10-26 at 19:27 +0000, Anton Protopopov wrote:
> > Add C-level selftests for indirect jumps to validate LLVM and libbpf
> > functionality. The tests are intentionally disabled, to be run
> > locally by developers, but will not make the CI red.
> >
> > Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
> > ---
>
> [...]
>
> > 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..3c8ee363bda1
> > --- /dev/null
> > +++ b/tools/testing/selftests/bpf/progs/bpf_gotox.c
> > @@ -0,0 +1,402 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +
> > +#include "vmlinux.h"
> > +#include <bpf/bpf_helpers.h>
> > +#include <bpf/bpf_tracing.h>
> > +#include <bpf/bpf_core_read.h>
> > +#include "bpf_misc.h"
> > +
> > +/* Disable tests for now, as CI runs with LLVM-20 */
> > +#if 0
>
> Yonghong,
>
> I think we need the following thing in LLVM:
>
> diff --git a/clang/lib/Basic/Targets/BPF.cpp b/clang/lib/Basic/Targets/BPF.cpp
> index 0411bcca5178..8de1083d758c 100644
> --- a/clang/lib/Basic/Targets/BPF.cpp
> +++ b/clang/lib/Basic/Targets/BPF.cpp
> @@ -75,6 +75,7 @@ void BPFTargetInfo::getTargetDefines(const LangOptions &Opts,
> Builder.defineMacro("__BPF_FEATURE_GOTOL");
> Builder.defineMacro("__BPF_FEATURE_ST");
> Builder.defineMacro("__BPF_FEATURE_LOAD_ACQ_STORE_REL");
> + Builder.defineMacro("__BPF_FEATURE_GOTOX");
> }
> }
>
> Then, Anton will be able to use it in order to decide if to skip the
> tests, wdyt?
This will definitely be useful for the BPF side.
Where this doesn't apply is the corresponding prog_tests/bpf_gotox.c,
as it can be compiled independently and for sure it will not have
__BPF_FEATURE_GOTOX enabled. So what is the way to tell preprocessor
if gotox was enabled in BPF program? Is there a way to pass/generate
a macro definition from BPF prog to skeleton? If so, then it can be
used in the prog_tests/bpf_gotox.c to enable/disable tests.
> > +__u64 in_user;
> > +__u64 ret_user;
> > +
> > +struct simple_ctx {
> > + __u64 x;
> > +};
> > +
> > +__u64 some_var;
> > +
> > +/*
> > + * This function adds code which will be replaced by a different
> > + * number of instructions by the verifier. This adds additional
> > + * stress on testing the insn_array maps corresponding to indirect jumps.
> > + */
> > +static __always_inline void adjust_insns(__u64 x)
> > +{
> > + some_var ^= x + bpf_jiffies64();
> > +}
> > +
> > +SEC("syscall")
> > +int simple_test(struct simple_ctx *ctx)
> > +{
> > + switch (ctx->x) {
> > + case 0:
> > + adjust_insns(ctx->x + 1);
> > + ret_user = 2;
> > + break;
>
> [...]
prev parent reply other threads:[~2025-10-28 10:52 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-26 19:26 [PATCH v7 bpf-next 00/12] BPF indirect jumps Anton Protopopov
2025-10-26 19:26 ` [PATCH v7 bpf-next 01/12] bpf, x86: add new map type: instructions array Anton Protopopov
2025-10-26 20:12 ` Anton Protopopov
2025-10-26 22:34 ` kernel test robot
2025-10-26 22:59 ` kernel test robot
2025-10-27 21:44 ` Eduard Zingerman
2025-10-28 10:10 ` Anton Protopopov
2025-10-29 21:54 ` Eduard Zingerman
2025-10-26 19:26 ` [PATCH v7 bpf-next 02/12] selftests/bpf: add selftests for new insn_array map Anton Protopopov
2025-10-26 19:27 ` [PATCH v7 bpf-next 03/12] bpf: support instructions arrays with constants blinding Anton Protopopov
2025-10-26 19:27 ` [PATCH v7 bpf-next 04/12] selftests/bpf: test instructions arrays with blinding Anton Protopopov
2025-10-26 19:27 ` [PATCH v7 bpf-next 05/12] bpf, x86: allow indirect jumps to r8...r15 Anton Protopopov
2025-10-26 19:27 ` [PATCH v7 bpf-next 06/12] bpf, x86: add support for indirect jumps Anton Protopopov
2025-10-26 20:41 ` Anton Protopopov
2025-10-26 19:27 ` [PATCH v7 bpf-next 07/12] bpf: disasm: add support for BPF_JMP|BPF_JA|BPF_X Anton Protopopov
2025-10-26 19:27 ` [PATCH v7 bpf-next 08/12] bpf, docs: do not state that indirect jumps are not supported Anton Protopopov
2025-10-27 6:30 ` Anton Protopopov
2025-10-26 19:27 ` [PATCH v7 bpf-next 09/12] libbpf: support llvm-generated indirect jumps Anton Protopopov
2025-10-26 20:15 ` Anton Protopopov
2025-10-27 22:09 ` Eduard Zingerman
2025-10-27 22:38 ` Eduard Zingerman
2025-10-27 22:59 ` Eduard Zingerman
2025-10-28 11:36 ` Anton Protopopov
2025-10-28 11:42 ` Anton Protopopov
2025-10-26 19:27 ` [PATCH v7 bpf-next 10/12] bpftool: Recognize insn_array map type Anton Protopopov
2025-10-26 19:27 ` [PATCH v7 bpf-next 11/12] selftests/bpf: add new verifier_gotox test Anton Protopopov
2025-10-26 19:27 ` [PATCH v7 bpf-next 12/12] selftests/bpf: add C-level selftests for indirect jumps Anton Protopopov
2025-10-27 23:25 ` Eduard Zingerman
2025-10-28 10:59 ` 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=aQCiBNHFYENQdNvL@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.