[PATCH bpf v1] selftests/bpf: Fix runqslower cross-endian build

2025-01-24 Thread Tony Ambardar
From: Tony Ambardar The runqslower binary from a cross-endian build currently fails to run because the included skeleton has host endianness. Fix this by passing the target BPF endianness to the runqslower sub-make. Fixes: 5a63c33d6f00 ("selftests/bpf: Support cross-endian building")

[PATCH bpf v1] selftests/bpf: Fix cross-compiling urandom_read

2024-10-08 Thread Tony Ambardar
LD), passed via '-fuse-ld=' using an absolute path rather than a linker "flavour". Fixes: 08c79c9cd67f ("selftests/bpf: Don't force lld on non-x86 architectures") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/Makefile | 2 +- 1 file change

[PATCH bpf v1] selftests/bpf: Fix error compiling cgroup_ancestor.c with musl libc

2024-10-08 Thread Tony Ambardar
ument to allow compiling for both musl and glibc. Cc: Alexis Lothoré (eBPF Foundation) Fixes: f957c230e173 ("selftests/bpf: convert test_skb_cgroup_id_user to test_progs") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/prog_tests/cgroup_ancestor.c | 2 +- 1 file changed,

[PATCH bpf-next v1 3/3] tools/bpf, selftests/bpf : Sync btf_ids.h to tools

2024-09-20 Thread Tony Ambardar
Update to include latest changes, including BTF_SET8 support and correct alignment of .BTF_ids sections, and remove the now-redundant alignment fix introduced in 3effc06a4dde ("selftests/bpf: Fix alignment of .BTF_ids"). CC: Jean-Philippe Brucker Signed-off-by: Tony Ambardar --- too

[PATCH bpf-next v1 2/3] bpf: btf: Ensure natural alignment of .BTF_ids section

2024-09-20 Thread Tony Ambardar
encoding macros in btf_ids.h to always align BTF ID data to 4 bytes. [1]: 3effc06a4dde ("selftests/bpf: Fix alignment of .BTF_ids") Signed-off-by: Tony Ambardar --- include/linux/btf_ids.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/btf_ids.h b/include/linux/btf_i

[PATCH bpf-next v1 1/3] tools/resolve_btfids: Simplify handling cross-endian compilation

2024-09-20 Thread Tony Ambardar
ot;) CC: Viktor Malik Signed-off-by: Tony Ambardar --- tools/bpf/resolve_btfids/main.c | 60 - 1 file changed, 22 insertions(+), 38 deletions(-) diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c index d54aaa0619df..9f1ab23ed014 100644

[PATCH bpf-next v1 0/3] Improve .BTF_ids patching and alignment

2024-09-20 Thread Tony Ambardar
data is 4-byte aligned, and not only the .BTF_ids used for vmlinux. Patch #3 syncs the above changes in btf_ids.h to tools/include, obviating a previous alignment fix in selftests/bpf. Feedback and suggestions are welcome! Best regards, Tony Tony Ambardar (3): tools/resolve_btfids: Simplify

[PATCH bpf-next v6 8/8] selftests/bpf: Support cross-endian building

2024-09-16 Thread Tony Ambardar
Update Makefile build rules to compile BPF programs with target endianness rather than host byte-order. With recent changes, this allows building the full selftests/bpf suite hosted on x86_64 and targeting s390x or mips64eb for example. Acked-by: Yonghong Song Signed-off-by: Tony Ambardar

[PATCH bpf-next v6 7/8] libbpf: Support creating light skeleton of either endianness

2024-09-16 Thread Tony Ambardar
to target byte-order on finalization. Add support functions to convert data to target endianness as it is added to the blob. Also add additional debug logging for data blob structure details and skeleton loading. Acked-by: Alexei Starovoitov Signed-off-by: Tony Ambardar --- too

[PATCH bpf-next v6 6/8] libbpf: Support linking bpf objects of either endianness

2024-09-16 Thread Tony Ambardar
. This is enabled by built-in ELF translation and recent BTF/BTF.ext endianness functions. Further add local functions for swapping byte-order of sections containing BPF insns. Signed-off-by: Tony Ambardar --- tools/lib/bpf/linker.c | 78 +- 1 file changed

[PATCH bpf-next v6 5/8] libbpf: Support opening bpf objects of either endianness

2024-09-16 Thread Tony Ambardar
Allow bpf_object__open() to access files of either endianness, and convert included BPF programs to native byte-order in-memory for introspection. Loading BPF objects of non-native byte-order is still disallowed however. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf.c | 51

[PATCH bpf-next v6 4/8] libbpf: Support BTF.ext loading and output in either endianness

2024-09-16 Thread Tony Ambardar
btf_ext__endianness() and btf_ext__set_endianness() for query and setting byte-order, as already exist for BTF data. [1] 3289959b97ca ("libbpf: Support BTF loading and raw data output in both endianness") [2] 8fd27bf69b86 ("libbpf: Add BPF static linker BTF and BTF.ext support") Signed-o

[PATCH bpf-next v6 3/8] libbpf: Fix output .symtab byte-order during linking

2024-09-16 Thread Tony Ambardar
rectly translated. Fixes: faf6ed321cf6 ("libbpf: Add BPF static linker APIs") Signed-off-by: Tony Ambardar --- tools/lib/bpf/linker.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c index e0005c6ade88..6985ab0f1ca9 100644 --- a/tools/l

