libbpf: Add support for relocatable bitfields
authorAndrii Nakryiko <andriin@fb.com>
Fri, 1 Nov 2019 22:28:07 +0000 (15:28 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 4 Nov 2019 15:06:56 +0000 (16:06 +0100)
commitee26dade0e3bcd8a34ae7520e373fb69365fce7a
treef6dc7431bd618323bae052600920051748703fd8
parent42765ede5c54ca915de5bfeab83be97207e46f68
libbpf: Add support for relocatable bitfields

Add support for the new field relocation kinds, necessary to support
relocatable bitfield reads. Provide macro for abstracting necessary code doing
full relocatable bitfield extraction into u64 value. Two separate macros are
provided:
- BPF_CORE_READ_BITFIELD macro for direct memory read-enabled BPF programs
(e.g., typed raw tracepoints). It uses direct memory dereference to extract
bitfield backing integer value.
- BPF_CORE_READ_BITFIELD_PROBED macro for cases where bpf_probe_read() needs
to be used to extract same backing integer value.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20191101222810.1246166-3-andriin@fb.com
tools/lib/bpf/bpf_core_read.h
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf_internal.h