* [PATCH bpf-next] libbpf: Fix dumping enum bitfields on big-endian
@ 2026-11-25 8:12 Hungyu Lin
2026-11-25 21:10 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Hungyu Lin @ 2026-11-25 8:12 UTC (permalink / raw)
To: andrii, bpf
Cc: ast, daniel, eddyz87, memxor, martin.lau, song, yonghong.song,
jolsa, emil, ihor.solodrai, alan.maguire, dennylin0707
btf_dump_dump_type_data() reads an enum bitfield into the __s64
enum_val and passes &enum_val to btf_dump_enum_data(), where
btf_dump_get_enum_value() loads t->size bytes from that address. For
enums smaller than 8 bytes, those are the high-order bytes of enum_val
on big-endian, so every enum bitfield is dumped with value 0.
Pass the address of the low-order t->size bytes of enum_val instead,
so the value is loaded the same way on both byte orders.
Fixes: 920d16af9b42 ("libbpf: BTF dumper support for typed data")
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
tools/lib/bpf/btf_dump.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c
index bbe86928b3ec..08a4bbbf4ffd 100644
--- a/tools/lib/bpf/btf_dump.c
+++ b/tools/lib/bpf/btf_dump.c
@@ -2665,7 +2665,14 @@ static int btf_dump_dump_type_data(struct btf_dump *d,
if (err)
break;
enum_val = (__s64)print_num;
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
err = btf_dump_enum_data(d, t, id, &enum_val);
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ err = btf_dump_enum_data(d, t, id,
+ (void *)&enum_val + sizeof(enum_val) - t->size);
+#else
+# error "Unrecognized __BYTE_ORDER__"
+#endif
} else
err = btf_dump_enum_data(d, t, id, data);
break;
base-commit: 8dfce13340aeba06d1b68cc7648f37762244be65
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH bpf-next] libbpf: Fix dumping enum bitfields on big-endian
2026-11-25 8:12 [PATCH bpf-next] libbpf: Fix dumping enum bitfields on big-endian Hungyu Lin
@ 2026-11-25 21:10 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-11-25 21:10 UTC (permalink / raw)
To: Hungyu Lin
Cc: andrii, bpf, ast, daniel, eddyz87, memxor, martin.lau, song,
yonghong.song, jolsa, emil, ihor.solodrai, alan.maguire
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Wed, 25 Nov 2026 08:12:45 +0000 you wrote:
> btf_dump_dump_type_data() reads an enum bitfield into the __s64
> enum_val and passes &enum_val to btf_dump_enum_data(), where
> btf_dump_get_enum_value() loads t->size bytes from that address. For
> enums smaller than 8 bytes, those are the high-order bytes of enum_val
> on big-endian, so every enum bitfield is dumped with value 0.
>
> Pass the address of the low-order t->size bytes of enum_val instead,
> so the value is loaded the same way on both byte orders.
>
> [...]
Here is the summary with links:
- [bpf-next] libbpf: Fix dumping enum bitfields on big-endian
https://git.kernel.org/bpf/bpf-next/c/3cbbebf6819b
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-25 21:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 8:12 [PATCH bpf-next] libbpf: Fix dumping enum bitfields on big-endian Hungyu Lin
2026-11-25 21:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox