From: Mark Wooding Date: Wed, 13 Jul 2016 22:19:03 +0000 (+0100) Subject: base/asm-common.h, *.S: Include metadata for 64-bit Windows stack unwinding. X-Git-Tag: 2.3.0~47 X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/commitdiff_plain/f71dd54d995dcffeb73fb41132a60b6ae62d2ea3 base/asm-common.h, *.S: Include metadata for 64-bit Windows stack unwinding. There are (annoyingly undocumented) assembler directives, which make this fairly straightforward. I've manually verified that they're setting up the expected data structures correctly. Under normal circumstances, we don't expect these leaf functions to throw exceptions. Note that the `endswap_block' subroutine of `rijndael_setup_x86ish_- aesni' is not currently properly described. --- diff --git a/base/asm-common.h b/base/asm-common.h index 0b5f2238..0d32ccf9 100644 --- a/base/asm-common.h +++ b/base/asm-common.h @@ -100,6 +100,14 @@ name: // Set the function hooks. #define FUNC_PREHOOK(_) .balign 16 +// On Windows, arrange to install stack-unwinding data. +#if CPUFAM_AMD64 && ABI_WIN +# define FUNC_POSTHOOK(name) .seh_proc name +# define ENDFUNC_HOOK(_) .seh_endproc +// Procedures are expected to invoke `.seh_setframe' if necessary, and +// `.seh_pushreg' and friends, and `.seh_endprologue'. +#endif + // Don't use the wretched AT&T syntax. It's festooned with pointless // punctuation, and all of the data movement is backwards. Ugh! .intel_syntax noprefix diff --git a/symm/chacha-x86ish-sse2.S b/symm/chacha-x86ish-sse2.S index 641ad653..42091536 100644 --- a/symm/chacha-x86ish-sse2.S +++ b/symm/chacha-x86ish-sse2.S @@ -110,6 +110,8 @@ FUNC(chacha_core_x86ish_sse2) # define SAVE3 [rsp + 32] sub rsp, 48 + 8 + .seh_stackalloc 48 + 8 + .seh_endprologue #endif // First job is to slurp the matrix into XMM registers. Be careful: diff --git a/symm/rijndael-x86ish-aesni.S b/symm/rijndael-x86ish-aesni.S index 3dcdfc58..27f09bc4 100644 --- a/symm/rijndael-x86ish-aesni.S +++ b/symm/rijndael-x86ish-aesni.S @@ -165,7 +165,10 @@ FUNC(rijndael_setup_x86ish_aesni) // We'll need the index registers, which belong to the caller in this // ABI. push rsi + .seh_pushreg rsi push rdi + .seh_pushreg rdi + .seh_endprologue // Move arguments to more useful places. mov SI, r8 // key material @@ -420,6 +423,7 @@ ENDFUNC # define SRC rdx # define DST r8 # define NR eax + .seh_endprologue #endif // Find the magic endianness-swapping table. diff --git a/symm/salsa20-x86ish-sse2.S b/symm/salsa20-x86ish-sse2.S index 47401b7a..6da6b246 100644 --- a/symm/salsa20-x86ish-sse2.S +++ b/symm/salsa20-x86ish-sse2.S @@ -111,8 +111,12 @@ FUNC(salsa20_core_x86ish_sse2) # define SAVE3 [rsp + 48] sub rsp, 64 + 8 + .seh_stackalloc 64 + 8 movdqa [rsp + 0], xmm6 + .seh_savexmm xmm6, 0 movdqa [rsp + 16], xmm7 + .seh_savexmm xmm7, 16 + .seh_endprologue #endif // First job is to slurp the matrix into XMM registers. The words