mbox series

[bpf-next,0/3] libbpf: support loading/storing any BTF endianness

Message ID 20200929043046.1324350-1-andriin@fb.com (mailing list archive)
Headers show
Series libbpf: support loading/storing any BTF endianness | expand

Message

Andrii Nakryiko Sept. 29, 2020, 4:30 a.m. UTC
Add support for loading and storing BTF in either little- or big-endian
integer encodings, regardless of host endianness. This allows users of libbpf
to not care about endianness when they don't want to and transparently
open/load BTF of any endianness. libbpf will preserve original endianness and
will convert output raw data as necessary back to original endianness, if
necessary. This allows tools like pahole to be ignorant to such issues during
cross-compilation.

While working with BTF data in memory, the endianness is always native to the
host. Convetion can happen only during btf__get_raw_data() call, and only in
a raw data copy.

Additionally, it's possible to force output BTF endianness through new
btf__set_endianness() API. This which allows to create flexible tools doing
arbitrary conversions of BTF endianness, just by relying on libbpf.

Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Cc: Tony Ambardar <tony.ambardar@gmail.com>
Cc: Ilya Leoshkevich <iii@linux.ibm.com>
Cc: Luka Perkov <luka.perkov@sartura.hr>

Andrii Nakryiko (3):
  selftests/bpf: move and extend ASSERT_xxx() testing macros
  libbpf: support BTF loading and raw data output in both endianness
  selftests/bpf: test BTF's handling of endianness

 tools/lib/bpf/btf.c                           | 310 ++++++++++++++----
 tools/lib/bpf/btf.h                           |   7 +
 tools/lib/bpf/libbpf.map                      |   2 +
 .../selftests/bpf/prog_tests/btf_endian.c     | 101 ++++++
 .../selftests/bpf/prog_tests/btf_write.c      |  34 --
 tools/testing/selftests/bpf/test_progs.h      |  63 ++++
 6 files changed, 419 insertions(+), 98 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/btf_endian.c

Comments

patchwork-bot+bpf@kernel.org Sept. 29, 2020, 8 p.m. UTC | #1
Hello:

This series was applied to bpf/bpf-next.git (refs/heads/master):

On Mon, 28 Sep 2020 21:30:43 -0700 you wrote:
> Add support for loading and storing BTF in either little- or big-endian
> integer encodings, regardless of host endianness. This allows users of libbpf
> to not care about endianness when they don't want to and transparently
> open/load BTF of any endianness. libbpf will preserve original endianness and
> will convert output raw data as necessary back to original endianness, if
> necessary. This allows tools like pahole to be ignorant to such issues during
> cross-compilation.
> 
> [...]

Here is the summary with links:
  - [bpf-next,1/3] selftests/bpf: move and extend ASSERT_xxx() testing macros
    https://git.kernel.org/bpf/bpf-next/c/22ba36351631
  - [bpf-next,2/3] libbpf: support BTF loading and raw data output in both endianness
    https://git.kernel.org/bpf/bpf-next/c/3289959b97ca
  - [bpf-next,3/3] selftests/bpf: test BTF's handling of endianness
    https://git.kernel.org/bpf/bpf-next/c/ed9cf248b949

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html