bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC bpf-next 00/10] bpf: CO-RE support in the kernel.
@ 2021-09-17 21:57 Alexei Starovoitov
  2021-09-17 21:57 ` [PATCH RFC bpf-next 01/10] bpf: Prepare relo_core.c for kernel duty Alexei Starovoitov
                   ` (10 more replies)
  0 siblings, 11 replies; 34+ messages in thread
From: Alexei Starovoitov @ 2021-09-17 21:57 UTC (permalink / raw)
  To: davem; +Cc: daniel, andrii, john.fastabend, lmb, mcroce, bpf, kernel-team

From: Alexei Starovoitov <ast@kernel.org>

Hi All,

This is very early RFC that introduces CO-RE support in the kernel.
There are several reasons to add such support:
1. It's a step toward signed BPF programs.
2. It allows golang like languages that struggle to adopt libbpf
   to take advantage of CO-RE powers.
3. Currently the field accessed by 'ldx [R1 + 10]' insn is recognized
   by the verifier purely based on +10 offset. If R1 points to a union
   the verifier picks one of the fields at this offset.
   With CO-RE the kernel can disambiguate the field access.

This set wires all relevant pieces and passes two selftests with CO-RE
in the kernel.

The main goal of RFC is to get feedback on patch 3.
It's passing CO-RE relocation into the kernel via bpf_core_apply_relo()
helper that is called by the loader program.
It works, but there is no clean way to add error reporting here.
So I'm thinking that the better approach would be to pass an array
of 'struct bpf_core_relo_desc' into PROG_LOAD command similar to
how func_info and line_info are passed.
Such approach would allow for the use case 3 above (which
current approach in patch 3 doesn't support).

Major TODOs:
- rename kernel btf_*() helpers to match libbpf btf_*() helpers
  to avoid equivalent helpers in patch 1.
- bpf_core_match_member() in relo_core.c is recursive.
  Limit its recursion or refactor.
- implemented bpf_core_types_are_compat(). duh.
- decide whether bpf_core_find_cands() needs hash table (like libbpf does)
  or not.

Alexei Starovoitov (10):
  bpf: Prepare relo_core.c for kernel duty.
  bpf: Define enum bpf_core_relo_kind as uapi.
  bpf: Add proto of bpf_core_apply_relo()
  bpf: Add bpf_core_add_cands() and wire it into
    bpf_core_apply_relo_insn().
  libbpf: Use CO-RE in the kernel in light skeleton.
  libbpf: Make gen_loader data aligned.
  libbpf: Support init of inner maps in light skeleton.
  selftests/bpf: Convert kfunc test with CO-RE to lskel.
  selftests/bpf: Improve inner_map test coverage.
  selftests/bpf: Convert map_ptr_kern test to use light skeleton.

 include/linux/bpf.h                           |   1 +
 include/linux/btf.h                           |  89 ++++++++
 include/uapi/linux/bpf.h                      |  33 +++
 kernel/bpf/Makefile                           |   4 +
 kernel/bpf/btf.c                              | 193 ++++++++++++++++++
 kernel/bpf/syscall.c                          |   2 +
 tools/include/uapi/linux/bpf.h                |  33 +++
 tools/lib/bpf/bpf_gen_internal.h              |  13 ++
 tools/lib/bpf/gen_loader.c                    |  85 +++++++-
 tools/lib/bpf/libbpf.c                        |  35 +++-
 tools/lib/bpf/relo_core.c                     | 156 ++++++++++----
 tools/lib/bpf/relo_core.h                     |  18 --
 tools/testing/selftests/bpf/Makefile          |   2 +-
 .../selftests/bpf/prog_tests/kfunc_call.c     |   4 +-
 .../selftests/bpf/prog_tests/map_ptr.c        |   8 +-
 .../selftests/bpf/progs/map_ptr_kern.c        |  16 +-
 16 files changed, 611 insertions(+), 81 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2021-10-22  0:51 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-17 21:57 [PATCH RFC bpf-next 00/10] bpf: CO-RE support in the kernel Alexei Starovoitov
2021-09-17 21:57 ` [PATCH RFC bpf-next 01/10] bpf: Prepare relo_core.c for kernel duty Alexei Starovoitov
2021-09-21 21:25   ` Andrii Nakryiko
2021-09-28 14:45   ` Matteo Croce
2021-09-28 16:37     ` Alexei Starovoitov
2021-09-28 17:11       ` Matteo Croce
2021-09-28 20:34         ` Alexei Starovoitov
2021-09-29 12:32           ` Matteo Croce
2021-09-29 17:38             ` Matteo Croce
2021-09-29 23:00               ` Alexei Starovoitov
2021-09-29 23:49                 ` Matteo Croce
2021-10-22  0:48                   ` Matteo Croce
2021-10-22  0:51                     ` Alexei Starovoitov
2021-09-17 21:57 ` [PATCH RFC bpf-next 02/10] bpf: Define enum bpf_core_relo_kind as uapi Alexei Starovoitov
2021-09-21 21:27   ` Andrii Nakryiko
2021-09-17 21:57 ` [PATCH RFC bpf-next 03/10] bpf: Add proto of bpf_core_apply_relo() Alexei Starovoitov
2021-09-23 11:21   ` Lorenz Bauer
2021-09-23 18:48     ` Andrii Nakryiko
2021-09-17 21:57 ` [PATCH RFC bpf-next 04/10] bpf: Add bpf_core_add_cands() and wire it into bpf_core_apply_relo_insn() Alexei Starovoitov
2021-09-21 21:34   ` Andrii Nakryiko
2021-09-27 18:04   ` Matteo Croce
2021-09-17 21:57 ` [PATCH RFC bpf-next 05/10] libbpf: Use CO-RE in the kernel in light skeleton Alexei Starovoitov
2021-09-17 21:57 ` [PATCH RFC bpf-next 06/10] libbpf: Make gen_loader data aligned Alexei Starovoitov
2021-09-17 21:57 ` [PATCH RFC bpf-next 07/10] libbpf: Support init of inner maps in light skeleton Alexei Starovoitov
2021-09-17 21:57 ` [PATCH RFC bpf-next 08/10] selftests/bpf: Convert kfunc test with CO-RE to lskel Alexei Starovoitov
2021-09-17 21:57 ` [PATCH RFC bpf-next 09/10] selftests/bpf: Improve inner_map test coverage Alexei Starovoitov
2021-09-17 21:57 ` [PATCH RFC bpf-next 10/10] selftests/bpf: Convert map_ptr_kern test to use light skeleton Alexei Starovoitov
2021-09-23 11:33 ` [PATCH RFC bpf-next 00/10] bpf: CO-RE support in the kernel Lorenz Bauer
2021-09-23 18:52   ` Andrii Nakryiko
2021-09-24 23:13   ` Alexei Starovoitov
2021-09-27 16:12     ` Lorenz Bauer
2021-09-27 16:50       ` Alexei Starovoitov
2021-09-28  8:30         ` Lorenz Bauer
2021-09-28 16:35           ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).