All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Protopopov <a.s.protopopov@gmail.com>
To: Eduard Zingerman <eddyz87@gmail.com>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Anton Protopopov <aspsk@isovalent.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Quentin Monnet <qmo@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>
Subject: Re: [PATCH v3 bpf-next 08/13] bpf, x86: add support for indirect jumps
Date: Mon, 29 Sep 2025 14:10:16 +0000	[thread overview]
Message-ID: <aNqTSJFlZUogqP28@mail.gmail.com> (raw)
In-Reply-To: <aNWE3x7SwgyTglAN@mail.gmail.com>

On 25/09/25 06:07PM, Anton Protopopov wrote:
> On 25/09/19 05:28PM, Eduard Zingerman wrote:
> > On Thu, 2025-09-18 at 09:38 +0000, Anton Protopopov wrote:
> [...]
> > > +static int check_indirect_jump(struct bpf_verifier_env *env, struct bpf_insn *insn)
> > > +{
> > > +	struct bpf_verifier_state *other_branch;
> > > +	struct bpf_reg_state *dst_reg;
> > > +	struct bpf_map *map;
> > > +	u32 min_index, max_index;
> > > +	int err = 0;
> > > +	u32 *xoff;
> > > +	int n;
> > > +	int i;
> > > +
> > > +	dst_reg = reg_state(env, insn->dst_reg);
> > > +	if (dst_reg->type != PTR_TO_INSN) {
> > > +		verbose(env, "R%d has type %d, expected PTR_TO_INSN\n",
> > > +			     insn->dst_reg, dst_reg->type);
> > > +		return -EINVAL;
> > > +	}
> > > +
> > > +	map = dst_reg->map_ptr;
> > > +	if (verifier_bug_if(!map, env, "R%d has an empty map pointer", insn->dst_reg))
> > > +		return -EFAULT;
> > > +
> > > +	if (verifier_bug_if(map->map_type != BPF_MAP_TYPE_INSN_ARRAY, env,
> > > +			    "R%d has incorrect map type %d", insn->dst_reg, map->map_type))
> > > +		return -EFAULT;
> > > +
> > > +	err = indirect_jump_min_max_index(env, insn->dst_reg, map, &min_index, &max_index);
> > > +	if (err)
> > > +		return err;
> > > +
> > > +	xoff = kvcalloc(max_index - min_index + 1, sizeof(u32), GFP_KERNEL_ACCOUNT);
> > > +	if (!xoff)
> > > +		return -ENOMEM;
> > 
> > Let's keep a buffer for this allocation in `env` and realloc it when needed.
> > Would be good to avoid allocating memory each time this gotox is visited.
> 
> Ok (to put it in bpf_subprog_info as suggested in your next letter).
> Though, probably it still needs to grow (= realloc).

On a second thought, this doesn't work in general case: hard to avoid
copying/sorting. Every other request wants to do sort(M[start, end]).
All three things are vaiables: M, start, end. For now I will just add
a buffer to avoid allocations.

> [...]

  reply	other threads:[~2025-09-29 14:04 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-18  9:38 [PATCH v3 bpf-next 00/13] BPF indirect jumps Anton Protopopov
2025-09-18  9:38 ` [PATCH v3 bpf-next 01/13] bpf: fix the return value of push_stack Anton Protopopov
2025-09-19  0:17   ` Eduard Zingerman
2025-09-19  7:18     ` Anton Protopopov
2025-09-18  9:38 ` [PATCH v3 bpf-next 02/13] bpf: save the start of functions in bpf_prog_aux Anton Protopopov
2025-09-18  9:38 ` [PATCH v3 bpf-next 03/13] bpf, x86: add new map type: instructions array Anton Protopopov
2025-09-18  9:38 ` [PATCH v3 bpf-next 04/13] selftests/bpf: add selftests for new insn_array map Anton Protopopov
2025-09-18  9:38 ` [PATCH v3 bpf-next 05/13] bpf: support instructions arrays with constants blinding Anton Protopopov
2025-09-19  6:35   ` Eduard Zingerman
2025-09-19  7:05     ` Anton Protopopov
2025-09-19  7:12       ` Eduard Zingerman
2025-09-19 18:26         ` Alexei Starovoitov
2025-09-19 19:28           ` Daniel Borkmann
2025-09-19 19:44             ` Eduard Zingerman
2025-09-19 20:27               ` Anton Protopopov
2025-09-19 20:47                 ` Eduard Zingerman
2025-09-22  9:28                   ` Anton Protopopov
2025-09-30  9:07                     ` Anton Protopopov
2025-09-19 21:41               ` Daniel Borkmann
2025-09-18  9:38 ` [PATCH v3 bpf-next 06/13] selftests/bpf: test instructions arrays with blinding Anton Protopopov
2025-09-18  9:38 ` [PATCH v3 bpf-next 07/13] bpf, x86: allow indirect jumps to r8...r15 Anton Protopopov
2025-09-19 18:25   ` Eduard Zingerman
2025-09-19 18:38     ` Eduard Zingerman
2025-09-19 19:25       ` Anton Protopopov
2025-09-18  9:38 ` [PATCH v3 bpf-next 08/13] bpf, x86: add support for indirect jumps Anton Protopopov
2025-09-20  0:28   ` Eduard Zingerman
2025-09-21 19:12     ` Eduard Zingerman
2025-09-25 18:07     ` Anton Protopopov
2025-09-29 14:10       ` Anton Protopopov [this message]
2025-09-18  9:38 ` [PATCH v3 bpf-next 09/13] bpf: disasm: add support for BPF_JMP|BPF_JA|BPF_X Anton Protopopov
2025-09-18  9:38 ` [PATCH v3 bpf-next 10/13] libbpf: fix formatting of bpf_object__append_subprog_code Anton Protopopov
2025-09-19 23:18   ` Andrii Nakryiko
2025-09-18  9:38 ` [PATCH v3 bpf-next 11/13] libbpf: support llvm-generated indirect jumps Anton Protopopov
2025-09-19 23:18   ` Andrii Nakryiko
2025-09-22 10:13     ` Anton Protopopov
2025-09-18  9:38 ` [PATCH v3 bpf-next 12/13] bpftool: Recognize insn_array map type Anton Protopopov
2025-09-18  9:38 ` [PATCH v3 bpf-next 13/13] selftests/bpf: add selftests for indirect jumps Anton Protopopov
2025-09-20  0:58   ` Eduard Zingerman
2025-09-20 22:27     ` Eduard Zingerman
2025-09-20 22:32       ` Eduard Zingerman
2025-09-25 18:14       ` Anton Protopopov
2025-09-19  6:46 ` [PATCH v3 bpf-next 00/13] BPF " Eduard Zingerman
2025-09-19 14:57   ` Anton Protopopov
2025-09-19 16:49     ` Eduard Zingerman
2025-09-19 17:27   ` Eduard Zingerman
2025-09-19 18:03     ` Eduard Zingerman

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=aNqTSJFlZUogqP28@mail.gmail.com \
    --to=a.s.protopopov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=aspsk@isovalent.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=qmo@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 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.