While implementing JIT for packet capture ran into several issues:
1. x86 JIT had a pre-existing bug which would crash.
2. The arm64 JIT was missing the packet-access instructions, found
previously [1].
3. Shift counts were not masked to the operand width as RFC 9669
requires: undefined behavior in the interpreter and an encoding
failure in the arm64 JIT.
4. Tests related to JIT were not being run or were missing coverage.
Fixed all of these. Patches are ordered with the most urgent fix (the
x86 crash) first, each fix followed by the test that exercises it. The
arm64 packet-load support is kept ahead of the "check JIT was generated"
patch so the series bisects cleanly on arm64.
The arm64 epilogue branch fix (patch 6) was originally posted by
Christophe Fontaine [1]; that series stalled, so it is carried here with
his authorship.
Changes since v4:
- address Marat's review of the large-shift test: it now checks the
RFC 9669 masked result instead of a sentinel, which surfaced two more
bugs fixed in this version
- mask shift counts to the operand width: the interpreter shifted by
the raw count (UB, trips UBSan; patch 3) and the arm64 JIT overflowed
the UBFM/SBFM immediate (patch 4)
- reorder so the arm64 BPF_ABS/BPF_IND support precedes the "check JIT
was generated" patch, keeping the suite bisectable on arm64
[1] https://inbox.dpdk.org/dev/[email protected]/
Christophe Fontaine (1):
bpf/arm64: fix offset type to allow a negative jump
Stephen Hemminger (8):
bpf/x86: fix JIT encoding of fixed-width immediates
test/bpf: add JSET test with small immediate
bpf: mask shift count in interpreter per RFC 9669
bpf/arm64: mask shift count per RFC 9669
test/bpf: add test for large shift
bpf/arm64: add BPF_ABS/BPF_IND packet load support
test/bpf: check that JIT was generated
test/bpf: check that bpf_convert can be JIT'd
app/test/test_bpf.c | 320 +++++++++++++++++++++++++++++++---------
lib/bpf/bpf_exec.c | 31 ++--
lib/bpf/bpf_jit_arm64.c | 165 ++++++++++++++++++++-
lib/bpf/bpf_jit_x86.c | 6 +-
lib/bpf/meson.build | 2 +
5 files changed, 436 insertions(+), 88 deletions(-)
--
2.53.0