зеркало из https://github.com/mozilla/pjs.git
Fix for bug 227049. Prevent cache attacks on Windows 64 bits (AMD64). r=nelson,wtc
This commit is contained in:
Родитель
8bf2b98740
Коммит
2e7ca34bca
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче