]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: allow for key-less BTF in array map
authorDaniel Borkmann <daniel@iogearbox.net>
Tue, 9 Apr 2019 21:20:10 +0000 (23:20 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 10 Apr 2019 00:05:46 +0000 (17:05 -0700)
commitc163d23781cc9b8eaf88fdd7c0a9df80ad0149b1
treebb72402c12f3dd2f34be1d12e460442e7ed79b54
parent30299c8fe5ddc4561388fcc8ea706480aff843e7
bpf: allow for key-less BTF in array map

Given we'll be reusing BPF array maps for global data/bss/rodata
sections, we need a way to associate BTF DataSec type as its map
value type. In usual cases we have this ugly BPF_ANNOTATE_KV_PAIR()
macro hack e.g. via a66f3fce8bc4 ("bpf: Introduce BPF_ANNOTATE_KV_PAIR")
to get initial map to type association going. While more use cases
for it are discouraged, this also won't work for global data since
the use of array map is a BPF loader detail and therefore unknown
at compilation time. For array maps with just a single entry we make
an exception in terms of BTF in that key type is declared optional
if value type is of DataSec type. The latter LLVM is guaranteed to
emit and it also aligns with how we regard global data maps as just
a plain buffer area reusing existing map facilities for allowing
things like introspection with existing tools.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/btf.h
kernel/bpf/arraymap.c
kernel/bpf/btf.c
kernel/bpf/syscall.c