[PATCH bpf-next v6 2/8] libbpf: Fix header comment typos for BTF.ext

2024-09-16 Thread Tony Ambardar
Mention struct btf_ext_info_sec rather than non-existent btf_sec_func_info in BTF.ext struct documentation. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf

[PATCH bpf-next v6 1/8] libbpf: Improve log message formatting

2024-09-16 Thread Tony Ambardar
Fix missing newlines and extraneous terminal spaces in messages. Signed-off-by: Tony Ambardar --- tools/lib/bpf/btf.c | 6 +++--- tools/lib/bpf/btf_dump.c | 2 +- tools/lib/bpf/btf_relocate.c | 2 +- tools/lib/bpf/libbpf.c | 4 ++-- tools/lib/bpf/relo_core.c| 2 +- 5

[PATCH bpf-next v6 0/8] libbpf, selftests/bpf: Support cross-endian usage

2024-09-16 Thread Tony Ambardar
s logic - remove an 'inline' usage related to CI checkpatch failure - improve some formatting noted by checkpatch warnings - unexpected 'test_progs' failures drop 3 -> 2 (x86_64 to s390x cross) Tony Ambardar (8): libbpf: Improve log message formatting libbpf: Fix heade

Re: [PATCH bpf-next v5 4/8] libbpf: Support BTF.ext loading and output in either endianness

2024-09-16 Thread Tony Ambardar
On Wed, Sep 04, 2024 at 12:48:36PM -0700, Andrii Nakryiko wrote: > On Tue, Sep 3, 2024 at 12:33 AM Tony Ambardar wrote: > > > > Support for handling BTF data of either endianness was added in [1], but > > did not include BTF.ext data for lack of use cases. Later, support for

Re: [PATCH bpf-next v4 4/8] libbpf: Support BTF.ext loading and output in either endianness

2024-09-16 Thread Tony Ambardar
On Fri, Aug 30, 2024 at 05:15:06PM -0700, Eduard Zingerman wrote: > On Fri, 2024-08-30 at 00:29 -0700, Tony Ambardar wrote: > > [...] > > > @@ -3050,11 +3127,42 @@ static int btf_ext_parse_hdr(__u8 *data, __u32 > > data_size) > > return -ENOTS

Re: [PATCH bpf-next v5 7/8] libbpf: Support creating light skeleton of either endianness

