mirror of
https://github.com/netdata/libbpf.git
synced 2026-11-09 12:20:13 +08:00
libbpf: Add gating for arena globals relocation feature
Add feature gating for the arena globals relocation introduced in
commit c1f61171d44b. The commit depends on a previous commit in the
same patchset that is absent from older kernels
(12a1fe6e12db "bpf/verifier: Do not limit maximum direct offset into arena map").
Without this commit, arena globals relocation with arenas >= 512MiB
fails to load and breaks libbpf's backwards compatibility.
Introduce a libbpf feature to check whether the running kernel allows for
full range ldimm64 offset, and only relocate arena globals if it does.
Fixes: c1f61171d44b ("libbpf: Move arena globals to the end of the arena")
Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20260210184532.255475-1-emil@etsalapatis.com
This commit is contained in:
1 parent
ad0d0e5112
commit
429aaef6a3
3 files changed
+71
-2
No files matched your search
+5
-2
@@ -3009,8 +3009,11 @@ static int init_arena_map_data(struct bpf_object *obj, struct bpf_map *map,
|
||||
memcpy(obj->arena_data, data, data_sz);
|
||||
obj->arena_data_sz = data_sz;
|
||||
|
||||
/* place globals at the end of the arena */
|
||||
obj->arena_data_off = mmap_sz - data_alloc_sz;
|
||||
/* place globals at the end of the arena (if supported) */
|
||||
if (kernel_supports(obj, FEAT_LDIMM64_FULL_RANGE_OFF))
|
||||
obj->arena_data_off = mmap_sz - data_alloc_sz;
|
||||
else
|
||||
obj->arena_data_off = 0;
|
||||
|
||||
/* make bpf_map__init_value() work for ARENA maps */
|
||||
map->mmaped = obj->arena_data;
|
||||
|
||||
Reference in new issue
Block a user