Skip to content

bpf, x86: Extend CPUv4 instruction support in the i386 JIT

Nicholas Dudar bpf lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5bpf, x86: Add support for BPF_MOVSX in the i386 JITarch/x86/net/bpf_jit_comp32.c+51 -01 reply
2/5bpf, x86: Extract the i386 JIT load emitterarch/x86/net/bpf_jit_comp32.c+84 -640 replies
3/5bpf, x86: Add BPF_MEMSX support to the i386 JITarch/x86/net/bpf_jit_comp32.c+44 -270 replies
4/5bpf, x86: Add BPF_JMP32 | BPF_JA support to the i386 JITarch/x86/net/bpf_jit_comp32.c+7 -20 replies
5/5bpf, x86: Add unconditional byte swap to the i386 JITarch/x86/net/bpf_jit_comp32.c+2 -00 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH bpf-next 0/5] bpf, x86: Extend CPUv4 instruction support in the i386 JIT

Add MOVSX, MEMSX, 32-bit-offset unconditional jumps and unconditional byte swaps to the i386 JIT. MOVSX currently produces ordinary moves; the other instructions are rejected by the backend.

The load-emitter extraction is separate from MEMSX so the code movement and signed-load handling can be reviewed independently. MOVSX comes first because context-access conversion can lower signed loads into ordinary loads followed by MOVSX.

The separately posted i386 SDIV/SMOD work is independent of this series:
https://lore.kernel.org/bpf/[email protected]/

Tested on QEMU i386 with CONFIG_BPF_JIT_ALWAYS_ON=y. The full test_bpf suite improves from 845/216 to 862/199 pass/fail: the 17 newly passing cases cover these instructions, with no other result changes. Additional verifier-loaded programs check full-width results and ordinary controls.

Of the remaining 199 failures, 8 are ALU32 SDIV/SMOD result mismatches. The other 191 fail during program creation or runtime selection: 149 atomic cases, 37 ALU64 division/modulo cases (including a mixed ALU test), 4 long conditional jumps and 1 jump/gap stress case.

All five intermediate JIT objects build. A standalone emission harness checks ordinary-load byte equivalence across the extraction and compares MOVSX staging with the earlier emitter, accounting for the removed self-moves. No physical hardware was tested.

Nicholas Dudar (5):
bpf, x86: Add support for BPF_MOVSX in the i386 JIT bpf, x86: Extract the i386 JIT load emitter bpf, x86: Add BPF_MEMSX support to the i386 JIT bpf, x86: Add BPF_JMP32 | BPF_JA support to the i386 JIT bpf, x86: Add unconditional byte swap to the i386 JIT

 arch/x86/net/bpf_jit_comp32.c | 227 ++++++++++++++++++++++++----------
 1 file changed, 161 insertions(+), 66 deletions(-)

base-commit: 29fcf9ce4bbdf4cc339def776860e1c0095bca98