From: Eduard Zingerman <eddyz87@gmail.com>
To: Harishankar Vishwanathan <harishankar.vishwanathan@gmail.com>,
ast@kernel.org
Cc: m.shachnai@rutgers.edu, srinivas.narayana@rutgers.edu,
santosh.nagarakatte@rutgers.edu,
Daniel Borkmann <daniel@iogearbox.net>,
John Fastabend <john.fastabend@gmail.com>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>,
Hao Luo <haoluo@google.com>, Jiri Olsa <jolsa@kernel.org>,
Mykola Lysenko <mykolal@fb.com>, Shuah Khan <shuah@kernel.org>,
Matan Shachnai <m.shachnai@gmail.com>,
Luis Gerhorst <luis.gerhorst@fau.de>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v2 2/2] selftests/bpf: Add testcases for BPF_ADD and BPF_SUB
Date: Wed, 18 Jun 2025 14:22:27 -0700 [thread overview]
Message-ID: <5b3b620d04fc3bcf4286dc4bb8c6fd995df86a25.camel@gmail.com> (raw)
In-Reply-To: <20250617231733.181797-3-harishankar.vishwanathan@gmail.com>
On Tue, 2025-06-17 at 19:17 -0400, Harishankar Vishwanathan wrote:
> The previous commit improves the precision in scalar(32)_min_max_add,
> and scalar(32)_min_max_sub. The improvement in precision occurs in
> cases when all outcomes overflow or underflow, respectively. This
> commit adds selftests that exercise those cases.
>
> Co-developed-by: Matan Shachnai <m.shachnai@rutgers.edu>
> Signed-off-by: Matan Shachnai <m.shachnai@rutgers.edu>
> Signed-off-by: Harishankar Vishwanathan <harishankar.vishwanathan@gmail.com>
> ---
Could you please also add test cases when one bound overflows while
another does not? Or these are covered by some other tests?
[...]
> +SEC("socket")
> +__description("64-bit addition overflow, all outcomes overflow")
> +__success __log_level(2)
> +__msg("7: (0f) r5 += r3 {{.*}} R5_w=scalar(smin=0x800003d67e960f7d,umin=0x551ee3d67e960f7d,umax=0xc0149fffffffffff,smin32=0xfe960f7d,umin32=0x7e960f7d,var_off=(0x3d67e960f7d; 0xfffffc298169f082))")
Would it be possible to pick some more "human readable" constants here?
As-is it is hard to make sense what verifier actually computes.
> +__retval(0)
> +__naked void add64_ovf(void)
> +{
> + asm volatile (
> + "call %[bpf_get_prandom_u32];"
> + "r3 = r0;"
> + "r4 = 0x950a43d67e960f7d ll;"
> + "r3 |= r4;"
> + "r5 = 0xc014a00000000000 ll;"
> + "r5 += r3;"
> + "r0 = 0;"
> + "exit"
> + :
> + : __imm(bpf_get_prandom_u32)
> + : __clobber_all);
> +}
[...]
next prev parent reply other threads:[~2025-06-18 21:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-17 23:17 [PATCH v2 0/2] bpf, verifier: Improve precision of BPF_ADD and BPF_SUB Harishankar Vishwanathan
2025-06-17 23:17 ` [PATCH v2 1/2] bpf, verifier: Improve precision for " Harishankar Vishwanathan
2025-06-18 11:24 ` Hao Sun
2025-06-19 22:17 ` Harishankar Vishwanathan
2025-06-18 20:53 ` Eduard Zingerman
2025-06-17 23:17 ` [PATCH v2 2/2] selftests/bpf: Add testcases " Harishankar Vishwanathan
2025-06-18 21:22 ` Eduard Zingerman [this message]
2025-06-19 21:13 ` Harishankar Vishwanathan
2025-06-19 21:55 ` Eduard Zingerman
2025-06-19 22:34 ` Harishankar Vishwanathan
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=5b3b620d04fc3bcf4286dc4bb8c6fd995df86a25.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=haoluo@google.com \
--cc=harishankar.vishwanathan@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=luis.gerhorst@fau.de \
--cc=m.shachnai@gmail.com \
--cc=m.shachnai@rutgers.edu \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=mykolal@fb.com \
--cc=santosh.nagarakatte@rutgers.edu \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=srinivas.narayana@rutgers.edu \
--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).