From: Xin Liu <liuxin350@huawei.com>
To: <ast@kernel.org>, <daniel@iogearbox.net>, <andrii@kernel.org>,
<martin.lau@linux.dev>, <song@kernel.org>, <yhs@fb.com>,
<john.fastabend@gmail.com>, <kpsingh@kernel.org>,
<sdf@google.com>, <haoluo@google.com>, <jolsa@kernel.org>
Cc: <bpf@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<yanan@huawei.com>, <wuchangye@huawei.com>,
<xiesongyang@huawei.com>, <kongweibin2@huawei.com>,
<zhangmingyi5@huawei.com>, <liwei883@huawei.com>,
<liuxin350@huawei.com>
Subject: [PATCH] libbpf: extending BTF_KIND_INIT to accommodate some unusual types
Date: Mon, 22 Apr 2024 22:45:38 +0800 [thread overview]
Message-ID: <20240422144538.351722-1-liuxin350@huawei.com> (raw)
In btf__add_int, the size of the new btf_kind_int type is limited.
When the size is greater than 16, btf__add_int fails to be added
and -EINVAL is returned. This is usually effective.
However, when the built-in type __builtin_aarch64_simd_xi in the
NEON instruction is used in the code in the arm64 system, the value
of DW_AT_byte_size is 64. This causes btf__add_int to fail to
properly add btf information to it.
like this:
...
<1><cf>: Abbrev Number: 2 (DW_TAG_base_type)
<d0> DW_AT_byte_size : 64 // over max size 16
<d1> DW_AT_encoding : 5 (signed)
<d2> DW_AT_name : (indirect string, offset: 0x53): __builtin_aarch64_simd_xi
<1><d6>: Abbrev Number: 0
...
An easier way to solve this problem is to treat it as a base type
and set byte_size to 64. This patch is modified along these lines.
Fixes: 4a3b33f8579a ("libbpf: Add BTF writing APIs")
Signed-off-by: Xin Liu <liuxin350@huawei.com>
---
tools/lib/bpf/btf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 2d0840ef599a..0af121293b65 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -1934,7 +1934,7 @@ int btf__add_int(struct btf *btf, const char *name, size_t byte_sz, int encoding
if (!name || !name[0])
return libbpf_err(-EINVAL);
/* byte_sz must be power of 2 */
- if (!byte_sz || (byte_sz & (byte_sz - 1)) || byte_sz > 16)
+ if (!byte_sz || (byte_sz & (byte_sz - 1)) || byte_sz > 64)
return libbpf_err(-EINVAL);
if (encoding & ~(BTF_INT_SIGNED | BTF_INT_CHAR | BTF_INT_BOOL))
return libbpf_err(-EINVAL);
--
2.33.0
next reply other threads:[~2024-04-22 14:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-22 14:45 Xin Liu [this message]
2024-04-22 17:43 ` [PATCH] libbpf: extending BTF_KIND_INIT to accommodate some unusual types Andrii Nakryiko
2024-04-23 13:15 Xin Liu
2024-04-23 14:30 ` Alan Maguire
2024-04-24 6:52 ` Xin Liu
2024-04-23 20:12 ` Yonghong Song
2024-04-24 7:06 ` Xin Liu
2024-04-24 22:11 ` Yonghong Song
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=20240422144538.351722-1-liuxin350@huawei.com \
--to=liuxin350@huawei.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kongweibin2@huawei.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liwei883@huawei.com \
--cc=martin.lau@linux.dev \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=wuchangye@huawei.com \
--cc=xiesongyang@huawei.com \
--cc=yanan@huawei.com \
--cc=yhs@fb.com \
--cc=zhangmingyi5@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).