# HG changeset patch # User kvn # Date 1279142954 25200 # Node ID 079980c86f3308af971a4c039921e4de43c31fbd # Parent 8d5934a77f1072ff4506f02764b65b491f69f2e0 6968646: JVM crashes with SIGFPE during startup Summary: Check that cpuid returns valid values for processor topology (not zeros). Reviewed-by: never, twisti diff -r 8d5934a77f10 -r 079980c86f33 src/cpu/x86/vm/vm_version_x86.hpp --- a/src/cpu/x86/vm/vm_version_x86.hpp Mon Jul 12 22:27:18 2010 -0700 +++ b/src/cpu/x86/vm/vm_version_x86.hpp Wed Jul 14 14:29:14 2010 -0700 @@ -376,10 +376,17 @@ static bool is_amd() { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x68747541; } // 'htuA' static bool is_intel() { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x756e6547; } // 'uneG' + static bool supports_processor_topology() { + return (_cpuid_info.std_max_function >= 0xB) && + // eax[4:0] | ebx[0:15] == 0 indicates invalid topology level. + // Some cpus have max cpuid >= 0xB but do not support processor topology. + ((_cpuid_info.tpl_cpuidB0_eax & 0x1f | _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus) != 0); + } + static uint cores_per_cpu() { uint result = 1; if (is_intel()) { - if (_cpuid_info.std_max_function >= 0xB) { + if (supports_processor_topology()) { result = _cpuid_info.tpl_cpuidB1_ebx.bits.logical_cpus / _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus; } else { @@ -393,7 +400,7 @@ static uint threads_per_core() { uint result = 1; - if (is_intel() && _cpuid_info.std_max_function >= 0xB) { + if (is_intel() && supports_processor_topology()) { result = _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus; } else if (_cpuid_info.std_cpuid1_edx.bits.ht != 0) { result = _cpuid_info.std_cpuid1_ebx.bits.threads_per_cpu /