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@xxxxxxxxxx> > Acked-by: Yonghong Song <yonghong.song@xxxxxxxxx> > --- 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; > [...]