1.1 --- a/src/cpu/x86/vm/vm_version_x86.hpp Mon Jul 12 22:27:18 2010 -0700 1.2 +++ b/src/cpu/x86/vm/vm_version_x86.hpp Wed Jul 14 14:29:14 2010 -0700 1.3 @@ -376,10 +376,17 @@ 1.4 static bool is_amd() { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x68747541; } // 'htuA' 1.5 static bool is_intel() { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x756e6547; } // 'uneG' 1.6 1.7 + static bool supports_processor_topology() { 1.8 + return (_cpuid_info.std_max_function >= 0xB) && 1.9 + // eax[4:0] | ebx[0:15] == 0 indicates invalid topology level. 1.10 + // Some cpus have max cpuid >= 0xB but do not support processor topology. 1.11 + ((_cpuid_info.tpl_cpuidB0_eax & 0x1f | _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus) != 0); 1.12 + } 1.13 + 1.14 static uint cores_per_cpu() { 1.15 uint result = 1; 1.16 if (is_intel()) { 1.17 - if (_cpuid_info.std_max_function >= 0xB) { 1.18 + if (supports_processor_topology()) { 1.19 result = _cpuid_info.tpl_cpuidB1_ebx.bits.logical_cpus / 1.20 _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus; 1.21 } else { 1.22 @@ -393,7 +400,7 @@ 1.23 1.24 static uint threads_per_core() { 1.25 uint result = 1; 1.26 - if (is_intel() && _cpuid_info.std_max_function >= 0xB) { 1.27 + if (is_intel() && supports_processor_topology()) { 1.28 result = _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus; 1.29 } else if (_cpuid_info.std_cpuid1_edx.bits.ht != 0) { 1.30 result = _cpuid_info.std_cpuid1_ebx.bits.threads_per_cpu /