From: Eduard Zingerman <eddyz87@gmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>, memxor@gmail.com
Cc: puranjay@kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 1/6] bpf: Derive the atomic load register in one place
Date: Mon, 10 Aug 2026 10:10:26 -0700 [thread overview]
Message-ID: <704b266e251c6b7e503ba489bf87a92039369c09.camel@gmail.com> (raw)
In-Reply-To: <20260810134346.466004-1-daniel@iogearbox.net>
On Mon, 2026-08-10 at 15:43 +0200, Daniel Borkmann wrote:
...
> --- a/include/linux/filter.h
> +++ b/include/linux/filter.h
> @@ -414,6 +414,30 @@ static inline bool bpf_atomic_is_load_acq(const struct bpf_insn *insn)
> insn->imm == BPF_LOAD_ACQ;
> }
>
> +/*
> + * Given an instruction @insn, return the number of the BPF register that a
> + * BPF_ATOMIC reads the value at its memory operand into, or -1 if there is
> + * no such register. That is the register a BPF_PROBE_ATOMIC has to clear when
> + * the access faults. Like bpf_atomic_is_load_acq(), @insn is not assumed to
> + * be a BPF_ATOMIC here.
> + */
> +static inline int bpf_atomic_load_reg(const struct bpf_insn *insn)
> +{
> + if (BPF_CLASS(insn->code) != BPF_STX ||
> + (BPF_MODE(insn->code) != BPF_ATOMIC &&
> + BPF_MODE(insn->code) != BPF_PROBE_ATOMIC))
> + return -1;
> +
> + switch (insn->imm) {
> + case BPF_LOAD_ACQ:
> + return insn->dst_reg;
> + case BPF_CMPXCHG:
> + return BPF_REG_0;
> + default:
> + return (insn->imm & BPF_FETCH) ? insn->src_reg : -1;
> + }
> +}
> +
Hi Daniel,
Note that there is already a very similar fixups.c:insn_def_regno().
Should we try to avoid duplication?
...
next prev parent reply other threads:[~2026-08-10 17:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 13:43 [PATCH bpf-next 1/6] bpf: Derive the atomic load register in one place Daniel Borkmann
2026-08-10 13:43 ` [PATCH bpf-next 2/6] bpf, riscv: Clear fetch destination on faulting arena atomic Daniel Borkmann
2026-08-10 13:43 ` [PATCH bpf-next 3/6] bpf, x86: " Daniel Borkmann
2026-08-10 14:07 ` sashiko-bot
2026-08-10 14:08 ` Daniel Borkmann
2026-08-10 17:26 ` Eduard Zingerman
2026-08-10 18:22 ` Puranjay Mohan
2026-08-10 13:43 ` [PATCH bpf-next 4/6] bpf, arm64: " Daniel Borkmann
2026-08-10 18:20 ` Eduard Zingerman
2026-08-10 18:30 ` Puranjay Mohan
2026-08-10 18:36 ` Eduard Zingerman
2026-08-10 18:31 ` Puranjay Mohan
2026-08-10 13:43 ` [PATCH bpf-next 5/6] bpf, s390: " Daniel Borkmann
2026-08-10 13:43 ` [PATCH bpf-next 6/6] selftests/bpf: Add arena fault tests for atomics with fetch Daniel Borkmann
2026-08-10 18:56 ` Eduard Zingerman
2026-08-10 15:08 ` [PATCH bpf-next 1/6] bpf: Derive the atomic load register in one place bot+bpf-ci
2026-08-10 17:10 ` Eduard Zingerman [this message]
2026-08-10 18:13 ` Daniel Borkmann
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=704b266e251c6b7e503ba489bf87a92039369c09.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=memxor@gmail.com \
--cc=puranjay@kernel.org \
/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