chiark / gitweb /
base/asm-common.h, *.S: Include metadata for 64-bit Windows stack unwinding.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 13 Jul 2016 22:19:03 +0000 (23:19 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 13 Jul 2016 22:19:03 +0000 (23:19 +0100)
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.

base/asm-common.h
symm/chacha-x86ish-sse2.S
symm/rijndael-x86ish-aesni.S
symm/salsa20-x86ish-sse2.S

index 0b5f2238a2b658373f0b4715f01ab4e5ac78f989..0d32ccf90952bd5272236a75d4e12bf214078b85 100644 (file)
@@ -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
index 641ad653cba036231f0474aa1a1ecf27de02c7fe..42091536f4e34edf1b53761c9936e77814472d05 100644 (file)
@@ -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:
index 3dcdfc58d4814b7c0829701c7dd4349e90255e0a..27f09bc4c2fd60f726f449c52bce696118a35d6c 100644 (file)
@@ -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.
index 47401b7a769a57da093e0ec9f96497da32d19f92..6da6b24683fe9ab0b3ece85b034f23c67865c7fd 100644 (file)
@@ -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