aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/bn/asm
diff options
context:
space:
mode:
authorAdam Langley <agl@chromium.org>2013-06-03 15:45:11 -0400
committerBen Laurie <ben@links.org>2013-06-04 18:46:25 +0100
commit7753a3a68431aa81b82beea4c3f5374b41454679 (patch)
tree667db0b495304e6e4040bd816afd81612228150a /crypto/bn/asm
parent5dcd2deb3e8349f5f35628b2fcc6b815644e0791 (diff)
downloadopenssl-7753a3a68431aa81b82beea4c3f5374b41454679.tar.gz
Add volatile qualifications to two blocks of inline asm to stop GCC from
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.
Diffstat (limited to 'crypto/bn/asm')
-rw-r--r--crypto/bn/asm/x86_64-gcc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/crypto/bn/asm/x86_64-gcc.c b/crypto/bn/asm/x86_64-gcc.c
index dfb7506267..7d97c0bedc 100644
--- a/crypto/bn/asm/x86_64-gcc.c
+++ b/crypto/bn/asm/x86_64-gcc.c
@@ -189,7 +189,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 %0,%0 \n" /* clear carry */
" jmp 1f \n"
".p2align 4 \n"
@@ -201,7 +201,7 @@ BN_ULONG bn_add_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int
" sbbq %0,%0 \n"
: "=&r"(ret),"+c"(n),"+r"(i)
: "r"(rp),"r"(ap),"r"(bp)
- : "cc"
+ : "cc", "memory"
);
return ret&1;
@@ -214,7 +214,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 %0,%0 \n" /* clear borrow */
" jmp 1f \n"
".p2align 4 \n"
@@ -226,7 +226,7 @@ BN_ULONG bn_sub_words (BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int
" sbbq %0,%0 \n"
: "=&r"(ret),"+c"(n),"+r"(i)
: "r"(rp),"r"(ap),"r"(bp)
- : "cc"
+ : "cc", "memory"
);
return ret&1;