#1 2026-08-28 19:49:44

Greg0r
Member
Registered: 2019-01-28
Posts: 55

small issue

Win64 ABI violation in SBlockMix (mormot.crypt.other.pas, ASMSSE2)

x86_64 SBlockMix uses xmm8..xmm11 and never restores them. On Win64 those are callee-saved, so SCrypt() silently corrupts the caller's FP state.
The hash stays correct, so no vector test catches it  a build with only the restore removed still passes all of RFC 7914.

Fix, once per call outside the R-loop:

sub rsp, 72
movaps [rsp], xmm8
movaps [rsp + 10H], xmm9
movaps [rsp + 20H], xmm10
movaps [rsp + 30H], xmm11
... body unchanged ...
movaps xmm8, [rsp]
movaps xmm9, [rsp + 10H]
movaps xmm10, [rsp + 20H]
movaps xmm11, [rsp + 30H]
add rsp, 72

ps: rsi/rdi are callee-saved too and get push/pop'ed  r10/r11 are volatile on both ABIs and remove that entirely.

Offline

#2 2026-08-28 22:12:12

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,587
Website

Re: small issue

I guess it may be not enough: XMM6-XMM15 should be preserved on Win64.

Could you prepare a pull request?

Offline

#3 Yesterday 13:12:34

Greg0r
Member
Registered: 2019-01-28
Posts: 55

Re: small issue

agreed on the rule  the other six are preserved already
since the routine never writes them
of xmm6..xmm15 it only touches xmm8..xmm11, and the probe loads all ten to confirm rest come back byte 1:1

ps. I do not use GH

Offline

#4 Yesterday 15:13:06

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,587
Website

Re: small issue

Should be fine with
https://github.com/synopse/mORMot2/commit/2c1daf90d

Note that a patch file also works great.
With no GT from Micro$oft account needed. wink

Thanks for the feedback!

Offline

Board footer

Powered by FluxBB