bpf, mips: Add signed div/mod support - #8691
Open
kernel-patches-daemon-bpf-rc[bot] wants to merge 3 commits into
Open
bpf, mips: Add signed div/mod support#8691kernel-patches-daemon-bpf-rc[bot] wants to merge 3 commits into
kernel-patches-daemon-bpf-rc[bot] wants to merge 3 commits into
Conversation
Author
|
Upstream branch: d114bb9 |
kernel-patches-daemon-bpf-rc
Bot
force-pushed
the
bpf-next_base
branch
from
August 11, 2026 22:08
818432c to
d922dc0
Compare
Factor MIPS32 and MIPS64 division and modulo emission out of emit_alu_r() and emit_alu_r64(). This prepares the JITs to select signed or unsigned opcodes without duplicating the R6 and pre-R6 handling. No functional change intended. Suggested-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Assisted-by: Codex:gpt-5.6-sol Signed-off-by: Nicholas Dudar <main.kalliope@gmail.com>
Add uasm emitters for the signed DIV, MOD, DDIV, and DMOD instructions. Provide both pre-R6 and R6 division forms so users can select the instruction appropriate for the target ISA. Assisted-by: Codex:gpt-5.6-sol Link: https://lore.kernel.org/bpf/CAM1=_QS79dDBfaaNQXnWd61AqHd1M4o9aDMMiftnoJveNr=FZg@mail.gmail.com/ Signed-off-by: Nicholas Dudar <main.kalliope@gmail.com>
Author
|
Upstream branch: 07cb86a |
The MIPS JITs handle BPF_DIV and BPF_MOD without inspecting insn->off, which distinguishes BPF_SDIV and BPF_SMOD. Signed operations therefore use unsigned instructions, or unsigned helpers for ALU64 on 32-bit MIPS, and produce unsigned results for negative operands. Pass insn->off unchanged through immediate validation and register emission, and interpret it only in div/mod-specific paths. Use signed DIV/DDIV for pre-R6 and DIV/MOD/DDIV/DMOD for R6. On 32-bit MIPS, use div64_s64() and a signed remainder helper for ALU64. Keep the signed quotient signed while computing that remainder, and keep signed immediates out of the unsigned power-of-two shift/mask rewrite. check_alu_op() rejects immediate zero divisors. bpf_do_misc_fixups() rewrites signed immediate -1 and guards register divisors that are zero or, for signed operations, -1 before JIT compilation. The ALU32 paths continue to zero-extend their results. The remaining test_bpf failures are five MOVSX, eight BSWAP, three MEMSX, and one JMP32_JA. MOVSX and MEMSX will be addressed separately; Johan Almbladh is handling BSWAP and JMP32_JA. Found while auditing BPF JIT handling of signed div/mod. Assisted-by: Codex:gpt-5.6-sol Link: https://lore.kernel.org/bpf/CAM1=_QS79dDBfaaNQXnWd61AqHd1M4o9aDMMiftnoJveNr=FZg@mail.gmail.com/ Link: https://lore.kernel.org/bpf/CAM1=_QQ7XiJEozaetLt_+kVn91YAXWpJK_pyfT9=paXseW=wwA@mail.gmail.com/ Signed-off-by: Nicholas Dudar <main.kalliope@gmail.com>
kernel-patches-daemon-bpf-rc
Bot
force-pushed
the
series/1143650=>bpf-next
branch
from
August 11, 2026 22:13
b3f3559 to
eb09f18
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request for series with
subject: bpf, mips: Add signed div/mod support
version: 3
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1143650