diff options
author | Daniel Borkmann <daniel@iogearbox.net> | 2020-09-30 18:18:18 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-09-30 21:50:35 +0300 |
commit | 0e9f6841f664f801a69d27f765dc70b8a93e1959 (patch) | |
tree | 59bbc2e77e6832566e76243fca5805868126eea4 /samples | |
parent | b4ab31414970a7a03a5d55d75083f2c101a30592 (diff) | |
download | linux-0e9f6841f664f801a69d27f765dc70b8a93e1959.tar.xz |
bpf, libbpf: Add bpf_tail_call_static helper for bpf programs
Port of tail_call_static() helper function from Cilium's BPF code base [0]
to libbpf, so others can easily consume it as well. We've been using this
in production code for some time now. The main idea is that we guarantee
that the kernel's BPF infrastructure and JIT (here: x86_64) can patch the
JITed BPF insns with direct jumps instead of having to fall back to using
expensive retpolines. By using inline asm, we guarantee that the compiler
won't merge the call from different paths with potentially different
content of r2/r3.
We're also using Cilium's __throw_build_bug() macro (here as: __bpf_unreachable())
in different places as a neat trick to trigger compilation errors when
compiler does not remove code at compilation time. This works for the BPF
back end as it does not implement the __builtin_trap().
[0] https://github.com/cilium/cilium/commit/f5537c26020d5297b70936c6b7d03a1e412a1035
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/1656a082e077552eb46642d513b4a6bde9a7dd01.1601477936.git.daniel@iogearbox.net
Diffstat (limited to 'samples')
0 files changed, 0 insertions, 0 deletions