Skip to content

RFC bpf, mips: Add BPF_MOVSX support to the JITs

Nicholas Dudar bpf linux-mips lkml sashiko-reviews 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpf, mips: Factor register moves into helpersarch/mips/net/bpf_jit_comp32.c arch/mips/net/bpf_jit_comp64.c+33 -71 reply
2/2bpf, mips: Add support for BPF_MOVSX in the JITsarch/mips/net/bpf_jit_comp32.c arch/mips/net/bpf_jit_comp64.c+79 -172 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC bpf-next 0/2] bpf, mips: Add BPF_MOVSX support to the JITs

bpf-next is closed for the merge window, so I am sending this for review. I plan to post this series after it reopens.

The MIPS32 and MIPS64 JITs lower register BPF_MOVSX as an ordinary move because their register-move paths do not interpret insn->off. Negative low-width values therefore retain incorrect upper bits.

First factor ordinary register moves into backend-local 32- and 64-bit helpers. Then handle the BPF-defined MOVSX widths from insn->off in those helpers. This keeps the verifier-inserted ALU32 zero extension on its existing path and preserves the MIPS32 register-pair handling. The implementation uses shift sequences rather than the R2+ seb/seh instructions so it also works on base MIPS32.

MOVSX can be applied before or after the in-flight SDIV/SMOD series. Both must precede MEMSX (yet to be sent). The ordering discussion is here:

Patch 1 did not change any test_bpf result. On the four little-endian profiles where the complete suite was run at each boundary, patch 2 fixed the ALU32 byte and halfword MOVSX cases and the ALU64 byte, halfword, and word cases. The 32-bit totals moved from 1031 passes and 31 failures to 1036 passes and 26 failures; the 64-bit totals moved from 1030 passes and 31 failures to 1035 passes and 26 failures. Patch 2 did not change any other test result. Ordinary MOV and zero-extension controls passed at each boundary.

Selector-focused QEMU testing covered MIPS32 base, R2, and R6 plus pre-R6 MIPS64, each in big- and little-endian configurations. No physical MIPS hardware was tested.

Nicholas Dudar (2):
bpf, mips: Factor register moves into helpers bpf, mips: Add support for BPF_MOVSX in the JITs

 arch/mips/net/bpf_jit_comp32.c | 54 +++++++++++++++++++++++++++++++---
 arch/mips/net/bpf_jit_comp64.c | 48 ++++++++++++++++++++++++++++--
 2 files changed, 95 insertions(+), 7 deletions(-)

base-commit: 6655c409707ec8ce9ce0850ffe4fe02331fd4d9c