[RFC PATCH bpf-next 00/13] bpf: Support new insns from cpu v4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In previous discussion ([1]), it is agreed that we should introduce
cpu version 4 (llvm flag -mcpu=v4) which contains some instructions
which can simplify code, make code easier to understand, fix the
existing problem, or simply for feature completeness. More specifically,
the following new insns are proposed:
  . sign extended load
  . sign extended mov
  . bswap
  . signed div/mod
  . ja with 32-bit offset

This patch set added kernel support for insns proposed in [1] except
BPF_ST which already has full kernel support. Beside the above proposed
insns, LLVM will generate BPF_ST insn as well under -mcpu=v4 ([2]).

The patchset implements interpreter and jit support for these new
insns. It has minimum verifier support in order to pass bpf selftests.
More work will be required to cover verification and other aspects
(e.g. blinding, etc.).

I send the patch set earlier and want to get some early feedbacks
before I dig into verifier details. Patch 3 (sign-extension mov
insns) prompts me to think whether we should have unsign-extension
mov insns as well (see Patch 3 commit message for details).
The last patch contains some statistics of how many new insns are
actually generated in selftests.  Please see each individual patch
for details.

  [1] https://lore.kernel.org/bpf/4bfe98be-5333-1c7e-2f6d-42486c8ec039@xxxxxxxx/
  [2] https://reviews.llvm.org/D144829

Yonghong Song (13):
  bpf: Support new sign-extension load insns
  bpf: Add verifier support for sign-extension load insns
  bpf: Support new sign-extension mov insns
  bpf: Support new unconditional bswap instruction
  bpf: Support new signed div/mod instructions.
  bpf: Support new 32bit offset jmp instruction
  bpf: Add kernel/bpftool asm support for new instructions
  selftests/bpf: Add unit tests for new sign-extension load insns
  selftests/bpf: Add unit tests for new sign-extension mov insns
  selftests/bpf: Add unit tests for new bswap insns
  selftests/bpf: Add unit tests for new sdiv/smod insns
  selftests/bpf: Add unit tests for new gotol insn
  selftests/bpf: Add a cpuv4 test runner for cpu=v4 testing

 arch/x86/net/bpf_jit_comp.c                   | 130 ++-
 include/uapi/linux/bpf.h                      |   1 +
 kernel/bpf/core.c                             | 170 +++-
 kernel/bpf/disasm.c                           |  57 +-
 kernel/bpf/verifier.c                         | 100 ++-
 tools/include/uapi/linux/bpf.h                |   1 +
 tools/testing/selftests/bpf/Makefile          |  18 +-
 .../selftests/bpf/prog_tests/verifier.c       |  10 +
 .../selftests/bpf/progs/verifier_bswap.c      |  45 ++
 .../selftests/bpf/progs/verifier_gotol.c      |  30 +
 .../selftests/bpf/progs/verifier_lds.c        |  46 ++
 .../selftests/bpf/progs/verifier_movs.c       |  67 ++
 .../selftests/bpf/progs/verifier_sdiv.c       | 763 ++++++++++++++++++
 13 files changed, 1357 insertions(+), 81 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/verifier_bswap.c
 create mode 100644 tools/testing/selftests/bpf/progs/verifier_gotol.c
 create mode 100644 tools/testing/selftests/bpf/progs/verifier_lds.c
 create mode 100644 tools/testing/selftests/bpf/progs/verifier_movs.c
 create mode 100644 tools/testing/selftests/bpf/progs/verifier_sdiv.c

-- 
2.34.1






[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux