Skip to content

bpf, mips: Add signed div/mod support

Nicholas Dudar bpf linux-mips lkml 3 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest3 patches 2 repliesApplied 3/3
  2. v33 patches 5 repliesSuperseded
  3. v22 patches 5 repliesSuperseded

Changes in v4 from the cover letter

- Add seb/seh uasm emitters for R2-or-newer CPUs.
- Rebase onto current bpf-next without changing the implementation.

Patches in v4 All 3 applied

#Subject and filesSizeRepliesApplied
1/3bpf, mips: Factor out div/mod emission helpersarch/mips/net/bpf_jit_comp.c arch/mips/net/bpf_jit_comp64.c+48 -240 repliesApplied
2/3MIPS: uasm: Add signed div/mod and sign-extension emittersarch/mips/include/asm/uasm.h arch/mips/mm/uasm-mips.c arch/mips/mm/uasm.c+37 -71 replyApplied
3/3bpf, mips: Add support for BPF_SDIV and BPF_SMODarch/mips/net/bpf_jit_comp.c arch/mips/net/bpf_jit_comp.h arch/mips/net/bpf_jit_comp32.c +1 more+78 -410 repliesApplied

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchPhilippe Mathieu-DaudéJohan Almbladh
SeriesT-b A-b
1/3R-b
2/3
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH bpf-next v4 0/3] bpf, mips: Add signed div/mod support

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/[email protected]/
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