From: Vineet Gupta <vineet.gupta@linux.dev>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Eduard Zingerman <eddyz87@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
Emil Tsalapatis <emil@etsalapatis.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
Shuah Khan <shuah@kernel.org>, bpf <bpf@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@vger.kernel.org>
Subject: Re: [PATCH bpf-next v2 03/13] bpf: track low-32 scalar equality across zero-extending movs
Date: Fri, 2 Oct 2026 14:59:46 +0100 [thread overview]
Message-ID: <81cf1bec-0e88-468b-b7b1-992aa92cff80@linux.dev> (raw)
In-Reply-To: <DLLCIL3RGVY1.H5A4OEASW5OF@gmail.com>
On 9/21/26 11:25 PM, Alexei Starovoitov wrote:
> On Mon Sep 21, 2026 at 10:17 PM UTC, Eduard Zingerman wrote:
>> On Mon, 2026-09-21 at 21:55 +0000, Alexei Starovoitov wrote:
>>> On Mon Sep 21, 2026 at 7:44 PM UTC, Eduard Zingerman wrote:
>>>>>>>> Where:
>>>>>>>> - id == 0 => no id link
>>>>>>>> - full => all 64-bits of the register are identical to
>>>>>>>> all 64-bits of a scalar value `id' (let's call it X).
>>>>>>>> ∀ rA{.id == X, .link == full}, rB{X,full} => rA == rB
>>>>>>>> - zext => lower 32-bits of the register are identical to
>>>>>>>> lower 32-bits of a scalar value X,
>>>>>>>> upper 32-bits of the register are null.
>>>>>>>> ∀ rA{.id == X, .link == ?}, rB{X,zext} => rA % 32 == rB % 32
>>>>>>>> - sext => lower 32-bits of the register are identical to
>>>>>>>> lower 32-bits of a scalar value X,
>>>>>>>> upper 32-bits of the register are either 0 or 1,
>>>>>>>> depending on the bit 31 value.
>>>>>>>> ∀ rA{.id == X, .link == ?}, rB{X,sext} => sext(rA % 32) == sext(rB % 32)
>>>>>>> hmm.
>>>>>>> there is also 32-bit link with delta, right?
>>>>>> My point is that delta is independent of 32-bit/64-bit property.
>>>>>> `delta' can be used to propagate in both directions:
>>>>>> - full 64 bit -> 32 bit sign/zero-extened
>>>>>> - 32 bit sign/zero-extened -> full 64-bit
>>>>> both? how ?
>>>>> I was under impression that in 32-bit domain delta is one way.
>>>>> rX = ...
>>>>> wY = wX
>>>>> wY += 5
>>>>>
>>>>> if wY == 10
>>>>> We cannot do -5 to rX
>>>> Why?
>>>> It is still valid to transfer r32 and tnum_subreg knowledge from wY to rX.
>>>>
>>>> wY + 5 == rX % 32 + 5 => hence rX % 32 knowledge can be recovered.
>>>>
>>>> If rX itself had some delta, e.g.:
>>>>
>>>> rX = ...
>>>> rX += 7
>>>> wY = wX
>>>> wY += 5
>>>>
>>>> Then it would still be possible:
>>>>
>>>> wY + 5 == (rX - 7) % 32 + 5 = rX % 32 - 2.
>>>>
>>>> Again, in case of this direction, only lower 32-bits of the 'full'
>>>> register can be inferred.
>>> Ok, so we're argeeing that it's not 'full' in your above definition.
>>> Your enum id_link_kind needs a 4th category : apply-delta-to-lower-32bit-...
>>> and it's not bi-directional.
>> It's not really a category, it's just a direction in a sync function:
>> - if known_reg is 'full' -> sync to sext/zext register recovers lower
>> 32-bits and infers upper
>> - if known_reg is sext/zext -> sync to 'full' register recovers only
>> lower 32-bits and keeps upper untouched (counting on cross-domain
>> bounds sync logic).
>> - 'full' -> 'full' and 'sext/zext' -> 'sext/zext' syncs are trivial.
>>
>>> rX = ...
>>> wY = wX
>>> wY += 5
>>> if wY == 10
>>> here can apply -5 to lower 32-bit of rX only.
>>>
>>> rX = ...
>>> wY = wX
>>> wY += 5
>>> if rX == 10
>>> here can apply +5 to lower 32-bit of wY _and_ do zero extend into full rY.
>>>
>>> I don't see a value of 'zext' kind alone that doesn't do 'add delta'.
>> Exactly, that's why I suggest this as a completely orthogonal encoding.
>> Effectively for an abstract scalar value X it would encode whether
>> the particular register is:
>> - X + delta
>> - zext(X + delta)
>> - sext(X + delta)
> ahh. it wasn't clear to me that 'zext' you're proposing does '+ delta'.
> Now I see that your zext is the same as apply-delta-to-lower-32bit-and-zext
> as I was talking about all along.
So to close the loop on this v3 will support the above three forms:
add_const:2 and subreg_ext:1merge into one {none,
And just to recap, we will be adding two features:
- adding the sext with delta
- reverse syncing of low 32 bits
Thx,
-Vineet
next prev parent reply other threads:[~2026-10-02 13:59 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 16:46 [PATCH bpf-next v2 00/13] bpf: track scalar equality across the low 32 bits Vineet Gupta
2026-09-10 16:46 ` [PATCH bpf-next v2 01/13] bpf: move linked-scalar flags out of bpf_reg_state->id [NFC] Vineet Gupta
2026-09-10 17:52 ` bot+bpf-ci
2026-09-14 18:02 ` Vineet Gupta
2026-09-16 21:03 ` Alexei Starovoitov
2026-09-16 21:21 ` Vineet Gupta
2026-09-18 23:38 ` Vineet Gupta
2026-09-12 18:50 ` Alexei Starovoitov
2026-09-15 1:17 ` Vineet Gupta
2026-09-16 21:02 ` Alexei Starovoitov
2026-09-16 21:24 ` Vineet Gupta
2026-09-17 0:36 ` Alexei Starovoitov
2026-10-02 8:03 ` Vineet Gupta
2026-10-02 11:23 ` Alexei Starovoitov
2026-09-18 23:13 ` Eduard Zingerman
2026-09-21 18:44 ` Vineet Gupta
2026-09-10 16:46 ` [PATCH bpf-next v2 02/13] bpf: compare linked-scalar kinds in regs_exact() Vineet Gupta
2026-09-12 18:51 ` Alexei Starovoitov
2026-09-15 1:11 ` Vineet Gupta
2026-09-10 16:46 ` [PATCH bpf-next v2 03/13] bpf: track low-32 scalar equality across zero-extending movs Vineet Gupta
2026-09-10 17:52 ` bot+bpf-ci
2026-09-11 9:29 ` Vineet Gupta
2026-09-12 18:59 ` Alexei Starovoitov
2026-09-15 20:31 ` Vineet Gupta
2026-09-16 4:23 ` Alexei Starovoitov
2026-09-17 0:08 ` Vineet Gupta
2026-09-17 0:30 ` Alexei Starovoitov
2026-09-21 17:28 ` Eduard Zingerman
2026-09-21 18:59 ` Alexei Starovoitov
2026-09-21 19:10 ` Eduard Zingerman
2026-09-21 19:27 ` Alexei Starovoitov
2026-09-21 19:44 ` Eduard Zingerman
2026-09-21 21:55 ` Alexei Starovoitov
2026-09-21 22:17 ` Eduard Zingerman
2026-09-21 22:25 ` Alexei Starovoitov
2026-10-02 13:59 ` Vineet Gupta [this message]
2026-09-10 16:46 ` [PATCH bpf-next v2 04/13] selftests/bpf: cover the low-32 link for " Vineet Gupta
2026-09-10 16:46 ` [PATCH bpf-next v2 05/13] bpf: keep the range across a sign extension that cannot change it Vineet Gupta
2026-09-10 17:52 ` bot+bpf-ci
2026-09-11 10:37 ` Vineet Gupta
2026-09-12 19:02 ` Alexei Starovoitov
2026-09-15 21:18 ` Vineet Gupta
2026-09-10 16:46 ` [PATCH bpf-next v2 06/13] selftests/bpf: cover sign extensions that cannot change the range Vineet Gupta
2026-09-10 16:46 ` [PATCH bpf-next v2 07/13] bpf: track low-32 scalar equality across sign-extending movs Vineet Gupta
2026-09-10 17:52 ` bot+bpf-ci
2026-09-11 10:00 ` Vineet Gupta
2026-09-12 19:09 ` Alexei Starovoitov
2026-09-15 20:39 ` Vineet Gupta
2026-09-10 16:46 ` [PATCH bpf-next v2 08/13] selftests/bpf: cover the low-32 link for " Vineet Gupta
2026-09-10 17:52 ` bot+bpf-ci
2026-09-11 8:00 ` Vineet Gupta
2026-09-10 16:46 ` [PATCH bpf-next v2 09/13] bpf: track low-32 scalar equality across narrowing stack fills Vineet Gupta
2026-09-10 16:46 ` [PATCH bpf-next v2 10/13] selftests/bpf: cover the low-32 link for " Vineet Gupta
2026-09-10 17:31 ` bot+bpf-ci
2026-09-11 5:07 ` Vineet Gupta
2026-09-10 16:46 ` [PATCH bpf-next v2 11/13] bpf: record what a narrowing spill actually stores Vineet Gupta
2026-09-10 16:46 ` [PATCH bpf-next v2 12/13] bpf: track low-32 scalar equality across narrowing stack spills Vineet Gupta
2026-09-10 16:46 ` [PATCH bpf-next v2 13/13] selftests/bpf: cover the low-32 link for " Vineet Gupta
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=81cf1bec-0e88-468b-b7b1-992aa92cff80@linux.dev \
--to=vineet.gupta@linux.dev \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--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
all inboxes | Powered by JetHome®