From a764ec929eec2abdedd76cb5b593c8ec6a6abcfd Mon Sep 17 00:00:00 2001 From: Kenjiro Nakayama Date: Sat, 22 Aug 2026 11:06:51 +0900 Subject: Enable supported MIPS32 assembly in CI Use the little endian MIPS32 toolchain since the generated assembly is little-endian, and define the architecture feature macros needed to select the AES, BN, SHA-1, and SHA-256 assembly implementations. Do not generate or build SHA-512 assembly for MIPS32. The generator accepts the O32 ABI, but the resulting implementation still uses 64-bit instructions and requires the MIPS64 ISA. It is therefore not valid for generic MIPS32 targets. --- .github/workflows/linux.yml | 2 +- configure.ac | 2 +- crypto/Makefile.am.elf-mips | 1 - crypto/arch/mips/crypto_arch.h | 18 ++++++++++++++++++ crypto/bn/arch/mips/bn_arch.h | 19 +++++++++++++++++++ scripts/test | 9 +++++---- update.sh | 1 - 7 files changed, 44 insertions(+), 8 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a2a85e7..06dda17 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -68,7 +68,7 @@ jobs: packages+=(qemu-user-static binfmt-support g++-14-loongarch64-linux-gnu) ;; mips32) - packages+=(qemu-user-static binfmt-support g++-mips-linux-gnu) + packages+=(qemu-user-static binfmt-support g++-mipsel-linux-gnu) ;; mips64) packages+=(qemu-user-static binfmt-support g++-mips64el-linux-gnuabi64) diff --git a/configure.ac b/configure.ac index 12703dd..7c6ac98 100644 --- a/configure.ac +++ b/configure.ac @@ -95,7 +95,7 @@ AS_CASE([$host_cpu], [*amd64*], [host_cpu=x86_64 HOSTARCH=intel], [i?86], [host_cpu=i386 HOSTARCH=intel enable_asm=no], [mips64*], [host_cpu=mips64 enable_asm=${enable_asm-no}], - [mips*], [host_cpu=mips enable_asm=no], + [mips*], [host_cpu=mips enable_asm=${enable_asm-no}], [powerpc*], [host_cpu=powerpc], [ppc64*], [host_cpu=powerpc64], [x86_64], [HOSTARCH=intel] diff --git a/crypto/Makefile.am.elf-mips b/crypto/Makefile.am.elf-mips index 2276991..682fb5e 100644 --- a/crypto/Makefile.am.elf-mips +++ b/crypto/Makefile.am.elf-mips @@ -2,7 +2,6 @@ ASM_MIPS_ELF = aes/aes-mips.S ASM_MIPS_ELF += bn/bn-mips.S ASM_MIPS_ELF += bn/mont-mips.S ASM_MIPS_ELF += sha/sha1-mips.S -ASM_MIPS_ELF += sha/sha512-mips.S ASM_MIPS_ELF += sha/sha256-mips.S EXTRA_DIST += $(ASM_MIPS_ELF) diff --git a/crypto/arch/mips/crypto_arch.h b/crypto/arch/mips/crypto_arch.h index 274879c..2407503 100644 --- a/crypto/arch/mips/crypto_arch.h +++ b/crypto/arch/mips/crypto_arch.h @@ -18,4 +18,22 @@ #ifndef HEADER_CRYPTO_ARCH_H #define HEADER_CRYPTO_ARCH_H +#ifndef OPENSSL_NO_ASM + +#ifdef LIBRESSL_USE_AES_ASSEMBLY +#define HAVE_AES_SET_ENCRYPT_KEY_INTERNAL +#define HAVE_AES_SET_DECRYPT_KEY_INTERNAL +#define HAVE_AES_ENCRYPT_INTERNAL +#define HAVE_AES_DECRYPT_INTERNAL +#endif + +#ifdef LIBRESSL_USE_SHA_ASSEMBLY +#define HAVE_SHA1_BLOCK_DATA_ORDER +#define HAVE_SHA1_BLOCK_GENERIC +#define HAVE_SHA256_BLOCK_DATA_ORDER +#define HAVE_SHA256_BLOCK_GENERIC +#endif + +#endif + #endif diff --git a/crypto/bn/arch/mips/bn_arch.h b/crypto/bn/arch/mips/bn_arch.h index 4d6571f..a14b83b 100644 --- a/crypto/bn/arch/mips/bn_arch.h +++ b/crypto/bn/arch/mips/bn_arch.h @@ -20,5 +20,24 @@ #ifndef OPENSSL_NO_ASM +#ifdef LIBRESSL_USE_BN_ASSEMBLY + +#define HAVE_BN_ADD_WORDS + +#define HAVE_BN_DIV_WORDS +#define HAVE_BN_DIV_3_WORDS + +#define HAVE_BN_MUL_COMBA4 +#define HAVE_BN_MUL_COMBA8 +#define HAVE_BN_MULW_ADD_WORDS +#define HAVE_BN_MULW_WORDS + +#define HAVE_BN_SQR_COMBA4 +#define HAVE_BN_SQR_COMBA8 + +#define HAVE_BN_SUB_WORDS + +#endif + #endif #endif diff --git a/scripts/test b/scripts/test index 6d573e3..b3386a8 100755 --- a/scripts/test +++ b/scripts/test @@ -173,11 +173,12 @@ elif [ "$ARCH" = "riscv64" ]; then elif [ "$ARCH" = "mips32" ] || [ "$ARCH" = "mips64" ]; then if [ "$ARCH" = "mips32" ]; then - sudo ln -sf /usr/mips-linux-gnu/lib/ld.so.1 /lib/ - setup_cross_compiler mips-linux-gnu + sudo ln -sf /usr/mipsel-linux-gnu/lib/ld.so.1 /lib/ + setup_cross_compiler mipsel-linux-gnu - ./configure --host=mips-linux-gnu - LD_LIBRARY_PATH=/usr/mips-linux-gnu/lib make -j 4 check + # MIPS32 assembly is disabled by default, so enable it for CI coverage. + ./configure --host=mipsel-linux-gnu --enable-asm + LD_LIBRARY_PATH=/usr/mipsel-linux-gnu/lib make -j 4 check else sudo ln -sf /usr/mips64el-linux-gnuabi64/lib64/ld.so.1 /lib64 setup_cross_compiler mips64el-linux-gnuabi64 diff --git a/update.sh b/update.sh index ddd2cf3..4b2c4dd 100755 --- a/update.sh +++ b/update.sh @@ -248,7 +248,6 @@ gen_asm_mips o32 bn mips bn-mips gen_asm_mips o32 bn mips-mont mont-mips gen_asm_mips o32 sha sha1-mips sha1-mips gen_asm_mips o32 sha sha512-mips sha256-mips -gen_asm_mips o32 sha sha512-mips sha512-mips echo generating mips64 ASM source for elf gen_asm_mips 64 aes aes-mips aes-mips64 -- cgit v1.2.3-55-g6feb