summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjulien.pierre.boogz%sun.com <devnull@localhost>2008-01-29 23:07:02 +0000
committerjulien.pierre.boogz%sun.com <devnull@localhost>2008-01-29 23:07:02 +0000
commit3543eb9398416fad0a255e7fc4e8f3280d96934c (patch)
tree1c9b26b25484360e790bb9da9a6ae9a49c09b314
parent61f9833e470ffa4c7bebb7950c6d454b7030f227 (diff)
downloadnss-hg-3543eb9398416fad0a255e7fc4e8f3280d96934c.tar.gz
Fix for bug 227049. Prevent cache attacks on Windows 64 bits (AMD64). r=nelson,wtc
-rw-r--r--security/nss/lib/freebl/mpi/mpcpucache.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/security/nss/lib/freebl/mpi/mpcpucache.c b/security/nss/lib/freebl/mpi/mpcpucache.c
index 04f278fc2..65927d05e 100644
--- a/security/nss/lib/freebl/mpi/mpcpucache.c
+++ b/security/nss/lib/freebl/mpi/mpcpucache.c
@@ -53,16 +53,19 @@
*
*/
-#if defined(i386) || defined(__i386) || defined(__X86__) || defined (_M_IX86) || defined(__x86_64__) || defined(__x86_64)
+#if defined(i386) || defined(__i386) || defined(__X86__) || defined (_M_IX86) || defined(__x86_64__) || defined(__x86_64) || defined(_M_AMD64)
/* X86 processors have special instructions that tell us about the cache */
#include "string.h"
-#if defined(__x86_64__) || defined(__x86_64)
+#if defined(__x86_64__) || defined(__x86_64) || defined(_M_AMD64)
#define AMD_64 1
#endif
/* Generic CPUID function */
#if defined(AMD_64)
+
+#if defined(__GNUC__)
+
static void cpuid(unsigned long op, unsigned long *eax,
unsigned long *ebx, unsigned long *ecx,
unsigned long *edx)
@@ -74,7 +77,31 @@ static void cpuid(unsigned long op, unsigned long *eax,
"=d" (*edx)
: "0" (op));
}
-#elif !defined(_MSC_VER)
+
+#elif defined(_MSC_VER)
+
+#include <intrin.h>
+
+static void cpuid(unsigned long op, unsigned long *eax,
+ unsigned long *ebx, unsigned long *ecx,
+ unsigned long *edx)
+{
+ int intrinsic_out[4];
+
+ __cpuid(intrinsic_out, op);
+ *eax = intrinsic_out[0];
+ *ebx = intrinsic_out[1];
+ *ecx = intrinsic_out[2];
+ *edx = intrinsic_out[3];
+}
+
+#endif
+
+#else /* !defined(AMD_64) */
+
+/* x86 */
+
+#if defined(__GNUC__)
static void cpuid(unsigned long op, unsigned long *eax,
unsigned long *ebx, unsigned long *ecx,
unsigned long *edx)
@@ -115,7 +142,7 @@ static unsigned long changeFlag(unsigned long flag)
return changedFlags ^ originalFlags;
}
-#else
+#elif defined(_MSC_VER)
/*
* windows versions of the above assembler
@@ -166,6 +193,8 @@ static unsigned long changeFlag(unsigned long flag)
}
#endif
+#endif
+
#if !defined(AMD_64)
#define AC_FLAG 0x40000
#define ID_FLAG 0x200000