From: Eduard Zingerman <eddyz87@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Yonghong Song <yonghong.song@linux.dev>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
kernel-team@fb.com, Martin KaFai Lau <martin.lau@kernel.org>,
Shung-Hsi Yu <shung-hsi.yu@suse.com>
Subject: Re: [PATCH bpf-next v4 1/2] bpf: Get better reg range with ldsx and 32bit compare
Date: Fri, 19 Jul 2024 16:40:49 -0700 [thread overview]
Message-ID: <e10d476b192b32acecafa73392f2dad97419536b.camel@gmail.com> (raw)
In-Reply-To: <CAEf4BzYazgarMJNVqt33grWxYEcNWy_L=OCXwg9tw5wHYc+2iw@mail.gmail.com>
On Fri, 2024-07-19 at 15:46 -0700, Andrii Nakryiko wrote:
[...]
> > + /* Here we would like to handle a special case after sign extending load,
> > + * when upper bits for a 64-bit range are all 1s or all 0s.
> > + *
> > + * Upper bits are all 1s when register is in a range:
> > + * [0xffff_ffff_0000_0000, 0xffff_ffff_ffff_ffff]
> > + * Upper bits are all 0s when register is in a range:
> > + * [0x0000_0000_0000_0000, 0x0000_0000_ffff_ffff]
> > + * Together this forms are continuous range:
> > + * [0xffff_ffff_0000_0000, 0x0000_0000_ffff_ffff]
> > + *
> > + * Now, suppose that register range is in fact tighter:
> > + * [0xffff_ffff_8000_0000, 0x0000_0000_ffff_ffff] (R)
> > + * Also suppose that it's 32-bit range is positive,
> > + * meaning that lower 32-bits of the full 64-bit register
> > + * are in the range:
> > + * [0x0000_0000, 0x7fff_ffff] (W)
> > + *
> > + * If this happens, then any value in a range:
> > + * [0xffff_ffff_0000_0000, 0xffff_ffff_7fff_ffff]
> > + * is smaller than a lowest bound of the range (R):
> > + * 0xffff_ffff_8000_0000
> > + * which means that upper bits of the full 64-bit register
> > + * can't be all 1s, when lower bits are in range (W).
> > + *
> > + * Note that:
> > + * - 0xffff_ffff_8000_0000 == (s64)S32_MIN
> > + * - 0x0000_0000_ffff_ffff == (s64)S32_MAX
>
> ?? S32_MAX = 0x7fffffff, so should the right part be U32_MAX or the
> left part should be 0x0000_0000_7fff_ffff ?
Oops, that's on me, yes it should be 0x0000_0000_7fff_ffff here.
[...]
next prev parent reply other threads:[~2024-07-19 23:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-18 5:28 [PATCH bpf-next v4 1/2] bpf: Get better reg range with ldsx and 32bit compare Yonghong Song
2024-07-18 5:28 ` [PATCH bpf-next v4 2/2] selftests/bpf: Add reg_bounds tests for ldsx and subreg compare Yonghong Song
2024-07-18 20:48 ` Eduard Zingerman
2024-07-19 22:58 ` Andrii Nakryiko
2024-07-22 18:11 ` Yonghong Song
2024-07-19 22:46 ` [PATCH bpf-next v4 1/2] bpf: Get better reg range with ldsx and 32bit compare Andrii Nakryiko
2024-07-19 23:40 ` Eduard Zingerman [this message]
2024-07-22 18:16 ` Yonghong Song
2024-07-24 22:56 ` Andrii Nakryiko
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=e10d476b192b32acecafa73392f2dad97419536b.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
--cc=shung-hsi.yu@suse.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