summaryrefslogtreecommitdiff
path: root/tools/lib
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2021-10-13 18:09:01 +0200
committerAndrii Nakryiko <andrii@kernel.org>2021-10-20 11:40:45 -0700
commit961632d5416389a6f2e7478b674ac645c7e3ff01 (patch)
tree85e4b85c09f0a2074a8cbcec4925bc80aecef238 /tools/lib
parentc9e982b879465ca74e3593ce82808aa259265a71 (diff)
libbpf: Fix dumping non-aligned __int128
Non-aligned integers are dumped as bitfields, which is supported for at most 64-bit integers. Fix by using the same trick as btf_dump_float_data(): copy non-aligned values to the local buffer. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211013160902.428340-4-iii@linux.ibm.com
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/bpf/btf_dump.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c
index 679bf34e3f47..e98c201f29b5 100644
--- a/tools/lib/bpf/btf_dump.c
+++ b/tools/lib/bpf/btf_dump.c
@@ -1670,9 +1670,10 @@ static int btf_dump_int_data(struct btf_dump *d,
{
__u8 encoding = btf_int_encoding(t);
bool sign = encoding & BTF_INT_SIGNED;
+ char buf[16] __aligned(16);
int sz = t->size;
- if (sz == 0) {
+ if (sz == 0 || sz > sizeof(buf)) {
pr_warn("unexpected size %d for id [%u]\n", sz, type_id);
return -EINVAL;
}
@@ -1680,8 +1681,10 @@ static int btf_dump_int_data(struct btf_dump *d,
/* handle packed int data - accesses of integers not aligned on
* int boundaries can cause problems on some platforms.
*/
- if (!ptr_is_aligned(data, sz))
- return btf_dump_bitfield_data(d, t, data, 0, 0);
+ if (!ptr_is_aligned(data, sz)) {
+ memcpy(buf, data, sz);
+ data = buf;
+ }
switch (sz) {
case 16: {