Re: [PATCH bpf-next 4/8] bpf: Add helpers for trampoline image management

Song Liu
2023-09-20T16:31:30Z

> On Sep 19, 2023, at 10:31 PM, Song Liu <song@kernel.org> wrote:
>
> As BPF trampoline of different archs moves from bpf_jit_[alloc|free]_exec()
> to bpf_prog_pack_[alloc|free](), we need to use different _alloc, _free for
> different archs during the transition. Add the following helpers for this
> transition:
>
> void *arch_alloc_bpf_trampoline(int size);
> void arch_free_bpf_trampoline(void *image, int size);
> void arch_protect_bpf_trampoline(void *image, int size);
> void arch_unprotect_bpf_trampoline(void *image, int size);
>
> The fallback version of these helpers require size <= PAGE_SIZE, but they
> are only called with size == PAGE_SIZE. They will be called with size <
> PAGE_SIZE when arch_bpf_trampoline_size() helper is introduced later.
>
> Signed-off-by: Song Liu <song@kernel.org>
> ---
> include/linux/bpf.h | 5 +++++
> kernel/bpf/bpf_struct_ops.c | 12 +++++-----

I just found that we need similar changes in net/bpf/bpf_dummy_struct_ops.c.

Added it to the next version.

Song