Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The cryptographic assembly changes across MIPS32 and MIPS64 n32/n64 need GCC cross-build and runtime validation, since Clang-only results do not confirm the compiler-specific register constraints implicated in the original GCC failure.
No open issues 🎉
What changed in this PR
Adds MIPS Release 6 support to wolfCrypt’s SP integer assembly, addressing the build failure caused by removed HI/LO registers and instructions in #11953.
Changes:
- Uses
mulu/muhuanddmulu/dmuhuon Release 6, retaining legacy multiply sequences on older targets. - Makes HI/LO clobbers conditional on the ISA revision.
- Adds early-clobber constraints to high-word outputs to prevent input-register overlap.
| File | Description |
|---|---|
wolfcrypt/src/sp_int.c |
Updates MIPS32 and MIPS64 multiply and square macros for Release 6 compatibility. |
Review effort: Balanced
|
Contributor
Author
|
Jenkins: retest this please |
SparkiDev
force-pushed
the
mips_r6_sp_int_asm
branch
3 times, most recently
from
November 4, 2026 00:23
0accbf8 to
400f19d
Compare
Contributor
Author
|
Jenkins: retest this please |
MIPS Release 6 removed the HI/LO registers and the multu/dmultu, mflo and mfhi instructions. The SP int MIPS and MIPS64 assembly used them and listed $hi/$lo as clobbers, so builds for r6 CPUs failed with "the register '$hi' cannot be clobbered". Add SP_ASM_MIPS_MUL to put the low and high words of a multiplication into registers. Use mulu/muhu (dmulu/dmuhu for 64-bit) when __mips_isa_rev >= 6 and the existing multu/mflo/mfhi sequence otherwise. Only clobber HI/LO before r6. Mark the high word output as early clobber in the macros that write the result directly, as r6 writes it before the inputs are fully consumed. Code generated for pre-r6 targets is unchanged.
SparkiDev
force-pushed
the
mips_r6_sp_int_asm
branch
from
November 4, 2026 05:07
400f19d to
d477168
Compare
Contributor
Author
|
Jenkins: retest this please |
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.
Description
MIPS Release 6 removed the HI/LO registers and the multu/dmultu, mflo and mfhi instructions. The SP int MIPS and MIPS64 assembly used them and listed $hi/$lo as clobbers, so builds for r6 CPUs failed with "the register '$hi' cannot be clobbered".
Add SP_ASM_MIPS_MUL to put the low and high words of a multiplication into registers. Use mulu/muhu (dmulu/dmuhu for 64-bit) when __mips_isa_rev >= 6 and the existing multu/mflo/mfhi sequence otherwise. Only clobber HI/LO before r6. Mark the high word output as early clobber in the macros that write the result directly, as r6 writes it before the inputs are fully consumed.
Code generated for pre-r6 targets is unchanged.
Fixes #11953
Testing
The patched source was cross-built with
./configure --host=<mips triplet> --enable-all --disable-sharedusing zig 0.14.1cc(clang-based, musl libc) as the compiler.wolfcrypt/test/testwolfcryptwas then run under qemu-user.sp_int.oWOLFSSL_SP_MIPS64dmulu/dmuhuWOLFSSL_SP_MIPS64dmulu/dmuhuWOLFSSL_SP_MIPSmulu/muhuWOLFSSL_SP_MIPSmultu/mflo/mfhi