mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
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
This commit is contained in:
parent
c9e982b879
commit
961632d541
1 changed files with 6 additions and 3 deletions
|
@ -1670,9 +1670,10 @@ static int btf_dump_int_data(struct btf_dump *d,
|
||||||
{
|
{
|
||||||
__u8 encoding = btf_int_encoding(t);
|
__u8 encoding = btf_int_encoding(t);
|
||||||
bool sign = encoding & BTF_INT_SIGNED;
|
bool sign = encoding & BTF_INT_SIGNED;
|
||||||
|
char buf[16] __aligned(16);
|
||||||
int sz = t->size;
|
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);
|
pr_warn("unexpected size %d for id [%u]\n", sz, type_id);
|
||||||
return -EINVAL;
|
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
|
/* handle packed int data - accesses of integers not aligned on
|
||||||
* int boundaries can cause problems on some platforms.
|
* int boundaries can cause problems on some platforms.
|
||||||
*/
|
*/
|
||||||
if (!ptr_is_aligned(data, sz))
|
if (!ptr_is_aligned(data, sz)) {
|
||||||
return btf_dump_bitfield_data(d, t, data, 0, 0);
|
memcpy(buf, data, sz);
|
||||||
|
data = buf;
|
||||||
|
}
|
||||||
|
|
||||||
switch (sz) {
|
switch (sz) {
|
||||||
case 16: {
|
case 16: {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue