bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Puranjay Mohan <puranjay@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	 Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	 Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend	 <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev	 <sdf@fomichev.me>,
	Hao Luo <haoluo@google.com>, Jiri Olsa <jolsa@kernel.org>,
	 Xu Kuohai <xukuohai@huaweicloud.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon	 <will@kernel.org>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
		bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v5 3/4] bpf: Report arena faults to BPF stderr
Date: Tue, 02 Sep 2025 17:01:35 -0700	[thread overview]
Message-ID: <f41d83899f6d2dda1b55fe7f91f0816b9e23361a.camel@gmail.com> (raw)
In-Reply-To: <20250901193730.43543-4-puranjay@kernel.org>

On Mon, 2025-09-01 at 19:37 +0000, Puranjay Mohan wrote:
> Begin reporting arena page faults and the faulting address to BPF
> program's stderr, this patch adds support in the arm64 and x86-64 JITs,
> support for other archs can be added later.
> 
> The fault handlers receive the 32 bit address in the arena region so
> the upper 32 bits of user_vm_start is added to it before printing the
> address. This is what the user would expect to see as this is what is
> printed by bpf_printk() is you pass it an address returned by
> bpf_arena_alloc_pages();
> 
> Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
> Acked-by: Yonghong Song <yonghong.song@linux.dev>
> ---

Fwiw, aside from a nit below the patch looks good to me.

> diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
> index 7e3fca1646203..644424ae5e5d2 100644
> --- a/arch/x86/net/bpf_jit_comp.c
> +++ b/arch/x86/net/bpf_jit_comp.c

[...]

> @@ -2089,8 +2143,25 @@ st:			if (is_imm8(insn->off))
>  
>  				ex->data = EX_TYPE_BPF;
>  
> -				ex->fixup = (prog - start_of_ldx) |
> -					((BPF_CLASS(insn->code) == BPF_LDX ? reg2pt_regs[dst_reg] : DONT_CLEAR) << 8);
> +				is_arena = (BPF_MODE(insn->code) == BPF_PROBE_MEM32) ||
> +					   (BPF_MODE(insn->code) == BPF_PROBE_ATOMIC);

Nit:
It looks like label `populate_extable` is always reachable from either
BPF_PROB_MEM32 or BPF_PROBE_ATOMIC instruction. Non-arena use cases
for BPF_PROBE_MEM{,SX} are handled separately. So, it appears that
this condition is always true.

> +
> +				fixup_reg = (BPF_CLASS(insn->code) == BPF_LDX) ?
> +					    reg2pt_regs[dst_reg] : DONT_CLEAR;
> +
> +				ex->fixup = FIELD_PREP(FIXUP_INSN_LEN_MASK, prog - start_of_ldx) |
> +					    FIELD_PREP(FIXUP_REG_MASK, fixup_reg);
> +
> +				if (is_arena) {
> +					ex->fixup |= FIXUP_ARENA_ACCESS;
> +					if (BPF_CLASS(insn->code) == BPF_LDX)
> +						arena_reg = reg2pt_regs[src_reg];
> +					else
> +						arena_reg = reg2pt_regs[dst_reg];
> +
> +					ex->fixup |= FIELD_PREP(FIXUP_ARENA_REG_MASK, arena_reg);
> +					ex->data |= FIELD_PREP(DATA_ARENA_OFFSET_MASK, insn->off);
> +				}
>  			}
>  			break;
>  

[...]

  parent reply	other threads:[~2025-09-03  0:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-01 19:37 [PATCH bpf-next v5 0/4] bpf: report arena faults to BPF streams Puranjay Mohan
2025-09-01 19:37 ` [PATCH bpf-next v5 1/4] bpf: arm64: simplify exception table handling Puranjay Mohan
2025-09-01 19:37 ` [PATCH bpf-next v5 2/4] bpf: core: introduce main_prog_aux for stream access Puranjay Mohan
2025-09-02  2:25   ` Alexei Starovoitov
2025-09-02  2:32     ` Kumar Kartikeya Dwivedi
2025-09-01 19:37 ` [PATCH bpf-next v5 3/4] bpf: Report arena faults to BPF stderr Puranjay Mohan
2025-09-02 12:42   ` kernel test robot
2025-09-03  0:01   ` Eduard Zingerman [this message]
2025-09-01 19:37 ` [PATCH bpf-next v5 4/4] selftests/bpf: Add tests for arena fault reporting Puranjay Mohan
2025-09-02 16:22   ` Yonghong Song
2025-09-02 22:21   ` Eduard Zingerman
2025-09-05 14:00     ` Puranjay Mohan
2025-09-05 18:38       ` 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=f41d83899f6d2dda1b55fe7f91f0816b9e23361a.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=puranjay@kernel.org \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=will@kernel.org \
    --cc=xukuohai@huaweicloud.com \
    --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).