]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
bpf: Introduce bpf_jit_binary_pack_[alloc|finalize|free]
authorSong Liu <songliubraving@fb.com>
Fri, 4 Feb 2022 18:57:41 +0000 (10:57 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 8 Feb 2022 02:13:01 +0000 (18:13 -0800)
commit33c9805860e584b194199cab1a1e81f4e6395408
tree935536b12d08e7b5c1a1ad132e5b141e72492652
parent57631054fae6dcc9c892ae6310b58bbb6f6e5048
bpf: Introduce bpf_jit_binary_pack_[alloc|finalize|free]

This is the jit binary allocator built on top of bpf_prog_pack.

bpf_prog_pack allocates RO memory, which cannot be used directly by the
JIT engine. Therefore, a temporary rw buffer is allocated for the JIT
engine. Once JIT is done, bpf_jit_binary_pack_finalize is used to copy
the program to the RO memory.

bpf_jit_binary_pack_alloc reserves 16 bytes of extra space for illegal
instructions, which is small than the 128 bytes space reserved by
bpf_jit_binary_alloc. This change is necessary for bpf_jit_binary_hdr
to find the correct header. Also, flag use_bpf_prog_pack is added to
differentiate a program allocated by bpf_jit_binary_pack_alloc.

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220204185742.271030-9-song@kernel.org
include/linux/bpf.h
include/linux/filter.h
kernel/bpf/core.c