Repository navigation
Conversation
|
There was a problem hiding this comment.
🟡 Changes recommended
Toolchain-supplied CPU flags can leave C and assembly targets inconsistent, causing AArch64 link failures, and bypass the required ARMv7 FIPS inline workaround.
2 open issues
What changed in this PR
Adds explicit ARM assembly support to wolfSSL’s CMake configuration, aligning CPU defaults with Autotools and extending ML-DSA assembly integration.
Changes:
- Adds ARM assembly options, CPU defaults, and generated-header definitions.
- Includes ARM ML-DSA assembly in CMake and Zephyr builds.
- Adds ARM and configuration-template CI coverage, with fixes for template and
NO_TLSbuilds.
| File | Description |
|---|---|
zephyr/CMakeLists.txt |
Includes supported ARM ML-DSA assembly sources. |
wolfssl/wolfcrypt/settings.h |
Derives SQRDMLSH availability from compiler target features. |
src/internal.c |
Excludes CSR v2 pending-CA handling from NO_TLS builds. |
CMakeLists.txt |
Adds ARM options, CPU defaults, target detection, and warning-macro compatibility. |
cmake/options.h.in |
Exports ARM assembly configuration macros. |
cmake/functions.cmake |
Selects inline or standalone ARM ML-DSA assembly sources. |
.github/workflows/cmake.yml |
Adds ARM assembly tests and user-settings template builds. |
Review effort: Balanced
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12126
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): .github/workflows/cmake.yml, CMakeLists.txt, cmake/functions.cmake, cmake/options.h.in, zephyr/CMakeLists.txt
Coverage: 2 of 2 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Max
2793703 to
c9418bd
Compare
|
@claude review |
c9418bd to
8d71f48
Compare
Autotools adds armv8-mldsa-asm and armv8-32-mldsa-asm when ARM assembly is enabled, but the CMake build never did, so an ARM assembly CMake build with ML-DSA failed to link on the mldsa_*_neon functions. Add them as the ML-KEM block does; each file guards itself on the target architecture.
The AArch64 ML-KEM and ML-DSA assembly use SQRDMLSH unless WOLFSSL_AARCH64_NO_SQRDMLSH is defined, and that instruction only assembles when the target CPU has RDM. Only configure's default -mcpu=generic+crypto and the Zephyr settings defined it, so an AArch64 assembly build for a CPU without RDM, such as -march=armv8-a+crypto or an iOS arm64 target, failed with "instruction requires: rdm". Define it in settings.h whenever __ARM_FEATURE_QRDMX is absent. Targets with RDM keep the SQRDMLSH code.
cmake/functions.cmake already picked the ARM assembly sources on WOLFSSL_ARM_ASM, but nothing declared the option or defined WOLFSSL_ARMASM, so an ARM assembly CMake build only worked from a user_settings.h with hand-picked CPU flags. Declare the option and define WOLFSSL_ARMASM, which reaches the assembly sources and options.h. Unless a -mcpu=, -mfpu= or -march= option is set in CMAKE_C_FLAGS or CMAKE_ASM_FLAGS, in any of their per-configuration variants or in the directory compile options, or the build uses user_settings.h, add the CPU defaults of --enable-armasm: -mcpu=generic+crypto and -mstrict-align on AArch64, the SHA-512/SHA-3 crypto instructions on macOS, NEON without the crypto extension on ARMv7-A, Thumb-2 without NEON on ARMv7-M and ARMv7E-M, ARMv6 and ARMv4 without NEON or the crypto extension, and the ARMv8 crypto extension on other 32-bit ARM. When CMAKE_C_COMPILER_TARGET is set, its arch picks the CPU branch, with thumb read as arm, as configure does with its host triple, so thumbv7em-none-eabi takes the ARMv7E-M path. iOS and the other Apple arm64 targets keep their own CPU flags. ARMv5, ARMv6-M, ARMv7-R, ARMv8-R, ARMv8-M and any other processor name, such as a core name, have no defaults and get a warning. A build that skips the defaults says so in a status line. ARMv7 FIPS builds use the inline assembly, as configure does. A user who sets the CPU also sets it in CMAKE_ASM_FLAGS, and gets a warning when only one of CMAKE_C_FLAGS and CMAKE_ASM_FLAGS sets it. Declare WOLFSSL_ARMASM_THUMB2, which already picked the Thumb-2 sources, as an option that defines the macro on 32-bit ARM together with WOLFSSL_ARMASM_NO_NEON and WOLFSSL_ARMASM_NO_HW_CRYPTO, since the Thumb-2 ports have neither. Refuse a build for a known non-ARM target or for several macOS architectures at once, and ignore WOLFSSL_ARM_ASM when WOLFSSL_ASM is off, as configure does, without changing its cached value. A 32-bit userland on a 64-bit kernel, such as 32-bit Raspberry Pi OS, reports aarch64 as the processor. Treat it as 32-bit ARMv8 (armv8l, as config.guess reports it) when the compiler has 4-byte pointers and does not define __aarch64__, so that neither the AArch64 CPU flags nor WOLFSSL_AARCH64_BUILD reach a 32-bit compiler. AArch64 ILP32 defines __aarch64__ and stays on the AArch64 path. Export WOLFSSL_ARMASM_INLINE and the new macros through options.h. Add a CMake CI job on AArch64 Linux and macOS that builds the assembly and inline forms, checks that options.h exports every library define and runs ctest.
CMake passed -DWOLFSSL_IGNORE_FILE_WARN, which defines it as 1, while the examples/configs templates define it empty. A CMake user_settings.h build from user_settings_pq.h, _tls12.h, _tls13.h, _dtls13.h, _rsa_only.h, _ca.h or _pkcs7.h therefore failed -Werror on the macro redefinition. Define it empty so both definitions match.
ProcessPeerCertAddPendingCA() calls TLSX_CSR2_AddPendingSigner(), which tls.c only builds without NO_TLS. Every other CSR v2 call in ProcessPeerCerts() already checks NO_TLS, so a NO_TLS build with HAVE_CERTIFICATE_STATUS_REQUEST_V2, such as user_settings_ca.h, failed to link whenever the unused helper was kept, as in an unoptimized CMake build. Guard the helper, its call and addToPendingCAs the same way. Add a CMake CI step that builds the tls12, tls13, dtls13, pq, rsa_only, ca and pkcs7 user_settings.h templates as Debug builds, so this link failure and the WOLFSSL_IGNORE_FILE_WARN redefinition fixed in the previous commit stay caught.
zephyr/CMakeLists.txt never added armv8-mldsa-asm_c.c or armv8-32-mldsa-asm_c.c, so a Zephyr AArch64 build with CONFIG_WOLFCRYPT_ASM and ML-DSA failed to link on the mldsa_*_neon functions. Add them for the ARMv8 prefixes, in the symmetric assembly list and after wc_mldsa in the FIPS v7 boundary as src/include.am does. There is no Thumb-2 ML-DSA assembly, so Cortex-M builds are unchanged.
8d71f48 to
73517bf
Compare


Description
CMake picked the ARM assembly sources on
WOLFSSL_ARM_ASMbut never declared the option or definedWOLFSSL_ARMASM, so ARM assembly only worked through a hand-writtenuser_settings.h. This adds the option with the--enable-armasmCPU defaults and builds the ARM ML-DSA assembly in CMake and the Zephyr module.Changes
WOLFSSL_ARM_ASMandWOLFSSL_ARMASM_THUMB2, defineWOLFSSL_ARMASMand add configure's per-CPU defaults unless the user set-mcpu/-mfpu/-marchWOLFSSL_AARCH64_NO_SQRDMLSHin settings.h from the compiler's target CPUWOLFSSL_IGNORE_FILE_WARNempty in CMake souser_settings.htemplates don't hit a redefinition errorNO_TLSbuilds, which failed to link withuser_settings_ca.hTesting
build-armasmCMake job on AArch64 Linux and macOS: assembly and inline forms, checks options.h exports every library define, runs ctesttls12,tls13,dtls13,pq,rsa_only,caandpkcs7user_settings.htemplates