Today libbpf can attach a single kprobe only by function name, with an optional offset. But the kernel also supports attaching a single kprobe directly by raw kernel address, through both legacy tracefs/debugfs kprobes and PMU-based non-legacy kprobes. Since libbpf doesn't support this yet, callers that already have a target IP still have to drop down to perf_event_open() or direct tracefs writes.
This patchset adds address-based single-kprobe attach support to bpf_program__attach_kprobe_opts() and covers it in selftests/bpf. The first commit adds bpf_kprobe_opts.addr so that libbpf can attach single kprobes by raw address through both legacy tracefs/debugfs and PMU-based non-legacy paths. The second commit extends attach_probe selftests/bpf with address-based kprobe attach subtests for these paths. Hoyeon Lee (2): libbpf: allow address-based single kprobe attach selftests/bpf: add test for address-based single kprobe attach tools/lib/bpf/libbpf.c | 77 +++++++++++++------ tools/lib/bpf/libbpf.h | 5 +- .../selftests/bpf/prog_tests/attach_probe.c | 49 ++++++++++++ 3 files changed, 106 insertions(+), 25 deletions(-) -- 2.52.0

