From: Nicholas Dudar <main.kalliope@gmail.com>
To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
eddyz87@gmail.com, memxor@gmail.com, tsbogend@alpha.franken.de,
johan.almbladh@anyfinetworks.com, paulburton@kernel.org
Cc: martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev,
jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev,
philmd@oss.qualcomm.com, visitorckw@gmail.com,
bpf@vger.kernel.org, linux-mips@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH bpf-next v2 0/2] bpf, mips: Add signed div/mod support
Date: Wed, 29 Jul 2026 12:29:29 -0400 [thread overview]
Message-ID: <20260729162931.2369353-1-main.kalliope@gmail.com> (raw)
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/20260716211055.2569433-1-main.kalliope@gmail.com/
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
next reply other threads:[~2026-07-29 16:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 16:29 Nicholas Dudar [this message]
2026-07-29 16:29 ` [PATCH bpf-next v2 1/2] bpf, mips: Factor out div/mod emission helpers Nicholas Dudar
2026-07-29 17:10 ` bot+bpf-ci
2026-07-29 18:54 ` Nicholas Dudar
2026-07-30 8:11 ` Philippe Mathieu-Daudé
2026-07-29 16:29 ` [PATCH bpf-next v2 2/2] bpf, mips: Add support for BPF_SDIV and BPF_SMOD Nicholas Dudar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260729162931.2369353-1-main.kalliope@gmail.com \
--to=main.kalliope@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=johan.almbladh@anyfinetworks.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=paulburton@kernel.org \
--cc=philmd@oss.qualcomm.com \
--cc=song@kernel.org \
--cc=tsbogend@alpha.franken.de \
--cc=visitorckw@gmail.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox