xmm6 overwritten/not restored by HashUpdate
Closed this issue · 5 comments
Root problem: xmm6 is not being restored after a call to ippsHashUpdate (& ippsHashUpdate_rmf) in certain circumstances.
I recently upgraded from 2020.0 to 2020.1 (as downloaded from Intel web site). My unit tests which verify hash computation began to fail in certain configurations (Release mode SHA hashes) but pass in others (all Debug modes, all MD5 hashes). This occurs in both AVX (e9) & AVX2 (l9) modes of the crypto library.
My unit test does the following (with run-time arguments for hash type):
- Call ippsHashGetSize
- Call ippsHashInit
- Calls ippsHashUpdate in a loop with a single byte value & length of 1
- Calls ippsHashFinal
- Verifies hash result against a "pre-computed" value.
In release mode only, the compiler (MSVC 1926, Windows x64) creates a temporary object and stores it into xmm6; this is used as part of the call tree in my test code & is restored as arguments to the ippsHashUpdate call on each loop pass. For MD5, this register is never affected, but after a certain number of calls to ippsHashUpdate with the SHA functions, the register is zero-ized by ippsHashUpdate (which then breaks the remainder of the hash computation loop, because further calls are made with a null pointer & length of zero as loaded from xmm6). Per the x64 ABI, xmm6-xmm15 are non-volatile across function calls and should be restored by the callee.
- MD5: always works
- SHA1, SHA224, SHA256: after 64 single-byte calls, xmm6 is zero-ized & not restored by ippsHashUpdate
- SHA384, SHA512: after 128 single-byte calls, xmm6 is zero-ized & not restored by ippsHashUpdate
My guess is that something about the restoration of xmm registers is not working, and that it is tied to crossing a certain block boundary within ippsHashUpdate.
Hi Brian,
Thanks for reporting it.
Yes, we confirm such issue with non-volatile xmm registers. We fixed it, and the fix will be available in upcoming 2020 Update 2.
Regards,
Andrey
Excellent, thank you. I'll keep an eye out for that update. Request to leave this issue open until release of 2020 Update 2 for awareness.
Sure, I'll make an update here once it is out, so that you can check.
Hi Brian,
The 2020u2 is uploaded, so you can take a look on it. Please let me know if the fix works for you.
Regards,
Andrey
Yes, updating to 2020 update 2 worked. Thank you.