[PATCH bpf-next v2 0/2] bpf, mips: Add signed div/mod support
Nicholas Dudar <[email protected]> Wed, 29 Jul 2026 12:29:29 -0400
| Newsgroups | org.kernel.vger.linux-mips,org.kernel.vger.bpf,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
The MIPS JITs select division and modulo implementations from the BPF class and opcode, but do not inspect insn->off. BPF_SDIV and BPF_SMOD therefore use unsigned instructions, or unsigned C helpers for ALU64 on 32-bit MIPS. Patch 1 factors division and modulo emission into helpers. Patch 2 uses insn->off to select the signed instructions and helpers. Tested with test_bpf under QEMU on MIPS32r2, MIPS64r2, MIPS32r6, and MIPS64r6, with CONFIG_BPF_JIT_ALWAYS_ON=y. Patch 1 produced the base failure set on each target. With both patches, all 16 SDIV/SMOD cases passed. Fourteen failed on the base; two already passed. No test changed from PASS to FAIL. v2: - split out the div/mod helpers as Philippe suggested - use an unsigned quotient intermediate in the signed remainder helper - rebase onto bpf-next at fdec474c65fd - test the base, patch 1, and the full series on four MIPS targets v1: https://lore.kernel.org/bpf/[email protected]/ Nicholas Dudar (2): bpf, mips: Factor out div/mod emission helpers bpf, mips: Add support for BPF_SDIV and BPF_SMOD arch/mips/include/asm/uasm.h | 6 +++ arch/mips/mm/uasm-mips.c | 10 +++++ arch/mips/mm/uasm.c | 20 ++++++--- arch/mips/net/bpf_jit_comp.c | 53 +++++++++++++++++------- arch/mips/net/bpf_jit_comp.h | 5 ++- arch/mips/net/bpf_jit_comp32.c | 30 +++++++++----- arch/mips/net/bpf_jit_comp64.c | 74 +++++++++++++++++++++++----------- 7 files changed, 143 insertions(+), 55 deletions(-) base-commit: fdec474c65fd35d5a6e1497ed50a9f98c07192f0 -- 2.34.1