BPF List
 help / color / mirror / Atom feed
* [RFC PATCH bpf-next 0/5] static branches
@ 2024-01-22 16:49 Anton Protopopov
  2024-01-22 16:49 ` [RFC PATCH bpf-next 1/5] bpf: fix potential error return Anton Protopopov
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Anton Protopopov @ 2024-01-22 16:49 UTC (permalink / raw)
  To: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, Jiri Olsa,
	Martin KaFai Lau, Stanislav Fomichev, Yonghong Song,
	Eduard Zingerman, bpf
  Cc: Anton Protopopov

This series adds support for mapping between xlated and original
instructions offsets, mapping between xlated and jitted instructions
offsets (x86), support for two new BPF instruction JA[SRC=1] and
JA[SRC=3], and a new syscall to configure the jitted values of such
instructions.

This a follow up to the previous attempt to add static keys support
(see [1], [2]) which implements lower-level functionality than what
was proposed before.

It's RFC because 1) to run self-tests it requires a patched llvm
(https://github.com/llvm/llvm-project/pull/75110, thanks a lot
Yonghong!) 2) before spending time writing selftests and proper
bpftool updates [this time] I would prefer to get some initial
feedback first (for examples, see below)

The first patch is a formal fix.
The second patch adds xlated -> original mapping.
The third patch adds xlated -> jitted mapping.
The fourth patch adds support for new instructions.
And the fifth patch adds support for new syscall.

Altogether this provides enough functionality to dynamically patch
programs and support simple static keys. See the third patch which
displays an example of mappings between xlated->orig, xlated->jited.
See the last patch which includes description of how to implement
simple static key functionality.

This would be also interesting to hear what people think about more
high-level api where one "key" controls a set of static branches in
multiple programs and can serialize access to all the branches. What
kind of BPF object can represent such functionality, besides a map,
if any?

  [1] https://lpc.events/event/17/contributions/1608/attachments/1278/2578/bpf-static-keys.pdf
  [2] https://lore.kernel.org/bpf/20231206141030.1478753-1-aspsk@isovalent.com/

Anton Protopopov (5):
  bpf: fix potential error return
  bpf: keep track of and expose xlated insn offsets
  bpf: x86: expose how xlated insns map to jitted insns
  bpf: add support for an extended JA instruction
  bpf: x86: add BPF_STATIC_BRANCH_UPDATE syscall

 arch/x86/net/bpf_jit_comp.c       |  71 ++++++++++++++++++-
 include/linux/bpf.h               |  11 +++
 include/linux/bpf_verifier.h      |   1 -
 include/linux/filter.h            |   1 +
 include/uapi/linux/bpf.h          |  26 +++++++
 kernel/bpf/core.c                 |  69 +++++++++++++++++-
 kernel/bpf/syscall.c              | 112 ++++++++++++++++++++++++++++++
 kernel/bpf/verifier.c             |  58 ++++++++++++----
 tools/bpf/bpftool/prog.c          |  14 ++++
 tools/bpf/bpftool/xlated_dumper.c |   2 +-
 tools/bpf/bpftool/xlated_dumper.h |   2 +
 tools/include/uapi/linux/bpf.h    |  26 +++++++
 12 files changed, 375 insertions(+), 18 deletions(-)

-- 
2.34.1


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

end of thread, other threads:[~2024-01-30 12:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-22 16:49 [RFC PATCH bpf-next 0/5] static branches Anton Protopopov
2024-01-22 16:49 ` [RFC PATCH bpf-next 1/5] bpf: fix potential error return Anton Protopopov
2024-01-30 11:20   ` Jiri Olsa
2024-01-30 12:13     ` Anton Protopopov
2024-01-22 16:49 ` [RFC PATCH bpf-next 2/5] bpf: keep track of and expose xlated insn offsets Anton Protopopov
2024-01-22 16:49 ` [RFC PATCH bpf-next 3/5] bpf: x86: expose how xlated insns map to jitted insns Anton Protopopov
2024-01-22 16:49 ` [RFC PATCH bpf-next 4/5] bpf: add support for an extended JA instruction Anton Protopopov
2024-01-22 16:49 ` [RFC PATCH bpf-next 5/5] bpf: x86: add BPF_STATIC_BRANCH_UPDATE syscall Anton Protopopov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox