BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v3 0/3] bpf, mips: Add signed div/mod support
@ 2026-08-10 19:42 Nicholas Dudar
  2026-08-10 19:42 ` [PATCH bpf-next v3 1/3] bpf, mips: Factor out div/mod emission helpers Nicholas Dudar
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Nicholas Dudar @ 2026-08-10 19:42 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, memxor, tsbogend, johan.almbladh,
	paulburton
  Cc: martin.lau, song, yonghong.song, jolsa, emil, ihor.solodrai,
	philmd, bpf, linux-mips, linux-kernel

The MIPS JITs select division and modulo implementations from the BPF
class and opcode, but did not interpret the opcode-specific insn->off
value that selects signed DIV/MOD semantics. Negative operands therefore
produced unsigned results.

Factor div/mod emission into helpers, add the missing signed uasm
operations, and interpret the raw offset only in div/mod-specific paths.
On 32-bit MIPS, use signed 64-bit helpers for ALU64 operations.

The base, each intermediate patch boundary, and the full series were built
and run under QEMU with CONFIG_BPF_JIT_ALWAYS_ON=y on MIPS32r2, MIPS32r6,
MIPS64r2, and MIPS64r6. Fourteen of sixteen signed DIV/MOD cases failed on
the base and after the two preparatory patches; all sixteen passed and
remained JITed with the full series. A big-endian MIPS32 base/full
comparison produced the same result. Because patch 2 extends the shared
uasm interface, that intermediate revision was also built with a microMIPS
configuration.

v3:
- split the generic uasm additions into a separate provider patch
- propagate raw insn->off and decode it only in div/mod-specific paths
- keep the signed remainder quotient in s64
- add the requested short comments to the div/mod emitters
- refresh onto bpf-next at d114bb989367
- add intermediate-boundary, big-endian, and microMIPS validation

v2: https://lore.kernel.org/bpf/20260729162931.2369353-1-main.kalliope@gmail.com/
v1: https://lore.kernel.org/bpf/20260716211055.2569433-1-main.kalliope@gmail.com/

Nicholas Dudar (3):
  bpf, mips: Factor out div/mod emission helpers
  MIPS: uasm: Add signed div/mod emitters
  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   | 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, 140 insertions(+), 55 deletions(-)


base-commit: d114bb98936770c501c958bf2bc5fb6b7c0bad7b

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-08-11  0:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-10 19:42 [PATCH bpf-next v3 0/3] bpf, mips: Add signed div/mod support Nicholas Dudar
2026-08-10 19:42 ` [PATCH bpf-next v3 1/3] bpf, mips: Factor out div/mod emission helpers Nicholas Dudar
2026-08-10 19:42 ` [PATCH bpf-next v3 2/3] MIPS: uasm: Add signed div/mod emitters Nicholas Dudar
2026-08-10 21:05   ` bot+bpf-ci
2026-08-11  0:34     ` Nicholas Dudar
2026-08-10 19:42 ` [PATCH bpf-next v3 3/3] bpf, mips: Add support for BPF_SDIV and BPF_SMOD Nicholas Dudar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox