mbox series

[v3,bpf-next,0/4] libbpf: auto-resize relocatable LOAD/STORE instructions

Message ID 20201008001025.292064-1-andrii@kernel.org (mailing list archive)
Headers show
Series libbpf: auto-resize relocatable LOAD/STORE instructions | expand

Message

Andrii Nakryiko Oct. 8, 2020, 12:10 a.m. UTC
Patch set implements logic in libbpf to auto-adjust memory size (1-, 2-, 4-,
8-bytes) of load/store (LD/ST/STX) instructions which have BPF CO-RE field
offset relocation associated with it. In practice this means transparent
handling of 32-bit kernels, both pointer and unsigned integers. Signed
integers are not relocatable with zero-extending loads/stores, so libbpf
poisons them and generates a warning. If/when BPF gets support for
sign-extending loads/stores, it would be possible to automatically relocate
them as well.

All the details are contained in patch #2 comments and commit message.
Patch #3 is a simple change in libbpf to make advanced testing with custom BTF
easier. Patch #4 validates correct uses of auto-resizable loads, as well as
check that libbpf fails invalid uses. Patch #1 skips CO-RE relocation for
programs that had bpf_program__set_autoload(prog, false) set on them, reducing
warnings and noise.

v2->v3:
  - fix copyright (Alexei);
v1->v2:
  - more consistent names for instruction mem size convertion routines (Alexei);
  - extended selftests to use relocatable STX instructions (Alexei);
  - added a fix for skipping CO-RE relocation for non-loadable programs.

Cc: Luka Perkov <luka.perkov@sartura.hr>
Cc: Tony Ambardar <tony.ambardar@gmail.com>

Andrii Nakryiko (4):
  libbpf: skip CO-RE relocations for not loaded BPF programs
  libbpf: support safe subset of load/store instruction resizing with
    CO-RE
  libbpf: allow specifying both ELF and raw BTF for CO-RE BTF override
  selftests/bpf: validate libbpf's auto-sizing of LD/ST/STX instructions

 tools/lib/bpf/libbpf.c                        | 151 +++++++++++-
 .../selftests/bpf/prog_tests/core_autosize.c  | 225 ++++++++++++++++++
 .../selftests/bpf/progs/test_core_autosize.c  | 172 +++++++++++++
 3 files changed, 539 insertions(+), 9 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/core_autosize.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_core_autosize.c

Comments

patchwork-bot+netdevbpf@kernel.org Oct. 8, 2020, 2:10 a.m. UTC | #1
Hello:

This series was applied to bpf/bpf-next.git (refs/heads/master):

On Wed, 7 Oct 2020 17:10:20 -0700 you wrote:
> Patch set implements logic in libbpf to auto-adjust memory size (1-, 2-, 4-,
> 8-bytes) of load/store (LD/ST/STX) instructions which have BPF CO-RE field
> offset relocation associated with it. In practice this means transparent
> handling of 32-bit kernels, both pointer and unsigned integers. Signed
> integers are not relocatable with zero-extending loads/stores, so libbpf
> poisons them and generates a warning. If/when BPF gets support for
> sign-extending loads/stores, it would be possible to automatically relocate
> them as well.
> 
> [...]

Here is the summary with links:
  - [v3,bpf-next,1/4] libbpf: skip CO-RE relocations for not loaded BPF programs
    https://git.kernel.org/bpf/bpf-next/c/47f7cf6325f7
  - [v3,bpf-next,2/4] libbpf: support safe subset of load/store instruction resizing with CO-RE
    https://git.kernel.org/bpf/bpf-next/c/a66345bcbdf0
  - [v3,bpf-next,3/4] libbpf: allow specifying both ELF and raw BTF for CO-RE BTF override
    https://git.kernel.org/bpf/bpf-next/c/2b7d88c2b582
  - [v3,bpf-next,4/4] selftests/bpf: validate libbpf's auto-sizing of LD/ST/STX instructions
    https://git.kernel.org/bpf/bpf-next/c/888d83b961f6

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html