• Song Liu's avatar
    bpf: Use arch_bpf_trampoline_size · 26ef208c
    Song Liu authored
    
    
    Instead of blindly allocating PAGE_SIZE for each trampoline, check the size
    of the trampoline with arch_bpf_trampoline_size(). This size is saved in
    bpf_tramp_image->size, and used for modmem charge/uncharge. The fallback
    arch_alloc_bpf_trampoline() still allocates a whole page because we need to
    use set_memory_* to protect the memory.
    
    struct_ops trampoline still uses a whole page for multiple trampolines.
    
    With this size check at caller (regular trampoline and struct_ops
    trampoline), remove arch_bpf_trampoline_size() from
    arch_prepare_bpf_trampoline() in archs.
    
    Also, update bpf_image_ksym_add() to handle symbol of different sizes.
    Signed-off-by: default avatarSong Liu <song@kernel.org>
    Acked-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
    Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>  # on s390x
    Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
    Acked-by: default avatarBjörn Töpel <bjorn@rivosinc.com>
    Tested-by: Björn Töpel <bjorn@rivosinc.com> # on riscv
    Link: https://lore.kernel.org/r/20231206224054.492250...
    26ef208c
bpf_jit_comp64.c 48.6 KB