Re: [PATCH RFC bpf-next 15/31] bpf: Add get_func_arg[_cnt] support for kprobe multi functions

From: Alexei Starovoitov

Date: Wed Dec 02 2026 - 20:53:18 EST


On Wed, Dec 02, 2026 at 04:30 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
> + cnt = kprobe_multi_entry_args_cnt(run_ctx);
> + if (cnt < 0)
> + return cnt;
> + if (n >= cnt)
> + return -EINVAL;
> + *value = ftrace_regs_get_argument(run_ctx->fregs, n);

cnt is the number of args, but n selects a register.
They differ when a struct takes two registers. sockptr_t has 16 bytes:

sk_setsockopt(sk, level, optname, sockptr_t optval, optlen)
rdi rsi rdx rcx:r8 r9

n fentry entry, this patch inlined, patch 16
- ----------- ----------------- -----------------
3 optval, rcx optval, rcx -EOPNOTSUPP
4 optval, r8 optval, r8 optlen
5 optlen -EINVAL -EINVAL

optlen can't be read at the entry.
The same prog gets a different arg for n == 4 at an inlined instance.
Should n mean the same as in fentry?