mbox series

[bpf-next,0/3] Add user-space and non-CO-RE variants of BPF_CORE_READ()

Message ID 20201218235614.2284956-1-andrii@kernel.org
Headers show
Series Add user-space and non-CO-RE variants of BPF_CORE_READ() | expand

Message

Andrii Nakryiko Dec. 18, 2020, 11:56 p.m. UTC
Add two sets of BPF_CORE_READ()-like macros. One is for reading kernel data
from user address space (e.g., UAPI data structs for syscalls). Another one is
non-CO-RE variants, which don't emit CO-RE relocations and thus won't fail on
kernels without BTF. The latter one still provides much shorter way to write
reads that needs to chase few pointers.

Andrii Nakryiko (3):
  libbpf: add user-space variants of BPF_CORE_READ() family of macros
  libbpf: add non-CO-RE variants of BPF_CORE_READ() macro family
  selftests/bpf: add tests for user- and non-CO-RE BPF_CORE_READ()
    variants

 tools/lib/bpf/bpf_core_read.h                 | 136 +++++++++++++-----
 .../bpf/prog_tests/core_read_macros.c         |  64 +++++++++
 .../bpf/progs/test_core_read_macros.c         |  51 +++++++
 3 files changed, 212 insertions(+), 39 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/core_read_macros.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_core_read_macros.c