BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v4 0/3] bpf, mips: Add signed div/mod support
@ 2026-09-11 21:33 Nicholas Dudar
  2026-09-11 21:33 ` [PATCH bpf-next v4 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-09-11 21:33 UTC (permalink / raw)
  To: tsbogend, ast, daniel, andrii, eddyz87, memxor, johan.almbladh,
	paulburton
  Cc: martin.lau, song, yonghong.song, jolsa, emil, ihor.solodrai,
	linux-mips, linux-kernel, bpf, philmd

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@gmail.com/
MOVSX review: https://lore.kernel.org/bpf/CAM1=_QTN3JJ6jtckf32F8wxBzLDbHSrzUttyMBWNqZKmRe=2rg@mail.gmail.com/

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

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

end of thread, other threads:[~2026-09-12  0:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-11 21:33 [PATCH bpf-next v4 0/3] bpf, mips: Add signed div/mod support Nicholas Dudar
2026-09-11 21:33 ` [PATCH bpf-next v4 1/3] bpf, mips: Factor out div/mod emission helpers Nicholas Dudar
2026-09-11 21:33 ` [PATCH bpf-next v4 2/3] MIPS: uasm: Add signed div/mod and sign-extension emitters Nicholas Dudar
2026-09-11 22:30   ` bot+bpf-ci
2026-09-12  0:52     ` Nicholas Dudar
2026-09-11 21:33 ` [PATCH bpf-next v4 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