Commit e164b340 authored by Adam Langley's avatar Adam Langley Committed by Emilia Kasper
Browse files

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.

(cherry picked from commit 7753a3a6)

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

Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
(cherry picked from commit a90b1e32)
parent 679d0c86
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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	%2,%2		\n"
	".p2align 4			\n"
	"1:	movq	(%4,%2,8),%0	\n"
@@ -200,7 +200,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;
@@ -212,7 +212,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"
	".p2align 4			\n"
	"1:	movq	(%4,%2,8),%0	\n"
@@ -223,7 +223,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;