[PATCH bpf-next v4 0/3] bpf, mips: Add signed div/mod support
From: Nicholas Dudar
Date: Fri Sep 11 2026 - 17:33:59 EST
The MIPS JITs do not interpret the insn->off value that selects signed
DIV/MOD semantics, so negative operands produce unsigned results.
Factor div/mod emission into helpers, add the missing signed uasm
operations, and decode insn->off in the div/mod emitters. On MIPS32,
use signed 64-bit helpers for ALU64 operations.
The DIV/MOD implementation is unchanged from v3.
Before this rebase, all signed DIV/MOD test_bpf cases passed with the
pending MOVSX respin applied under QEMU Malta on little-endian MIPS32
R1/R2/R6 and MIPS64 R2/R6. The full suite had 12 expected failures for
unsupported operations (8 BSWAP, 3 MEMSX and 1 JMP32_JA).
R1 had 18 failures in total: those 12 plus
6 additional failures reproduced on unchanged v3 in the same environment.
Earlier v3 testing covered big-endian MIPS32.
Uasm object builds passed for MIPS32 R1/R6, MIPS64 R2/R6 and
microMIPS32 R2 before the rebase. The new SEB/SEH encodings match GNU as
for every register pair on MIPS32/64 R2/R3/R5/R6 in both endian modes;
all pre-existing native opcode entries are unchanged. No physical
hardware was tested.
Changes in v4:
- Add seb/seh uasm emitters for R2-or-newer CPUs.
- Rebase onto current bpf-next without changing the implementation.
v3: https://lore.kernel.org/bpf/20260810194215.3754591-1-main.kalliope@xxxxxxxxx/
MOVSX review: https://lore.kernel.org/bpf/CAM1=_QTN3JJ6jtckf32F8wxBzLDbHSrzUttyMBWNqZKmRe=2rg@xxxxxxxxxxxxxx/
Nicholas Dudar (3):
bpf, mips: Factor out div/mod emission helpers
MIPS: uasm: Add signed div/mod and sign-extension emitters
bpf, mips: Add support for BPF_SDIV and BPF_SMOD
arch/mips/include/asm/uasm.h | 8 ++++
arch/mips/mm/uasm-mips.c | 12 ++++++
arch/mips/mm/uasm.c | 24 ++++++++----
arch/mips/net/bpf_jit_comp.c | 55 +++++++++++++++++++-------
arch/mips/net/bpf_jit_comp.h | 4 +-
arch/mips/net/bpf_jit_comp32.c | 29 +++++++++-----
arch/mips/net/bpf_jit_comp64.c | 71 +++++++++++++++++++++++-----------
7 files changed, 147 insertions(+), 56 deletions(-)
base-commit: c1ff425d625eb2a4d2967e9889b85f202f24eb5d