| Index: src/trusted/cpu_features/arch/x86/cpu_x86.c
|
| diff --git a/src/trusted/validator/x86/nacl_cpuid.c b/src/trusted/cpu_features/arch/x86/cpu_x86.c
|
| similarity index 97%
|
| rename from src/trusted/validator/x86/nacl_cpuid.c
|
| rename to src/trusted/cpu_features/arch/x86/cpu_x86.c
|
| index bcb83ffc9d2c427121d89e4b083353b761f92779..37f478ae887e64d97a9ae4d06f6c44dbdedab2c0 100644
|
| --- a/src/trusted/validator/x86/nacl_cpuid.c
|
| +++ b/src/trusted/cpu_features/arch/x86/cpu_x86.c
|
| @@ -4,10 +4,10 @@
|
| * found in the LICENSE file.
|
| */
|
|
|
| -#include "native_client/src/trusted/validator/x86/nacl_cpuid.h"
|
| +#include "native_client/src/trusted/cpu_features/arch/x86/cpu_x86.h"
|
|
|
| /*
|
| - * nacl_cpuid.c
|
| + * cpu_x86.c
|
| * Retrieve and decode CPU model specific feature mask.
|
| */
|
| #if NACL_WINDOWS
|
| @@ -244,6 +244,7 @@ static const char NSC_CPUID0[kVendorIDLength] = "Geode by NSC";
|
| #endif
|
|
|
| static int asm_HasCPUID(void) {
|
| +#if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86
|
| volatile int before, after, result;
|
| #if NACL_BUILD_SUBARCH == 64
|
| /* Note: If we are running in x86-64, then cpuid must be defined,
|
| @@ -285,9 +286,13 @@ static int asm_HasCPUID(void) {
|
| #endif
|
| result = (before ^ after) & 0x0200000;
|
| return result;
|
| +#else /* NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 */
|
| + return 0;
|
| +#endif
|
| }
|
|
|
| static void asm_CPUID(uint32_t op, volatile uint32_t reg[4]) {
|
| +#if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86
|
| #if defined(__GNUC__)
|
| #if NACL_BUILD_SUBARCH == 64
|
| __asm__ volatile("push %%rbx \n\t" /* save %ebx */
|
| @@ -310,6 +315,14 @@ static void asm_CPUID(uint32_t op, volatile uint32_t reg[4]) {
|
| #else
|
| # error Unsupported platform
|
| #endif
|
| +#else /* NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 */
|
| + UNREFERENCED_PARAMETER(op);
|
| + reg[0] = 0;
|
| + reg[1] = 0;
|
| + reg[2] = 0;
|
| + reg[3] = 0;
|
| + return;
|
| +#endif
|
| }
|
|
|
| /*
|
| @@ -331,6 +344,7 @@ static void asm_CPUID(uint32_t op, volatile uint32_t reg[4]) {
|
| * __cpuidex for MSVC 2008 unconditionally.
|
| */
|
| static void asm_CPUIDx(uint32_t op, volatile uint32_t reg[4], uint32_t ecx) {
|
| +#if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86
|
| #if defined(__GNUC__)
|
| #if NACL_BUILD_SUBARCH == 64
|
| __asm__ volatile("push %%rbx \n\t" /* save %ebx */
|
| @@ -365,6 +379,15 @@ static void asm_CPUIDx(uint32_t op, volatile uint32_t reg[4], uint32_t ecx) {
|
| #else
|
| # error Unsupported platform
|
| #endif
|
| +#else /* NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 */
|
| + UNREFERENCED_PARAMETER(op);
|
| + UNREFERENCED_PARAMETER(ecx);
|
| + reg[0] = 0;
|
| + reg[1] = 0;
|
| + reg[2] = 0;
|
| + reg[3] = 0;
|
| + return;
|
| +#endif
|
| }
|
|
|
| static void CacheCPUVersionID(NaClCPUData* data) {
|
|
|