Skip to content

Allocate bpf trampoline on bpf_prog_pack

Song Liu bpf 7 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest7 patches 0 repliesApplied 7/7
  2. v67 patches 3 repliesSuperseded
  3. v57 patches 3 repliesSuperseded
Earlier versions · 4
VersionPostedPatchesRepliesStatus
v47 patches7 repliesSuperseded
v38 patches4 repliesSuperseded 1 of 8 applied
v28 patches2 repliesSuperseded
v18 patches8 repliesSuperseded

Changes in v7 from the cover letter

1. Use kvmalloc for rw_image in x86/arch_prepare_bpf_trampoline. (Alexei)
2. Add comment to explain why we cannot use kvmalloc in x86/arch_bpf_trampoline_size. (Alexei)

Patches in v7 All 7 applied

#Subject and filesSizeRepliesApplied
1/7bpf: Let bpf_prog_pack_free handle any pointerinclude/linux/filter.h kernel/bpf/core.c kernel/bpf/dispatcher.c+12 -160 repliesApplied
2/7bpf: Adjust argument names of arch_prepare_bpf_trampoline()arch/arm64/net/bpf_jit_comp.c include/linux/bpf.h kernel/bpf/trampoline.c+9 -90 repliesApplied
3/7bpf: Add helpers for trampoline image managementinclude/linux/bpf.h kernel/bpf/bpf_struct_ops.c kernel/bpf/trampoline.c +1 more+52 -180 repliesApplied
4/7bpf, x86: Adjust arch_prepare_bpf_trampoline return valuearch/x86/net/bpf_jit_comp.c+1 -10 repliesApplied
5/7bpf: Add arch_bpf_trampoline_size()arch/arm64/net/bpf_jit_comp.c arch/riscv/net/bpf_jit_comp64.c arch/s390/net/bpf_jit_comp.c +3 more+136 -460 repliesApplied
6/7bpf: Use arch_bpf_trampoline_sizearch/arm64/net/bpf_jit_comp.c arch/riscv/net/bpf_jit_comp64.c include/linux/bpf.h +3 more+44 -370 repliesApplied
7/7x86, bpf: Use bpf_prog_pack for bpf trampolinearch/x86/net/bpf_jit_comp.c+72 -260 repliesApplied

Reviews trailers per patch

All 7 patches have a Reviewed-by or Acked-by.

PatchIlya LeoshkevichBjörn TöpelJiri Olsa
1/7A-b T-b R-b A-b
2/7A-b T-b A-b
3/7A-b T-b A-b
4/7A-b A-b
5/7A-b T-b A-b T-b A-b
6/7A-b T-b A-b T-b A-b
7/7A-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v7 thread

Cover letter [PATCH v7 bpf-next 0/7] Allocate bpf trampoline on bpf_prog_pack

This set enables allocating bpf trampoline from bpf_prog_pack on x86. The majority of this work, however, is the refactoring of trampoline code. This is needed because we need to handle 4 archs and 2 users (trampoline and struct_ops).

1/7 through 6/7 refactors trampoline code. A few helpers are added. 7/7 finally let bpf trampoline on x86 use bpf_prog_pack.

Changes in v7:
1. Use kvmalloc for rw_image in x86/arch_prepare_bpf_trampoline. (Alexei)
2. Add comment to explain why we cannot use kvmalloc in x86/arch_bpf_trampoline_size. (Alexei)

Changes in v6:
1. Rebase.
2. Add Acked-by and Tested-by from Jiri Olsa and Björn Töpel.

Changes in v5:
1. Adjust size of trampoline ksym. (Jiri)
2. Use "unsigned int size" arg in image management helpers.(Daniel)

Changes in v4:
1. Dropped 1/8 in v3, which is already merged in bpf-next.
2. Add Reviewed-by from Björn Töpel.

Changes in v3:
1. Fix bug in s390. (Thanks to Ilya Leoshkevich).
2. Fix build error in riscv. (kernel test robot).

Changes in v2:
1. Add missing changes in net/bpf/bpf_dummy_struct_ops.c.
2. Reduce one dry run in arch_prepare_bpf_trampoline. (Xu Kuohai)
3. Other small fixes.

Song Liu (7):
bpf: Let bpf_prog_pack_free handle any pointer
bpf: Adjust argument names of arch_prepare_bpf_trampoline()
bpf: Add helpers for trampoline image management bpf, x86: Adjust arch_prepare_bpf_trampoline return value
bpf: Add arch_bpf_trampoline_size()
bpf: Use arch_bpf_trampoline_size
x86, bpf: Use bpf_prog_pack for bpf trampoline

 arch/arm64/net/bpf_jit_comp.c   |  55 +++++++++-----
 arch/riscv/net/bpf_jit_comp64.c |  25 +++---
 arch/s390/net/bpf_jit_comp.c    |  56 ++++++++------
 arch/x86/net/bpf_jit_comp.c     | 130 +++++++++++++++++++++++++-------
 include/linux/bpf.h             |  14 +++-
 include/linux/filter.h          |   2 +-
 kernel/bpf/bpf_struct_ops.c     |  19 +++--
 kernel/bpf/core.c               |  21 +++---
 kernel/bpf/dispatcher.c         |   7 +-
 kernel/bpf/trampoline.c         | 101 +++++++++++++++++++------
 net/bpf/bpf_dummy_struct_ops.c  |   7 +-
 11 files changed, 305 insertions(+), 132 deletions(-)

--
2.34.1