<div dir="auto"></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">---------- Forwarded message ---------<br>From: <strong class="gmail_sendername" dir="auto">Yonghong Song</strong> <span dir="auto"><<a href="mailto:yhs@fb.com">yhs@fb.com</a>></span><br>Date: Wed, Jul 12, 2023, 11:07 PM<br>Subject: [PATCH bpf-next v2 00/15] bpf: Support new insns from cpu v4<br>To: <<a href="mailto:bpf@vger.kernel.org">bpf@vger.kernel.org</a>><br>Cc: Alexei Starovoitov <<a href="mailto:ast@kernel.org">ast@kernel.org</a>>, Andrii Nakryiko <<a href="mailto:andrii@kernel.org">andrii@kernel.org</a>>, Daniel Borkmann <<a href="mailto:daniel@iogearbox.net">daniel@iogearbox.net</a>>, Fangrui Song <<a href="mailto:maskray@google.com">maskray@google.com</a>>, <<a href="mailto:kernel-team@fb.com">kernel-team@fb.com</a>><br></div><br><br>In previous discussion ([1]), it is agreed that we should introduce<br>
cpu version 4 (llvm flag -mcpu=v4) which contains some instructions<br>
which can simplify code, make code easier to understand, fix the<br>
existing problem, or simply for feature completeness. More specifically,<br>
the following new insns are proposed:<br>
. sign extended load<br>
. sign extended mov<br>
. bswap<br>
. signed div/mod<br>
. ja with 32-bit offset<br>
<br>
This patch set added kernel support for insns proposed in [1] except<br>
BPF_ST which already has full kernel support. Beside the above proposed<br>
insns, LLVM will generate BPF_ST insn as well under -mcpu=v4 ([2]).<br>
<br>
The patchset implements interpreter and jit support for these new<br>
insns as well as necessary verifier support.<br>
<br>
To test this patch set, you need to have latest llvm from 'main' branch<br>
of llvm-project repo and apply [2] on top of it.<br>
<br>
[1] <a href="https://lore.kernel.org/bpf/4bfe98be-5333-1c7e-2f6d-42486c8ec039@meta.com/" rel="noreferrer noreferrer" target="_blank">https://lore.kernel.org/bpf/4bfe98be-5333-1c7e-2f6d-42486c8ec039@meta.com/</a><br>
[2] <a href="https://reviews.llvm.org/D144829" rel="noreferrer noreferrer" target="_blank">https://reviews.llvm.org/D144829</a><br>
<br>
Changelogs:<br>
RFCv1 -> v2:<br>
. add more verifier supports for signed extend load and mov insns.<br>
. rename some insn names to be more consistent with intel practice.<br>
. add cpuv4 test runner for test progs.<br>
. add more unit and C tests.<br>
. add documentation.<br>
<br>
Yonghong Song (15):<br>
bpf: Support new sign-extension load insns<br>
bpf: Fix sign-extension ctx member accesses<br>
bpf: Support new sign-extension mov insns<br>
bpf: Support new unconditional bswap instruction<br>
bpf: Support new signed div/mod instructions.<br>
bpf: Fix jit blinding with new sdiv/smov insns<br>
bpf: Support new 32bit offset jmp instruction<br>
selftests/bpf: Add a cpuv4 test runner for cpu=v4 testing<br>
selftests/bpf: Add unit tests for new sign-extension load insns<br>
selftests/bpf: Add unit tests for new sign-extension mov insns<br>
selftests/bpf: Add unit tests for new bswap insns<br>
selftests/bpf: Add unit tests for new sdiv/smod insns<br>
selftests/bpf: Add unit tests for new gotol insn<br>
selftests/bpf: Test ldsx with more complex cases<br>
docs/bpf: Add documentation for new instructions<br>
<br>
Documentation/bpf/bpf_design_QA.rst | 5 -<br>
.../bpf/standardization/instruction-set.rst | 100 ++-<br>
arch/x86/net/bpf_jit_comp.c | 131 ++-<br>
include/linux/filter.h | 14 +-<br>
include/uapi/linux/bpf.h | 1 +<br>
kernel/bpf/cgroup.c | 14 +-<br>
kernel/bpf/core.c | 174 +++-<br>
kernel/bpf/verifier.c | 315 ++++++--<br>
tools/include/uapi/linux/bpf.h | 1 +<br>
tools/testing/selftests/bpf/.gitignore | 2 +<br>
tools/testing/selftests/bpf/Makefile | 18 +-<br>
.../selftests/bpf/bpf_testmod/bpf_testmod.c | 9 +-<br>
.../selftests/bpf/prog_tests/test_ldsx_insn.c | 88 ++<br>
.../selftests/bpf/prog_tests/verifier.c | 10 +<br>
.../selftests/bpf/progs/test_ldsx_insn.c | 75 ++<br>
.../selftests/bpf/progs/verifier_bswap.c | 45 ++<br>
.../selftests/bpf/progs/verifier_gotol.c | 30 +<br>
.../selftests/bpf/progs/verifier_ldsx.c | 115 +++<br>
.../selftests/bpf/progs/verifier_movsx.c | 177 ++++<br>
.../selftests/bpf/progs/verifier_sdiv.c | 763 ++++++++++++++++++<br>
20 files changed, 1929 insertions(+), 158 deletions(-)<br>
create mode 100644 tools/testing/selftests/bpf/prog_tests/test_ldsx_insn.c<br>
create mode 100644 tools/testing/selftests/bpf/progs/test_ldsx_insn.c<br>
create mode 100644 tools/testing/selftests/bpf/progs/verifier_bswap.c<br>
create mode 100644 tools/testing/selftests/bpf/progs/verifier_gotol.c<br>
create mode 100644 tools/testing/selftests/bpf/progs/verifier_ldsx.c<br>
create mode 100644 tools/testing/selftests/bpf/progs/verifier_movsx.c<br>
create mode 100644 tools/testing/selftests/bpf/progs/verifier_sdiv.c<br>
<br>
-- <br>
2.34.1<br>
<br>
<br>
</div>