2024-09-03 Thread Tony Ambardar
On Tue, Sep 03, 2024 at 12:57:51PM -0700, Alexei Starovoitov wrote: > On Tue, Sep 3, 2024 at 12:34 AM Tony Ambardar wrote: > > > > @@ -1040,10 +1121,11 @@ void bpf_gen__map_update_elem(struct bpf_gen *gen, > > int map_idx, void *pvalue, > > int zero = 0; >

[PATCH bpf-next v5 8/8] selftests/bpf: Support cross-endian building

2024-09-03 Thread Tony Ambardar
Update Makefile build rules to compile BPF programs with target endianness rather than host byte-order. With recent changes, this allows building the full selftests/bpf suite hosted on x86_64 and targeting s390x or mips64eb for example. Signed-off-by: Tony Ambardar --- tools/testing/selftests

[PATCH bpf-next v5 7/8] libbpf: Support creating light skeleton of either endianness

2024-09-03 Thread Tony Ambardar
to target byte-order on finalization. Add support functions to convert data to target endianness as it is added to the blob. Also add additional debug logging for data blob structure details and skeleton loading. Signed-off-by: Tony Ambardar --- tools/lib/bpf/bpf_gen_internal.h | 1 + too

[PATCH bpf-next v5 6/8] libbpf: Support linking bpf objects of either endianness

2024-09-03 Thread Tony Ambardar
. This is enabled by built-in ELF translation and recent BTF/BTF.ext endianness functions. Further add local functions for swapping byte-order of sections containing BPF insns. Signed-off-by: Tony Ambardar --- tools/lib/bpf/linker.c | 78 +- 1 file changed

[PATCH bpf-next v5 5/8] libbpf: Support opening bpf objects of either endianness

2024-09-03 Thread Tony Ambardar
Allow bpf_object__open() to access files of either endianness, and convert included BPF programs to native byte-order in-memory for introspection. Loading BPF objects of non-native byte-order is still disallowed however. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf.c | 52

[PATCH bpf-next v5 4/8] libbpf: Support BTF.ext loading and output in either endianness

2024-09-03 Thread Tony Ambardar
btf_ext__endianness() and btf_ext__set_endianness() for query and setting byte-order, as already exist for BTF data. [1] 3289959b97ca ("libbpf: Support BTF loading and raw data output in both endianness") [2] 8fd27bf69b86 ("libbpf: Add BPF static linker BTF and BTF.ext support") Signed-o

[PATCH bpf-next v5 3/8] libbpf: Fix output .symtab byte-order during linking

2024-09-03 Thread Tony Ambardar
rectly translated. Fixes: faf6ed321cf6 ("libbpf: Add BPF static linker APIs") Signed-off-by: Tony Ambardar --- tools/lib/bpf/linker.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c index 9cd3d4109788..7489306cd6f7 100644 --- a/tools/l

[PATCH bpf-next v5 2/8] libbpf: Fix header comment typos for BTF.ext

2024-09-03 Thread Tony Ambardar
Mention struct btf_ext_info_sec rather than non-existent btf_sec_func_info in BTF.ext struct documentation. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf

[PATCH bpf-next v5 1/8] libbpf: Improve log message formatting

2024-09-03 Thread Tony Ambardar
Fix missing newlines and extraneous terminal spaces in messages. Signed-off-by: Tony Ambardar --- tools/lib/bpf/btf.c | 6 +++--- tools/lib/bpf/btf_dump.c | 2 +- tools/lib/bpf/btf_relocate.c | 2 +- tools/lib/bpf/libbpf.c | 4 ++-- tools/lib/bpf/relo_core.c| 2 +- 5

[PATCH bpf-next v5 0/8] libbpf, selftests/bpf: Support cross-endian usage

2024-09-03 Thread Tony Ambardar
fixed a light skeleton bug causing test_progs 'map_ptr' failure - simplified some BTF.ext related endianness logic - remove an 'inline' usage related to CI checkpatch failure - improve some formatting noted by checkpatch warnings - unexpected 'test_progs' failures drop

Re: [PATCH bpf-next v4 4/8] libbpf: Support BTF.ext loading and output in either endianness

2024-09-02 Thread Tony Ambardar
On Fri, Aug 30, 2024 at 02:14:19PM -0700, Andrii Nakryiko wrote: > On Fri, Aug 30, 2024 at 12:30 AM Tony Ambardar > wrote: > > > > Support for handling BTF data of either endianness was added in [1], but > > did not include BTF.ext data for lack of use cases. Later

Re: [PATCH bpf-next v4 5/8] libbpf: Support opening bpf objects of either endianness

2024-08-31 Thread Tony Ambardar
On Fri, Aug 30, 2024 at 06:26:10PM -0700, Eduard Zingerman wrote: > On Fri, 2024-08-30 at 14:25 -0700, Andrii Nakryiko wrote: > > [...] > > > > err = bpf_object__elf_init(obj); > > > - err = err ? : bpf_object__check_endianness(obj); > > > err = err ? : bpf_object__elf_colle

Re: [PATCH bpf-next v4 5/8] libbpf: Support opening bpf objects of either endianness

2024-08-31 Thread Tony Ambardar
On Fri, Aug 30, 2024 at 06:16:25PM -0700, Eduard Zingerman wrote: > On Fri, 2024-08-30 at 00:29 -0700, Tony Ambardar wrote: > > [...] > > > @@ -940,6 +942,21 @@ bpf_object__add_programs(struct bpf_object *obj, > > Elf_Data *sec_data, > > return 0;

Re: [PATCH bpf-next v4 5/8] libbpf: Support opening bpf objects of either endianness

2024-08-31 Thread Tony Ambardar
On Fri, Aug 30, 2024 at 02:25:54PM -0700, Andrii Nakryiko wrote: > On Fri, Aug 30, 2024 at 12:30 AM Tony Ambardar > wrote: > > > > Allow bpf_object__open() to access files of either endianness, and convert > > included BPF programs to native byte-order in-memory for in

Re: [PATCH bpf-next v4 6/8] libbpf: Support linking bpf objects of either endianness

2024-08-31 Thread Tony Ambardar
On Fri, Aug 30, 2024 at 02:25:07PM -0700, Andrii Nakryiko wrote: > On Fri, Aug 30, 2024 at 12:30 AM Tony Ambardar > wrote: > > > > Allow static linking object files of either endianness, checking that input > > files have consistent byte-order, and setting outp

Re: [PATCH bpf-next v4 7/8] libbpf: Support creating light skeleton of either endianness

2024-08-31 Thread Tony Ambardar
On Fri, Aug 30, 2024 at 06:24:47PM -0700, Alexei Starovoitov wrote: > On Fri, Aug 30, 2024 at 2:31 PM Andrii Nakryiko > wrote: > > > > > > > > for the rest, Alexei, can you please review and give your ack? > > It looks fine. > All of the additional pr_debug()s look a bit excessive. > Will take an

Re: [PATCH bpf-next v4 7/8] libbpf: Support creating light skeleton of either endianness

2024-08-31 Thread Tony Ambardar
On Fri, Aug 30, 2024 at 02:30:46PM -0700, Andrii Nakryiko wrote: > On Fri, Aug 30, 2024 at 12:30 AM Tony Ambardar > wrote: > > > > Track target endianness in 'struct bpf_gen' and process in-memory data in > > native byte-order, but on finalization convert th

Re: [PATCH bpf-next v4 3/8] libbpf: Fix output .symtab byte-order during linking

2024-08-31 Thread Tony Ambardar
On Fri, Aug 30, 2024 at 03:15:10PM -0700, Eduard Zingerman wrote: > On Fri, 2024-08-30 at 00:29 -0700, Tony Ambardar wrote: > > Object linking output data uses the default ELF_T_BYTE type for '.symtab' > > section data, which disables any libelf-based translation. Explici

[PATCH bpf-next v4 5/8] libbpf: Support opening bpf objects of either endianness

2024-08-30 Thread Tony Ambardar
Allow bpf_object__open() to access files of either endianness, and convert included BPF programs to native byte-order in-memory for introspection. Loading BPF objects of non-native byte-order is still disallowed however. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf.c | 49

[PATCH bpf-next v4 4/8] libbpf: Support BTF.ext loading and output in either endianness

2024-08-30 Thread Tony Ambardar
btf_ext__endianness() and btf_ext__set_endianness() for query and setting byte-order, as already exist for BTF data. [1] 3289959b97ca ("libbpf: Support BTF loading and raw data output in both endianness") [2] 8fd27bf69b86 ("libbpf: Add BPF static linker BTF and BTF.ext support") Signed-o

[PATCH bpf-next v4 2/8] libbpf: Fix header comment typos for BTF.ext

2024-08-30 Thread Tony Ambardar
Mention struct btf_ext_info_sec rather than non-existent btf_sec_func_info in BTF.ext struct documentation. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf

[PATCH bpf-next v4 1/8] libbpf: Improve log message formatting

2024-08-30 Thread Tony Ambardar
Fix missing newlines and extraneous terminal spaces in messages. Signed-off-by: Tony Ambardar --- tools/lib/bpf/btf.c | 6 +++--- tools/lib/bpf/btf_dump.c | 2 +- tools/lib/bpf/btf_relocate.c | 2 +- tools/lib/bpf/libbpf.c | 4 ++-- tools/lib/bpf/relo_core.c| 2 +- 5

[PATCH bpf-next v4 0/8] libbpf, selftests/bpf: Support cross-endian usage

2024-08-30 Thread Tony Ambardar
fixed a light skeleton bug causing test_progs 'map_ptr' failure - simplified some BTF.ext related endianness logic - remove an 'inline' usage related to CI checkpatch failure - improve some formatting noted by checkpatch warnings - unexpected 'test_progs' failures

[PATCH bpf-next v4 3/8] libbpf: Fix output .symtab byte-order during linking

2024-08-30 Thread Tony Ambardar
rectly translated. Fixes: faf6ed321cf6 ("libbpf: Add BPF static linker APIs") Signed-off-by: Tony Ambardar --- tools/lib/bpf/linker.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c index 9cd3d4109788..7489306cd6f7 100644 --- a/tools/l

[PATCH bpf-next v4 7/8] libbpf: Support creating light skeleton of either endianness

2024-08-30 Thread Tony Ambardar
to target byte-order on finalization. Add support functions to convert data to target endianness as it is added to the blob. Also add additional debug logging for data blob structure details and skeleton loading. Signed-off-by: Tony Ambardar --- tools/lib/bpf/bpf_gen_internal.h | 1 + too

[PATCH bpf-next v4 6/8] libbpf: Support linking bpf objects of either endianness

2024-08-30 Thread Tony Ambardar
. This is enabled by built-in ELF translation and recent BTF/BTF.ext endianness functions. Further add local functions for swapping byte-order of sections containing BPF insns. Signed-off-by: Tony Ambardar --- tools/lib/bpf/linker.c | 90 ++ 1 file changed

[PATCH bpf-next v4 8/8] selftests/bpf: Support cross-endian building

2024-08-30 Thread Tony Ambardar
Update Makefile build rules to compile BPF programs with target endianness rather than host byte-order. With recent changes, this allows building the full selftests/bpf suite hosted on x86_64 and targeting s390x or mips64eb for example. Signed-off-by: Tony Ambardar --- tools/testing/selftests

Re: [PATCH bpf-next v3 0/8] libbpf, selftests/bpf: Support cross-endian usage

2024-08-28 Thread Tony Ambardar
On Wed, Aug 28, 2024 at 04:11:50AM -0700, Tony Ambardar wrote: > Hello all, [snip] > Changelog: > - > v2 -> v3: (feedback from Andrii) > - improve some log and commit message formatting > - restructure BTF.ext endianness safety checks and byte-swapping > -

[PATCH bpf-next v3 8/8] selftests/bpf: Support cross-endian building

2024-08-28 Thread Tony Ambardar
Update Makefile build rules to compile BPF programs with target endianness rather than host byte-order. With recent changes, this allows building the full selftests/bpf suite hosted on x86_64 and targeting s390x or mips64eb for example. Signed-off-by: Tony Ambardar --- tools/testing/selftests

[PATCH bpf-next v3 7/8] libbpf: Support creating light skeleton of either endianness

2024-08-28 Thread Tony Ambardar
to target byte-order on finalization. Add support functions to convert data to target endianness as it is added to the blob. Also add additional debug logging for data blob structure details and skeleton loading. Signed-off-by: Tony Ambardar --- tools/lib/bpf/bpf_gen_internal.h | 1 + too

[PATCH bpf-next v3 6/8] libbpf: Support linking bpf objects of either endianness

2024-08-28 Thread Tony Ambardar
. This is enabled by built-in ELF translation and recent BTF/BTF.ext endianness functions. Further add local functions for swapping byte-order of sections containing BPF insns. Signed-off-by: Tony Ambardar --- tools/lib/bpf/linker.c | 90 ++ 1 file changed

[PATCH bpf-next v3 5/8] libbpf: Support opening bpf objects of either endianness

2024-08-28 Thread Tony Ambardar
Allow bpf_object__open() to access files of either endianness, and convert included BPF programs to native byte-order in-memory for introspection. Loading BPF objects of non-native byte-order is still disallowed however. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf.c | 34

[PATCH bpf-next v3 4/8] libbpf: Support BTF.ext loading and output in either endianness

2024-08-28 Thread Tony Ambardar
exist for BTF data. [1] 3289959b97ca ("libbpf: Support BTF loading and raw data output in both endianness") [2] 8fd27bf69b86 ("libbpf: Add BPF static linker BTF and BTF.ext support") Signed-off-by: Tony Ambardar --- tools/lib/bpf/btf.c | 226 +++

[PATCH bpf-next v3 3/8] libbpf: Fix output .symtab byte-order during linking

2024-08-28 Thread Tony Ambardar
rectly translated. Fixes: faf6ed321cf6 ("libbpf: Add BPF static linker APIs") Signed-off-by: Tony Ambardar --- tools/lib/bpf/linker.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c index 9cd3d4109788..7489306cd6f7 100644 --- a/tools/l

[PATCH bpf-next v3 2/8] libbpf: Fix header comment typos for BTF.ext

2024-08-28 Thread Tony Ambardar
Mention struct btf_ext_info_sec rather than non-existent btf_sec_func_info in BTF.ext struct documentation. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf

[PATCH bpf-next v3 1/8] libbpf: Improve log message formatting

2024-08-28 Thread Tony Ambardar
Fix missing newlines and extraneous terminal spaces in messages. Signed-off-by: Tony Ambardar --- tools/lib/bpf/btf.c | 6 +++--- tools/lib/bpf/btf_dump.c | 2 +- tools/lib/bpf/btf_relocate.c | 2 +- tools/lib/bpf/libbpf.c | 4 ++-- tools/lib/bpf/relo_core.c| 2 +- 5

[PATCH bpf-next v3 0/8] libbpf, selftests/bpf: Support cross-endian usage

2024-08-28 Thread Tony Ambardar
formatting noted by checkpatch warnings - unexpected 'test_progs' failures drop 3 -> 2 (x86_64 to s390x cross) Tony Ambardar (8): libbpf: Improve log message formatting libbpf: Fix header comment typos for BTF.ext libbpf: Fix output .symtab byte-order during linking libbpf: Sup

Re: [PATCH bpf-next v2 7/8] libbpf: Support creating light skeleton of either endianness

2024-08-27 Thread Tony Ambardar
On Mon, Aug 26, 2024 at 02:25:27PM -0700, Andrii Nakryiko wrote: > On Mon, Aug 26, 2024 at 3:58 AM Tony Ambardar wrote: > > > > On Fri, Aug 23, 2024 at 12:47:56PM -0700, Andrii Nakryiko wrote: > > > On Thu, Aug 22, 2024 at 2:25 AM Tony Ambardar > > > wrote: &g

Re: [PATCH bpf-next v2 5/8] libbpf: Support opening bpf objects of either endianness

2024-08-27 Thread Tony Ambardar
On Mon, Aug 26, 2024 at 02:28:17PM -0700, Andrii Nakryiko wrote: > On Mon, Aug 26, 2024 at 3:53 AM Tony Ambardar wrote: > > > > On Fri, Aug 23, 2024 at 12:47:47PM -0700, Andrii Nakryiko wrote: > > > On Thu, Aug 22, 2024 at 2:25 AM Tony Ambardar > > > wrote: &g

Re: [PATCH bpf-next v2 7/8] libbpf: Support creating light skeleton of either endianness

2024-08-26 Thread Tony Ambardar
On Fri, Aug 23, 2024 at 12:47:56PM -0700, Andrii Nakryiko wrote: > On Thu, Aug 22, 2024 at 2:25 AM Tony Ambardar wrote: > > > > From: Tony Ambardar > > > > Track target endianness in 'struct bpf_gen' and process in-memory data in > > native byte-orde

Re: [PATCH bpf-next v2 6/8] libbpf: Support linking bpf objects of either endianness

2024-08-26 Thread Tony Ambardar
On Fri, Aug 23, 2024 at 12:47:52PM -0700, Andrii Nakryiko wrote: > On Thu, Aug 22, 2024 at 2:25 AM Tony Ambardar wrote: > > > > From: Tony Ambardar > > > > Allow static linking object files of either endianness, checking that input > > files have consiste

Re: [PATCH bpf-next v2 5/8] libbpf: Support opening bpf objects of either endianness

2024-08-26 Thread Tony Ambardar
On Fri, Aug 23, 2024 at 12:47:47PM -0700, Andrii Nakryiko wrote: > On Thu, Aug 22, 2024 at 2:25 AM Tony Ambardar wrote: > > > > From: Tony Ambardar > > > > Allow bpf_object__open() to access files of either endianness, and convert > > included BPF programs t

Re: [PATCH bpf-next v2 1/8] libbpf: Improve log message formatting

2024-08-26 Thread Tony Ambardar
On Thu, Aug 22, 2024 at 04:36:13PM -0700, Andrii Nakryiko wrote: > On Thu, Aug 22, 2024 at 2:24 AM Tony Ambardar wrote: > > > > From: Tony Ambardar > > > > Fix missing newlines and extraneous terminal spaces in messages. > > > > Signed-off-by: Tony Amb

[PATCH bpf-next v2 8/8] selftests/bpf: Support cross-endian building

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Update Makefile build rules to compile BPF programs with target endianness rather than host byte-order. With recent changes, this allows building the full selftests/bpf suite hosted on x86_64 and targeting s390x or mips64eb for example. Signed-off-by: Tony Ambardar

[PATCH bpf-next v2 4/8] libbpf: Support BTF.ext loading and output in either endianness

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Support for handling BTF data of either endianness was added in [1], but did not include BTF.ext data for lack of use cases. Later, support for static linking [2] provided a use case, but this feature and later ones were restricted to native-endian usage. Add support for

[PATCH bpf-next v2 7/8] libbpf: Support creating light skeleton of either endianness

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Track target endianness in 'struct bpf_gen' and process in-memory data in native byte-order, but on finalization convert the embedded loader BPF insns to target endianness. The light skeleton also includes a target-accessed data blob which is heterogeneous and thus

[PATCH bpf-next v2 6/8] libbpf: Support linking bpf objects of either endianness

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Allow static linking object files of either endianness, checking that input files have consistent byte-order, and setting output endianness from input. Linking requires in-memory processing of programs, relocations, sections, etc. in native endianness, and output conversion

[PATCH bpf-next v2 5/8] libbpf: Support opening bpf objects of either endianness

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Allow bpf_object__open() to access files of either endianness, and convert included BPF programs to native byte-order in-memory for introspection. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf.c | 21 +++-- tools/lib/bpf/libbpf_internal.h

[PATCH bpf-next v2 3/8] libbpf: Fix output .symtab byte-order during linking

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Object linking output data uses the default ELF_T_BYTE type for '.symtab' section data, which disables any libelf-based translation. Explicitly set the ELF_T_SYM type for output to restore libelf's byte-order conversion, noting that input '.symtab'

[PATCH bpf-next v2 2/8] libbpf: Fix header comment typos for BTF.ext

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Mention struct btf_ext_info_sec rather than non-existent btf_sec_func_info in BTF.ext struct documentation. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf

[PATCH bpf-next v2 0/8] libbpf, selftests/bpf: Support cross-endian usage

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Hello all, This patch series targets a long-standing BPF usability issue - the lack of general cross-compilation support - by enabling cross-endian usage of libbpf and bpftool, as well as supporting cross-endian build targets for selftests/bpf. Benefits include improved BPF

[PATCH bpf-next v2 1/8] libbpf: Improve log message formatting

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Fix missing newlines and extraneous terminal spaces in messages. Signed-off-by: Tony Ambardar --- tools/lib/bpf/btf.c | 7 --- tools/lib/bpf/btf_dump.c | 2 +- tools/lib/bpf/btf_relocate.c | 2 +- tools/lib/bpf/libbpf.c | 4 ++-- tools/lib/bpf

Re: [PATCH bpf-next v1 5/8] libbpf: Support opening bpf objects of either endianness

2024-08-22 Thread Tony Ambardar
On Wed, Aug 21, 2024 at 06:55:58PM -0700, Alexei Starovoitov wrote: > On Wed, Aug 21, 2024 at 2:10 AM Tony Ambardar wrote: > > > > > > +static inline void bpf_insn_bswap(struct bpf_insn *insn) > > +{ > > + /* dst_reg & src_reg nibbles */ > > +

[PATCH bpf-next v1 8/8] selftests/bpf: Support cross-endian building

2024-08-21 Thread Tony Ambardar
Update Makefile build rules to compile BPF programs with target endianness rather than host byte-order. With recent changes, this allows building the full selftests/bpf suite hosted on x86_64 and targeting s390x or mips64eb for example. Signed-off-by: Tony Ambardar --- tools/testing/selftests

[PATCH bpf-next v1 7/8] libbpf: Support creating light skeleton of either endianness

2024-08-21 Thread Tony Ambardar
to target byte-order on finalization. Add support functions to convert data to target endianness as it is added to the blob. Also add additional debug logging for data blob structure details and skeleton loading. Signed-off-by: Tony Ambardar --- tools/lib/bpf/bpf_gen_internal.h | 1 + too

[PATCH bpf-next v1 6/8] libbpf: Support linking bpf objects of either endianness

2024-08-21 Thread Tony Ambardar
. This is enabled by built-in ELF translation and recent BTF/BTF.ext endianness functions. Further add local functions for swapping byte-order of sections containing BPF insns. Signed-off-by: Tony Ambardar --- tools/lib/bpf/linker.c | 106 ++--- 1 file changed

[PATCH bpf-next v1 5/8] libbpf: Support opening bpf objects of either endianness

2024-08-21 Thread Tony Ambardar
Allow bpf_object__open() to access files of either endianness, and convert included BPF programs to native byte-order in-memory for introspection. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf.c | 21 +++-- tools/lib/bpf/libbpf_internal.h | 11 +++ 2

[PATCH bpf-next v1 4/8] libbpf: Support BTF.ext loading and output in either endianness

2024-08-21 Thread Tony Ambardar
exist for BTF data. [1]:commit 3289959b97ca ("libbpf: Support BTF loading and raw data output in both endianness") [2]:commit 8fd27bf69b86 ("libbpf: Add BPF static linker BTF and BTF.ext support") Signed-off-by: Tony Ambardar --- tools/lib/bpf/btf

[PATCH bpf-next v1 3/8] libbpf: Fix output .symtab byte-order during linking

2024-08-21 Thread Tony Ambardar
rectly translated. Fixes: faf6ed321cf6 ("libbpf: Add BPF static linker APIs") Signed-off-by: Tony Ambardar --- tools/lib/bpf/linker.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c index 9cd3d4109788..7489306cd6f7 100644 --- a/tools/l

[PATCH bpf-next v1 2/8] libbpf: Fix header comment typos for BTF.ext

2024-08-21 Thread Tony Ambardar
Mention struct btf_ext_info_sec rather than non-existent btf_sec_func_info in BTF.ext struct documentation. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf

[PATCH bpf-next v1 1/8] libbpf: Improve log message formatting

2024-08-21 Thread Tony Ambardar
Fix missing newlines and extraneous terminal spaces in messages. Signed-off-by: Tony Ambardar --- tools/lib/bpf/btf.c | 6 +++--- tools/lib/bpf/btf_dump.c | 2 +- tools/lib/bpf/btf_relocate.c | 2 +- tools/lib/bpf/libbpf.c | 4 ++-- tools/lib/bpf/relo_core.c| 2 +- 5

[PATCH bpf-next v1 0/8] libbpf, selftests/bpf: Support cross-endian usage

2024-08-21 Thread Tony Ambardar
thread includes some background regarding testing on QEMU/s390x and the generally favourable results (3 failures running test_progs): https://lore.kernel.org/bpf/ZsEcsaa3juxxQBUf@kodidev-ubuntu/ Feedback and suggestions are welcome! Best regards, Tony Tony Ambardar (8): libbpf: Improve log

[PATCH bpf-next v2 8/8] selftests/bpf: Fix error compiling tc_redirect.c with musl libc

2024-07-29 Thread Tony Ambardar
e the Y2038 roll-over. Fixes: ce6f6cffaeaa ("selftests/bpf: Wait for the netstamp_needed_key static key to be turned on") Fixes: c803475fd8dd ("bpf: selftests: test skb->tstamp in redirect_neigh") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/prog_tests/tc

[PATCH bpf-next v2 7/8] selftests/bpf: Fix using stdout, stderr as struct field names

2024-07-29 Thread Tony Ambardar
tion 'fprintf' 237 | fprintf(env.stdout, "#%-*d %s:", TEST_NUM_WIDTH, test->test_num, test->test_name); | ^~~ Link: https://lore.kernel.org/bpf/ZqR2DuHdBXPX%2Fyx8@kodidev-ubuntu/ Signed-off-by: Tony Ambardar --- .../selftests/bpf/

[PATCH bpf-next v2 6/8] selftests/bpf: Fix compile if backtrace support missing in libc

2024-07-29 Thread Tony Ambardar
/bpf: Print backtrace on SIGSEGV in test_progs") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/test_progs.c | 16 +++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c

[PATCH bpf-next v2 5/8] selftests/bpf: Fix redefinition errors compiling lwt_reroute.c

2024-07-29 Thread Tony Ambardar
back for unsupported libcs") [2]: https://git.musl-libc.org/cgit/musl/commit/?id=04983f227238 Fixes: 6c77997bc639 ("selftests/bpf: Add lwt_xmit tests for BPF_REROUTE") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/prog_tests/lwt_reroute.c | 1 + 1 file changed, 1

[PATCH bpf-next v2 4/8] selftests/bpf: Fix C++ compile error from missing _Bool type

2024-07-29 Thread Tony Ambardar
rrect type/include supporting C++, but in the meantime add a conditional define as above. Fixes: 7c8dce4b1661 ("bpftool: Make skeleton C code compilable with C++ compiler") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/test_cpp.cpp | 4 1 file changed, 4 insertions(+)

[PATCH bpf-next v2 3/8] selftests/bpf: Fix error compiling test_lru_map.c

2024-07-29 Thread Tony Ambardar
errors Fixes: 3fbfadce6012 ("bpf: Fix test_lru_sanity5() in test_lru_map.c") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/test_lru_map.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_lru_map.c b/tools/testing/selftests/bpf/test_l

[PATCH bpf-next v2 2/8] selftests/bpf: Fix arg parsing in veristat, test_progs

2024-07-29 Thread Tony Ambardar
Rewrite code using a counter to distinguish between strtok_r() calls. Fixes: 61ddff373ffa ("selftests/bpf: Improve by-name subtest selection logic in prog_tests") Fixes: 394169b079b5 ("selftests/bpf: add comparison mode to veristat") Fixes: c8bc5e050976 ("selftests/bpf: Add

[PATCH bpf-next v2 1/8] selftests/bpf: Use portable POSIX basename()

2024-07-29 Thread Tony Ambardar
ment. This is not needed in xskxceiver.c since the arg is mutable and the program exits immediately after usage. Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/veristat.c | 8 +--- tools/testing/selftests/bpf/xskxceiver.c | 1 + 2 files changed, 6 insertions(+), 3 deletion

[PATCH bpf-next v2 0/8] selftests/bpf: Improve libc portability / musl support (part 2)

2024-07-29 Thread Tony Ambardar
appreciated! Thanks, Tony Changelog: -- v1->v2: (feedback from Andrii) - P2: rewrite simpler code using counter - P5: update description/fix after more research - P6: use weak functions for backtrace stubs - P7: use stdxxx_saved names, update desc Tony Ambardar (8): selftests/bpf:

Re: [PATCH bpf-next v1 7/8] selftests/bpf: Fix using stdout, stderr as struct field names

2024-07-29 Thread Tony Ambardar
On Fri, Jul 26, 2024 at 09:22:38PM -0700, Tony Ambardar wrote: > On Thu, Jul 25, 2024 at 01:27:03PM -0700, Andrii Nakryiko wrote: > > On Thu, Jul 25, 2024 at 3:39 AM Tony Ambardar > > wrote: > > > > > > From: Tony Ambardar > > > > > > Typi

Re: [PATCH bpf-next v1 7/8] selftests/bpf: Fix using stdout, stderr as struct field names

2024-07-26 Thread Tony Ambardar
On Thu, Jul 25, 2024 at 01:27:03PM -0700, Andrii Nakryiko wrote: > On Thu, Jul 25, 2024 at 3:39 AM Tony Ambardar wrote: > > > > From: Tony Ambardar > > > > Typically stdin, stdout, stderr are treated as reserved identifiers under > > ISO/ANSI C, and a libc imple

Re: [PATCH bpf-next v1 5/8] selftests/bpf: Fix order-of-include compile errors in lwt_reroute.c

2024-07-26 Thread Tony Ambardar
On Thu, Jul 25, 2024 at 01:18:04PM -0700, Andrii Nakryiko wrote: > On Thu, Jul 25, 2024 at 3:39 AM Tony Ambardar wrote: > > > > From: Tony Ambardar > > > > Fix redefinition errors seen compiling lwt_reroute.c for mips64el/musl-libc > > by adjusting the order

Re: [PATCH bpf-next v1 6/8] selftests/bpf: Fix compile if backtrace support missing in libc

2024-07-26 Thread Tony Ambardar
On Thu, Jul 25, 2024 at 01:22:37PM -0700, Andrii Nakryiko wrote: > On Thu, Jul 25, 2024 at 3:39 AM Tony Ambardar wrote: > > > > From: Tony Ambardar > > > > Use backtrace functions only with glibc and otherwise provide stubs in > > test_progs.c. This avoids co

Re: [PATCH bpf-next v1 2/8] selftests/bpf: Fix arg parsing in veristat, test_progs

2024-07-26 Thread Tony Ambardar
On Thu, Jul 25, 2024 at 01:09:24PM -0700, Andrii Nakryiko wrote: > On Thu, Jul 25, 2024 at 3:39 AM Tony Ambardar wrote: > > ... > > --- a/tools/testing/selftests/bpf/testing_helpers.c > > +++ b/tools/testing/selftests/bpf/testing_helpers.c > > @@ -227,7 +227,7 @@ int

[PATCH bpf-next v1 8/8] selftests/bpf: Fix error compiling tc_redirect.c with musl libc

2024-07-25 Thread Tony Ambardar
From: Tony Ambardar Linux 5.1 implemented 64-bit time types and related syscalls to address the Y2038 problem generally across archs. Userspace handling of Y2038 varies with the libc however. While musl libc uses 64-bit time across all 32-bit and 64-bit platforms, GNU glibc uses 64-bit time on

[PATCH bpf-next v1 7/8] selftests/bpf: Fix using stdout, stderr as struct field names

2024-07-25 Thread Tony Ambardar
From: Tony Ambardar Typically stdin, stdout, stderr are treated as reserved identifiers under ISO/ANSI C, and a libc implementation is free to define these as macros. This is the case in musl libc and results in compile errors when these names are reused as struct fields, as with 's

[PATCH bpf-next v1 6/8] selftests/bpf: Fix compile if backtrace support missing in libc

2024-07-25 Thread Tony Ambardar
From: Tony Ambardar Use backtrace functions only with glibc and otherwise provide stubs in test_progs.c. This avoids compile errors (e.g. with musl libc) like: test_progs.c:13:10: fatal error: execinfo.h: No such file or directory 13 | #include /* backtrace

[PATCH bpf-next v1 5/8] selftests/bpf: Fix order-of-include compile errors in lwt_reroute.c

2024-07-25 Thread Tony Ambardar
From: Tony Ambardar Fix redefinition errors seen compiling lwt_reroute.c for mips64el/musl-libc by adjusting the order of includes in lwt_helpers.h. The ordering required is: --> (from "test_progs.h") --> . Because of the complexity and large number of includes, orderi

[PATCH bpf-next v1 4/8] selftests/bpf: Fix C++ compile error from missing _Bool type

2024-07-25 Thread Tony Ambardar
From: Tony Ambardar While building, bpftool makes a skeleton from test_core_extern.c, which itself includes and uses the 'bool' type. However, the skeleton test_core_extern.skel.h generated *does not* include or use the 'bool' type, instead using the C-only '_Bool'

[PATCH bpf-next v1 3/8] selftests/bpf: Fix error compiling test_lru_map.c

2024-07-25 Thread Tony Ambardar
From: Tony Ambardar Although the post-increment in macro 'CPU_SET(next++, &cpuset)' seems safe, the sequencing can raise compile errors, so move the increment outside the macro. This avoids an error seen using gcc 12.3.0 for mips64el/musl-libc: In file included from tes

  1   2   >