libbpf: Add support for bpf_arena.
authorAlexei Starovoitov <ast@kernel.org>
Fri, 8 Mar 2024 01:08:06 +0000 (17:08 -0800)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 11 Mar 2024 22:37:24 +0000 (15:37 -0700)
commit79ff13e99169ddb0e2277e046dbfb112f77dfac5
tree4ebc8420dd502d99d541e538ec00c80e6e4b2b15
parent4d2b56081c32cb33364745da434b88eeaa9d8d8d
libbpf: Add support for bpf_arena.

mmap() bpf_arena right after creation, since the kernel needs to
remember the address returned from mmap. This is user_vm_start.
LLVM will generate bpf_arena_cast_user() instructions where
necessary and JIT will add upper 32-bit of user_vm_start
to such pointers.

Fix up bpf_map_mmap_sz() to compute mmap size as
map->value_size * map->max_entries for arrays and
PAGE_SIZE * map->max_entries for arena.

Don't set BTF at arena creation time, since it doesn't support it.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240308010812.89848-9-alexei.starovoitov@gmail.com
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf_probes.c