From: Yonghong Song <yonghong.song@linux.dev>
To: Jiawei Zhao <phoenix500526@163.com>, ast@kernel.org
Cc: daniel@iogearbox.net, andrii@kernel.org, bpf@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 0/2] libbpf: fix USDT SIB argument handling causing unrecognized register error
Date: Wed, 6 Aug 2025 11:07:00 -0700 [thread overview]
Message-ID: <064cc6f1-8406-4cb4-8eb8-b02755079d7c@linux.dev> (raw)
In-Reply-To: <20250806092458.111972-1-phoenix500526@163.com>
On 8/6/25 2:24 AM, Jiawei Zhao wrote:
> 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)".
>
> The current USDT implementation in libbpf cannot parse these two formats,
> causing `bpf_program__attach_usdt()` to fail with -ENOENT
> (unrecognized register).
>
> This patch series adds support for SIB addressing mode in USDT probes.
> The main changes include:
> - add correct handling logic for SIB-addressed arguments in
> `parse_usdt_arg`.
> - add an usdt_o2 test case to cover SIB addressing mode.
>
> Testing shows that the SIB probe correctly generates 8@(%rcx,%rax,8)
> argument spec and passes all validation checks.
>
> The modification history of this patch series:
> Change since v1:
> - refactor the code to make it more readable
> - modify the commit message to explain why and how
>
> Change since v2:
> - fix the `scale` uninitialized error
>
> Change since v3:
> - force -O2 optimization for usdt.test.o to generate SIB addressing usdt
> and pass all test cases.
>
> Change since v4:
> - split the patch into two parts, one for the fix and the other for the
> test
>
> Change since v5:
> - Only enable optimization for x86 architecture to generate SIB addressing
> usdt argument spec.
>
> Change since v6:
> - Add an usdt_o2 test case to cover SIB addressing mode.
> - Reinstate the usdt.c test case.
>
> Do we need to add support for PC-relative USDT argument spec handling in
> libbpf? I have some interest in this question, but currently have no
> ideas. Getting offsets based on symbols requires dependency on the symbol
> table. However, once the binary file is stripped, the symtab will also be
> removed, which will cause this approach to fail. Does anyone have any
> thoughts on this?
>
>
> Jiawei Zhao (2):
> libbpf: fix USDT SIB argument handling causing unrecognized register
> error
> selftests/bpf: Force -O2 for USDT selftests to cover SIB handling
> logic
>
> tools/lib/bpf/usdt.bpf.h | 33 ++++++++-
> tools/lib/bpf/usdt.c | 43 +++++++++--
> tools/testing/selftests/bpf/Makefile | 8 +++
> .../selftests/bpf/prog_tests/usdt_o2.c | 71 +++++++++++++++++++
> .../selftests/bpf/progs/test_usdt_o2.c | 37 ++++++++++
> 5 files changed, 185 insertions(+), 7 deletions(-)
> create mode 100644 tools/testing/selftests/bpf/prog_tests/usdt_o2.c
> create mode 100644 tools/testing/selftests/bpf/progs/test_usdt_o2.c
>
Please add proper tag like [PATCH bpf-next v7 ...] so CI can test it
properly.
prev parent reply other threads:[~2025-08-06 18:07 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-06 9:24 [PATCH v7 0/2] libbpf: fix USDT SIB argument handling causing unrecognized register error Jiawei Zhao
2025-08-06 9:24 ` [PATCH v7 1/2] " Jiawei Zhao
2025-08-06 9:24 ` [PATCH v7 2/2] selftests/bpf: Force -O2 for USDT selftests to cover SIB handling logic Jiawei Zhao
2025-08-06 18:17 ` Yonghong Song
2025-08-07 2:57 ` 赵佳炜
2025-08-07 18:01 ` Yonghong Song
2025-08-10 8:55 ` 赵佳炜
2025-08-10 9:39 ` 赵佳炜
2025-08-12 5:06 ` Yonghong Song
2025-08-12 7:02 ` 赵佳炜
2025-08-12 16:11 ` Yonghong Song
2025-08-13 2:27 ` 赵佳炜
2025-08-13 5:24 ` Yonghong Song
2025-08-13 6:23 ` 赵佳炜
2025-08-17 13:43 ` 赵佳炜
2025-08-18 17:35 ` Yonghong Song
2025-08-19 9:50 ` 赵佳炜
2025-08-20 20:57 ` Yonghong Song
2025-08-20 23:00 ` Andrii Nakryiko
2025-08-21 15:38 ` 赵佳炜
2025-08-21 18:28 ` Andrii Nakryiko
2025-08-22 15:39 ` 赵佳炜
2025-08-07 9:28 ` Jiri Olsa
2025-08-06 18:07 ` Yonghong Song [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=064cc6f1-8406-4cb4-8eb8-b02755079d7c@linux.dev \
--to=yonghong.song@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=phoenix500526@163.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.