Fix for bug 227049. Prevent cache attacks on Windows 64 bits (AMD64). r=nelson,wtc
git-svn-id: svn://10.0.0.236/trunk@244400 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
7eba73f49e
commit
8bea682408
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user