bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Chaignon <paul.chaignon@gmail.com>
To: Yonghong Song <yonghong.song@linux.dev>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>
Subject: Re: [PATCH bpf-next 2/2] selftests/bpf: Range analysis test case for JSET
Date: Thu, 10 Jul 2025 16:38:31 +0200	[thread overview]
Message-ID: <aG_QZ4mfJyS4p6_7@mail.gmail.com> (raw)
In-Reply-To: <d41cbad6-a31e-464e-b2e3-b74acbf42b48@linux.dev>

On Wed, Jul 09, 2025 at 04:09:41PM -0700, Yonghong Song wrote:
> 
> 
> On 7/9/25 3:27 PM, Paul Chaignon wrote:

[...]

> > +SEC("socket")
> > +__description("dead branch on jset, does not result in invariants violation error")
> > +__success __log_level(2)
> > +__retval(0) __flag(BPF_F_TEST_REG_INVARIANTS)
> > +__naked void jset_range_analysis(void)
> > +{
> > +	asm volatile ("						\
> > +	call %[bpf_get_netns_cookie];				\
> > +	if r0 == 0 goto l0_%=;					\
> > +	.8byte %[jset]; /* if r0 & 0xffffffff goto +0 */	\
> 
> why not just use 'if r0 & 0xffffffff goto +0'? It will be equivelant to
> BPF_JMP_IMM(BPF_JSET, BPF_REG_0, 0xffffffff, 0).

I was having issues with some older versions of LLVM. Some didn't
recognize jset instructions, some simply crashed. That said, the CI
seems to be fine, so let me switch this back to the simpler syntax.

> 
> > +l0_%=:	r0 = 0;							\
> > +	exit;							\
> > +"	:
> > +	: __imm(bpf_get_netns_cookie),
> > +	  __imm_insn(jset, BPF_JMP_IMM(BPF_JSET, BPF_REG_0, 0xffffffff, 0))
> > +	: __clobber_all);
> > +}
> > +
> >   char _license[] SEC("license") = "GPL";
> 

  reply	other threads:[~2025-07-10 14:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-09 22:26 [PATCH bpf-next 1/2] bpf: Forget ranges when refining tnum after JSET Paul Chaignon
2025-07-09 22:27 ` [PATCH bpf-next 2/2] selftests/bpf: Range analysis test case for JSET Paul Chaignon
2025-07-09 23:09   ` Yonghong Song
2025-07-10 14:38     ` Paul Chaignon [this message]
2025-07-09 23:26 ` [PATCH bpf-next 1/2] bpf: Forget ranges when refining tnum after JSET Eduard Zingerman
2025-07-09 23:57 ` Yonghong Song
2025-07-10 14:51   ` Paul Chaignon
2025-07-10 17:09     ` 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=aG_QZ4mfJyS4p6_7@mail.gmail.com \
    --to=paul.chaignon@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;
as well as URLs for NNTP newsgroup(s).