From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>, <bpf@vger.kernel.org>
Cc: <daniel@iogearbox.net>, <andrii@kernel.org>, <eddyz87@gmail.com>
Subject: Re: [PATCH bpf-next 0/5] bpf: Unwinding via r3
Date: Mon, 19 Oct 2026 02:05:40 +0000 [thread overview]
Message-ID: <DM8G3O0ZTUM9.MMBWXXQ7OP98@gmail.com> (raw)
In-Reply-To: <DM7KR7J8VY2T.1CZIRUF6QRCWG@gmail.com>
On Sat, Oct 17, 2026 at 06:31 PM Kumar Kartikeya Dwivedi <memxor@gmail.com> wrote:
> Overall this makes sense, I guess my one small nit is that since we've
> crossed the bridge on changing the compiler, we could just use a
> cleaner encoding of some new instruction
After a bit of back and forth... I think that's indeed a better path forward.
Especially, since three bugs that the bots found in patches 1-3 were there because r3 is
an ordinary register and JITs guess the meaning from the shape of the code.
> - The verifier treats it exactly as JNE r3, 0, so no new verifier
> semantics.
I suspect your bot was confused.
New jcond insn means that r3 is no longer used.
but we need new flavors of exit insn:
exit plain return
unwind_exit r0 = 0 and return to the pad of my return address
Otherwise plain 'exit' has to say something in some register for
the branch to look at, and a nounwind subprog called via callx has to
know about it.
The verifier needs one bit between exit of the callee and the next insn:
cfg:
unwind_goto has to follow a call or callx of a subprog
and cannot be a jump target
exit:
unwound = false
unwind_exit:
reject in a callback and when insn after the call isn't unwind_goto
unwound = true, r0 = 0
call of a global subprog that has unwind_exit:
explore the pad too
unwind_goto: (probably most complex one...)
goto unwound ? pad : next
JITs:
unwind_goto:
extable[n++] = { ret_addr -> pad }
unwind_exit:
my_ret_addr = bpf_unwind_target(my_ret_addr)
epilogue
So patches 2 and 3 are no longer an optimization, but they are probably simpler (crunching...)
private stack has to be solved too... oh well.
> If we encode unwind exit as another jcond variant
hmm. cfg and liveness know JCOND as 'can jump, can fallthrough'.
unwind_exit is neither. BPF_EXIT with src_reg = 1 fits better
(more new insns... hmm)
unwind_goto is BPF_JCOND with src_reg = BPF_UNWIND_GOTO next to
BPF_MAY_GOTO.
3-ish new insns in total... progress?
> then you can get rid of the decl tag as well
Yes.
going to reject unwind_exit in async and exception callbacks.
patches tomorrow... bots are tired today ;)
prev parent reply other threads:[~2026-10-19 2:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-18 1:02 [PATCH bpf-next 0/5] bpf: Unwinding via r3 Alexei Starovoitov
2026-10-18 1:02 ` [PATCH bpf-next 1/5] bpf: Support unwinding " Alexei Starovoitov
2026-10-18 1:32 ` sashiko-bot
2026-10-18 1:48 ` bot+bpf-ci
2026-10-18 1:02 ` [PATCH bpf-next 2/5] bpf, x86: Replace 'if r3 != 0 goto pad' after a call with an extable entry Alexei Starovoitov
2026-10-18 1:28 ` sashiko-bot
2026-10-18 1:02 ` [PATCH bpf-next 3/5] bpf, arm64: Support unwinding via r3 Alexei Starovoitov
2026-10-18 1:34 ` sashiko-bot
2026-10-18 1:02 ` [PATCH bpf-next 4/5] selftests/bpf: Add tests for " Alexei Starovoitov
2026-10-18 1:38 ` bot+bpf-ci
2026-10-18 1:02 ` [PATCH bpf-next 5/5] selftests/bpf: Add a C++ prog with exceptions Alexei Starovoitov
2026-10-18 1:38 ` bot+bpf-ci
2026-10-18 1:31 ` [PATCH bpf-next 0/5] bpf: Unwinding via r3 Kumar Kartikeya Dwivedi
2026-10-19 2:05 ` Alexei Starovoitov [this message]
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=DM8G3O0ZTUM9.MMBWXXQ7OP98@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=memxor@gmail.com \
/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.