public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Anton Protopopov <a.s.protopopov@gmail.com>
To: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Yonghong Song <yonghong.song@linux.dev>
Subject: Re: [PATCH bpf-next 2/2] selftests/bpf: Extend live regs tests with a test for gotox
Date: Wed, 14 Jan 2026 12:24:03 +0000	[thread overview]
Message-ID: <aWeK41yKzQXAZs81@mail.gmail.com> (raw)
In-Reply-To: <20260114113314.32649-3-a.s.protopopov@gmail.com>

On 26/01/14 11:33AM, Anton Protopopov wrote:
> Add a test which checks that the destination register of a gotox
> instruction is marked as used and that the union of jump targets
> is considered as live.
> 
> Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
> ---
>  .../bpf/progs/compute_live_registers.c        | 37 +++++++++++++++++++
>  1 file changed, 37 insertions(+)
> 
> diff --git a/tools/testing/selftests/bpf/progs/compute_live_registers.c b/tools/testing/selftests/bpf/progs/compute_live_registers.c
> index 6884ab99a421..fad91c599095 100644
> --- a/tools/testing/selftests/bpf/progs/compute_live_registers.c
> +++ b/tools/testing/selftests/bpf/progs/compute_live_registers.c
> @@ -431,6 +431,43 @@ __naked void subprog1(void)
>  		::: __clobber_all);
>  }
>  
> +SEC("socket")
> +__log_level(2)
> +__msg("2: .1........ (07) r1 += 8")
> +__msg("3: .1........ (79) r2 = *(u64 *)(r1 +0)")
> +__msg("4: ..2....... (b7) r3 = 1")
> +__msg("5: ..23...... (b7) r4 = 2")
> +__msg("6: ..234..... (0d) gotox r2")
> +__msg("7: ...3...... (bf) r0 = r3")
> +__msg("8: 0......... (95) exit")
> +__msg("9: ....4..... (bf) r0 = r4")
> +__msg("10: 0......... (95) exit")
> +__naked
> +void gotox(void)
> +{
> +	asm volatile (
> +	".pushsection .jumptables,\"\",@progbits;"
> +"jt0_%=: .quad l0_%= - socket;"
> +	".quad l1_%= - socket;"
> +	".size jt0_%=, 16;"
> +	".global jt0_%=;"
> +	".popsection;"
> +
> +	"r1 = jt0_%= ll;"
> +	"r1 += 8;"
> +	"r2 = *(u64 *)(r1 + 0);"
> +	"r3 = 1;"
> +	"r4 = 2;"
> +	".8byte %[gotox_r2];"
> +"l0_%=:  r0 = r3;"
> +	"exit;"
> +"l1_%=:  r0 = r4;"
> +	"exit;"
> +	:
> +	: __imm_insn(gotox_r2, BPF_RAW_INSN(BPF_JMP | BPF_JA | BPF_X, BPF_REG_2, BPF_REG_0, 0, 0))
> +	: __clobber_all);
> +}
> +
>  /* to retain debug info for BTF generation */
>  void kfunc_root(void)
>  {
> -- 
> 2.34.1
> 

Ah, this fails on s390x. I will send a fix later today.

      reply	other threads:[~2026-01-14 12:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-14 11:33 [PATCH bpf-next 0/2] bpf: Live registers computation with gotox Anton Protopopov
2026-01-14 11:33 ` [PATCH bpf-next 1/2] bpf: Properly mark used registers for indirect jumps Anton Protopopov
2026-01-14 11:33 ` [PATCH bpf-next 2/2] selftests/bpf: Extend live regs tests with a test for gotox Anton Protopopov
2026-01-14 12:24   ` 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=aWeK41yKzQXAZs81@mail.gmail.com \
    --to=a.s.protopopov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox