-
Notifications
You must be signed in to change notification settings - Fork 148
libbpf: fix USDT SIB argument handling causing unrecognized register error #9509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: bpf-next_base
Are you sure you want to change the base?
Conversation
Upstream branch: 3ec8560 |
715d6cb
to
506c27a
Compare
Upstream branch: 1274163 |
5a58bce
to
e2fab0d
Compare
506c27a
to
76c716d
Compare
Upstream branch: d87fdb1 |
e2fab0d
to
ba4c44b
Compare
76c716d
to
f3b4b37
Compare
Upstream branch: dbe99ea |
ba4c44b
to
d739895
Compare
f3b4b37
to
bf66d41
Compare
Upstream branch: 6850a33 |
d739895
to
a86a5cb
Compare
bf66d41
to
74b5324
Compare
Upstream branch: dbe99ea |
a86a5cb
to
ad80fce
Compare
74b5324
to
c3c6b4b
Compare
Upstream branch: 5c42715 |
ad80fce
to
5c3e1af
Compare
c3c6b4b
to
1a79214
Compare
Upstream branch: bf7a6a6 |
5c3e1af
to
1d361da
Compare
1a79214
to
d47111e
Compare
Upstream branch: b5bbbb7 |
1d361da
to
195d988
Compare
d47111e
to
d07b74e
Compare
Upstream branch: 2693227 |
195d988
to
4a32afe
Compare
d07b74e
to
5057c80
Compare
Upstream branch: 78e097f |
…error On x86-64, USDT arguments can be specified using Scale-Index-Base (SIB) addressing, e.g. "1@-96(%rbp,%rax,8)". The current USDT implementation in libbpf cannot parse this format, causing `bpf_program__attach_usdt()` to fail with -ENOENT (unrecognized register). This patch fixes this by implementing the necessary changes: - add correct handling for SIB-addressed arguments in `bpf_usdt_arg`. - add adaptive support to `__bpf_usdt_arg_type` and `__bpf_usdt_arg_spec` to represent SIB addressing parameters. Signed-off-by: Jiawei Zhao <[email protected]>
…dling logic When using GCC on x86-64 to compile an usdt prog with -O1 or higher optimization, the compiler will generate SIB addressing mode for global array and PC-relative addressing mode for global variable, e.g. "1@-96(%rbp,%rax,8)" and "-1@4+t1(%rip)". In this patch: - add usdt_o1 test case to cover SIB addressing usdt argument spec handling logic Signed-off-by: Jiawei Zhao <[email protected]>
usdt_o1 is intended to exercise the SIB (Scale-Index-Base) argument handling in libbpf's USDT path. With GCC 13 this reliably produced a SIB-form argument (e.g. 8@(%rdx,%rax,8)), but with newer GCC (e.g. 15) the compiler frequently optimizes the probe argument into a plain register (e.g. 8@%rax) or a stack slot, so the test stops covering the SIB code path and becomes flaky across toolchains. Force a SIB memory operand in the probe by: * placing the base pointer into %rdx and the index into %rax using an empty inline asm with output constraints ("=d", "=a") and matching inputs * immediately passing base[idx] to STAP_PROBE1. * only enable on x86 platform. This makes the compiler encode the operand as SIB (base + index8), which in .note.stapsdt shows up as 8@(%rdx,%rax,8) regardless of GCC version. A memory clobber and noinline prevent reordering/re-allocation around the probe site. This change is x86_64-specific and does not alter program semantics; it only stabilizes the USDT argument shape so the test consistently validates SIB handling. Clang historically prefers stack temporaries for such operands, but the selftests build with GCC, and this keeps behavior stable across GCC versions without introducing a separate .S file. Signed-off-by: Jiawei Zhao <[email protected]>
4a32afe
to
1bb052a
Compare
Pull request for series with
subject: libbpf: fix USDT SIB argument handling causing unrecognized register error
version: 11
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=992429