From: Eduard Zingerman <eddyz87@gmail.com>
To: Paul Chaignon <paul.chaignon@gmail.com>, bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>
Subject: Re: [PATCH bpf-next 2/4] selftests/bpf: Update reg_bound range refinement logic
Date: Mon, 21 Jul 2025 14:29:47 -0700 [thread overview]
Message-ID: <8dc4b79af360bb6121c6b96a2c351bd060bfca29.camel@gmail.com> (raw)
In-Reply-To: <4636f494d90da3627e955d62e54a7927c6b2b92e.1752934170.git.paul.chaignon@gmail.com>
On Sat, 2025-07-19 at 16:22 +0200, Paul Chaignon wrote:
> This patch updates the range refinement logic in the reg_bound test to
> match the new logic from the previous commit. Without this change, tests
> would fail because we end with more precise ranges than the tests
> expect.
>
> Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
> ---
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
> .../testing/selftests/bpf/prog_tests/reg_bounds.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/reg_bounds.c b/tools/testing/selftests/bpf/prog_tests/reg_bounds.c
> index 39d42271cc46..e261b0e872db 100644
> --- a/tools/testing/selftests/bpf/prog_tests/reg_bounds.c
> +++ b/tools/testing/selftests/bpf/prog_tests/reg_bounds.c
> @@ -465,6 +465,20 @@ static struct range range_refine(enum num_t x_t, struct range x, enum num_t y_t,
> return range_improve(x_t, x, x_swap);
> }
>
> + if (!t_is_32(x_t) && !t_is_32(y_t) && x_t != y_t) {
Nit: I'd swap x and y if necessary, to avoid a second branch.
> + if (x_t == S64 && x.a > x.b) {
> + if (x.b < y.a && x.a <= y.b)
> + return range(x_t, x.a, y.b);
> + if (x.a > y.b && x.b >= y.a)
> + return range(x_t, y.a, x.b);
> + } else if (x_t == U64 && y.a > y.b) {
> + if (y.b < x.a && y.a <= x.b)
> + return range(x_t, y.a, x.b);
> + if (y.a > x.b && y.b >= x.a)
> + return range(x_t, x.a, y.b);
Nit: here returned type us U64, while above it is S64, I don't think
it matters but having same type in both branches would be less
confusing.
> + }
> + }
> +
> /* otherwise, plain range cast and intersection works */
> return range_improve(x_t, x, y_cast);
> }
next prev parent reply other threads:[~2025-07-21 21:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-19 14:20 [PATCH bpf-next 0/4] bpf: Improve 64bits bounds refinement Paul Chaignon
2025-07-19 14:22 ` [PATCH bpf-next 1/4] bpf: Improve bounds when s64 crosses sign boundary Paul Chaignon
2025-07-21 21:29 ` Eduard Zingerman
2025-07-22 7:32 ` Shung-Hsi Yu
2025-07-22 22:09 ` Paul Chaignon
2025-07-23 7:49 ` Shung-Hsi Yu
2025-07-19 14:22 ` [PATCH bpf-next 2/4] selftests/bpf: Update reg_bound range refinement logic Paul Chaignon
2025-07-21 21:29 ` Eduard Zingerman [this message]
2025-07-22 21:20 ` Paul Chaignon
2025-07-22 21:26 ` Eduard Zingerman
2025-07-19 14:23 ` [PATCH bpf-next 3/4] selftests/bpf: Test cross-sign 64bits range refinement Paul Chaignon
2025-07-21 21:30 ` Eduard Zingerman
2025-07-24 14:03 ` Paul Chaignon
2025-07-19 14:24 ` [PATCH bpf-next 4/4] selftests/bpf: Test invariants on JSLT crossing sign Paul Chaignon
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=8dc4b79af360bb6121c6b96a2c351bd060bfca29.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=paul.chaignon@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 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.