cpu: add dedicated cpu_sha1_aot lifter for SHA1RNDS4, SHA1NEXTE, SHA1MSG1, and SHA1MSG2 #2368
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2376"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T14:15:18Z.
Change
Adds a dedicated, standalone portable C++ AOT lifter (
tools/cpu_sha1_aot.py, no<immintrin.h>) and differential MASM test suite (tests/cpu/sha1_aot.asm,tests/cpu/sha1_aot.def,tests/cpu/sha1_aot_check.py) registered as CTestcpu_aot_sha1inCMakeLists.txtfor the Intel SHA-1 NI instructions (docs/coverage/x64_zen2.tsvgroup Crypto):SHA1RNDS4(imm8 & 3selecting f0..f3, upper bitsimm8[7:2]ignored),SHA1NEXTE,SHA1MSG1, andSHA1MSG2across register, self-operand, and flat 16-byte[rcx|rdx|r8]memory operands, plusmovdqu/movdqatransport and terminalreton volatileXMM0..XMM5.SHA256*instructions, VEX/EVEX/non-legacy encodings, nonvolatileXMM6..15, undefined XMM reads, unalignedmovdqa/sha1*displacements, displaced/indexed/RIP-relative/non-argument memory operands, stores outside[r8], instruction prefixes, branches, missingret, and trailing instructions afterret.CPUID.07H.00H:EBX[29](host_has_sha()) after running all translator, portable reference, NIST FIPS 180-4, aliasing, mutant, and altered-build checks unconditionally; exits 77 on hosts lacking SHA-NI without writingFORM_COVERAGE_RECORD, and runs full bit-for-bit native vs lifted differential checks plusFORM_COVERAGE_RECORDoutput on SHA-NI hosts.AI-assisted.
Verification
Verified on rebased commit
948e9fd7(parentupstream/maine33578e1) in bothdev(Debug) andrelease(/O2) presets on a SHA-NI-capable Windows x64 host (0 skips):8/8 spot mutations against
tools/cpu_sha1_aot.py(6 Python lifter guard mutations: SHA-256 reject, VEX reject, nonvolatile vector reject, undefined XMM reject, store outside[r8], aligned displacement guard; plus 2 rebuilt C++ semantic mutations:op_sha1rnds4round constant0x6ed9eba1u -> 0x6ed9eba0uandop_sha1msg2dropping thew16dependency) were killed (exit non-zero) bytests/cpu/sha1_aot_check.py.Evidence and follow-up
tests/cpu/sha1_aot.asmandtests/cpu/sha1_aot.defare source-built synthetic MASM fixtures (MIT License) with; coverage: record cpu_aot_sha1andALTER_SHA1negative-control variants."abc", 56-byte, and 112-byte messages) are verified end-to-end through both the register-operand and memory-operand lifted exports against Python'shashlib.sha1.cpu_aot_crypto_shaandcpu_mul_divtargets remain untouched.Checklist