]> granicus.if.org Git - openssl/commitdiff
Add volatile qualifications to two blocks of inline asm to stop GCC from
authorAdam Langley <agl@chromium.org>
Mon, 3 Jun 2013 19:45:11 +0000 (15:45 -0400)
committerEmilia Kasper <emilia@openssl.org>
Tue, 19 Aug 2014 15:12:08 +0000 (17:12 +0200)
eliminating them as dead code.

Both volatile and "memory" are used because of some concern that the compiler
may still cache values across the asm block without it, and because this was
such a painful debugging session that I wanted to ensure that it's never
repeated.

(cherry picked from commit 7753a3a68431aa81b82beea4c3f5374b41454679)

Conflicts:
crypto/bn/asm/x86_64-gcc.c

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit a90b1e32d2f697d1aa39b49038469e2ea40d5e7b)

crypto/bn/asm/x86_64-gcc.c

index b1b8a1109bf7b619710a720a72a9c1e9643aadf2..2d80f192da25ab2eefdb70694f5f133bbe631c06 100644 (file)
@@ -185,7 +185,7 @@ BN_ULONG bn_add_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int
 
        if (n <= 0) return 0;
 
-       asm (
+       asm volatile (
        "       subq    %2,%2           \n"
        ".align 16                      \n"
        "1:     movq    (%4,%2,8),%0    \n"
@@ -196,7 +196,7 @@ BN_ULONG bn_add_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int
        "       sbbq    %0,%0           \n"
                : "=&a"(ret),"+c"(n),"=&r"(i)
                : "r"(rp),"r"(ap),"r"(bp)
-               : "cc"
+               : "cc", "memory"
        );
 
   return ret&1;
@@ -208,7 +208,7 @@ BN_ULONG bn_sub_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int
 
        if (n <= 0) return 0;
 
-       asm (
+       asm volatile (
        "       subq    %2,%2           \n"
        ".align 16                      \n"
        "1:     movq    (%4,%2,8),%0    \n"
@@ -219,7 +219,7 @@ BN_ULONG bn_sub_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int
        "       sbbq    %0,%0           \n"
                : "=&a"(ret),"+c"(n),"=&r"(i)
                : "r"(rp),"r"(ap),"r"(bp)
-               : "cc"
+               : "cc", "memory"
        );
 
   return ret&1;