On Fri, Jan 26, 2024 at 5:24 AM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote: > > On Thu, 2024-01-25 at 12:55 -0800, Andrii Nakryiko wrote: > [...] > > > @@ -6379,11 +6388,21 @@ static bool need_func_arg_type_fixup(const struct btf *btf, const struct bpf_pro > > /* special cases */ > > switch (prog->type) { > > case BPF_PROG_TYPE_KPROBE: > > - case BPF_PROG_TYPE_PERF_EVENT: > > /* `struct pt_regs *` is expected, but we need to fix up */ > > if (btf_is_struct(t) && strcmp(tname, "pt_regs") == 0) > > return true; > > break; > > Sorry, this was probably discussed, but I got lost a bit. > Kernel side does not change pt_regs for BPF_PROG_TYPE_KPROBE > (in ./kernel/bpf/btf.c:btf_validate_prog_ctx_type) > but here we do, why do it differently? > Hm... We do the same. After this patch w end up with this logic on libbpf side (which matches kernel-side one, I believe): for KPROBE => allow pt_regs (unconditionally) for PERF_EVENT => allow user_regs_struct|user_pt_regs|pt_regs, depending on bpf_user_pt_regs_t definition on host platform That should match what the kernel is doing. > [...]