This series implements SPARC crypto instructions for QEMU. Most other arches already support crypto instructions, but SPARC is lagging behind.
The following instructions are added: - AES rounds and key expansions - CRC32C - SHA1/256/512 - RDCFR (Compatibility Feature Register) Camellia is intentionally left out as it's possibly being removed from the kernel code, and does not seem to be needed. DES/MD5/MPMUL also left out, as Linux doesn't use them. Motivated by the need for QEMU-testable SPARC crypto code without access to real hardware. An issue was raised by kernel maintainer Eric Biggers in: https://github.com/sparclinux/issues/issues/77 A new +crypto CPU feature enables the instructions and the CFR. This is off by default, and does not change default behaviour. The most difficult part to get right, and the biggest patch, was the SHA instructions. On SPARC, a single instruction hashes one whole block. sha1, sha256 and sha512 each do a complete FIPS 180-4 compression. Testing: - Every instruction tested against SPARC T4-1 and SPARC T7-1 - Tested QEMU on big-endian host (sparc64 T7-1) - Linux 7.3-rc5 crypto and CRC KUnit suites (208 passed, 0 failed) The Linux test used an unsent kernel patch plus -prom-env nvramrc. AI tool disclosure: - An early incomplete prototype was made using LLM tools - Used to research the OSA 2011 and FIPS 180-4 document. Implementation strategies and review of the _existing_ QEMU code. - Local test tooling. Scripts for comparing the output vs real SPARC hardware. - Review of patches, fixes made by me - No code, comments or commit messages directly from AI tools References: OSA (Oracle SPARC Architecture) 2011: https://www.oracle.com/technetwork/server-storage/sun-sparc-enterprise/documentation/140521-ua2011-d096-p-ext-2306580.pdf qemu-devel RFC: https://lists.gnu.org/archive/html/qemu-devel/2026-09/msg09494.html Stian Halseth (7): target/sparc: Add crypto feature target/sparc: Return CFR when crypto feature is enabled target/sparc: Add the eight AES round instructions target/sparc: Add the AES key expansion instructions target/sparc: Add the CRC32C instruction target/sparc: Add the SHA instructions linux-user/sparc: Report HWCAP_SPARC_CRYPTO for crypto CPU feature linux-user/sparc/elfload.c | 1 + target/sparc/cpu-feature.h.inc | 1 + target/sparc/cpu.c | 3 + target/sparc/crypto_helper.c | 435 +++++++++++++++++++++++++++++++++ target/sparc/helper.h | 15 ++ target/sparc/insns.decode | 26 +- target/sparc/meson.build | 2 +- target/sparc/translate.c | 81 ++++++ 8 files changed, 562 insertions(+), 2 deletions(-) create mode 100644 target/sparc/crypto_helper.c base-commit: 11661d857254b27fca5568c6deacf4f6b6f3460f -- 2.43.0
