Mercurial > hg > truffle
comparison src/cpu/x86/vm/vm_version_x86.hpp @ 1647:079980c86f33
6968646: JVM crashes with SIGFPE during startup
Summary: Check that cpuid returns valid values for processor topology (not zeros).
Reviewed-by: never, twisti
author | kvn |
---|---|
date | Wed, 14 Jul 2010 14:29:14 -0700 |
parents | 76efbe666d6c |
children | a83b0246bb77 |
comparison
equal
deleted
inserted
replaced
1646:8d5934a77f10 | 1647:079980c86f33 |
---|---|
374 static bool is_P6() { return cpu_family() >= 6; } | 374 static bool is_P6() { return cpu_family() >= 6; } |
375 | 375 |
376 static bool is_amd() { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x68747541; } // 'htuA' | 376 static bool is_amd() { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x68747541; } // 'htuA' |
377 static bool is_intel() { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x756e6547; } // 'uneG' | 377 static bool is_intel() { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x756e6547; } // 'uneG' |
378 | 378 |
379 static bool supports_processor_topology() { | |
380 return (_cpuid_info.std_max_function >= 0xB) && | |
381 // eax[4:0] | ebx[0:15] == 0 indicates invalid topology level. | |
382 // Some cpus have max cpuid >= 0xB but do not support processor topology. | |
383 ((_cpuid_info.tpl_cpuidB0_eax & 0x1f | _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus) != 0); | |
384 } | |
385 | |
379 static uint cores_per_cpu() { | 386 static uint cores_per_cpu() { |
380 uint result = 1; | 387 uint result = 1; |
381 if (is_intel()) { | 388 if (is_intel()) { |
382 if (_cpuid_info.std_max_function >= 0xB) { | 389 if (supports_processor_topology()) { |
383 result = _cpuid_info.tpl_cpuidB1_ebx.bits.logical_cpus / | 390 result = _cpuid_info.tpl_cpuidB1_ebx.bits.logical_cpus / |
384 _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus; | 391 _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus; |
385 } else { | 392 } else { |
386 result = (_cpuid_info.dcp_cpuid4_eax.bits.cores_per_cpu + 1); | 393 result = (_cpuid_info.dcp_cpuid4_eax.bits.cores_per_cpu + 1); |
387 } | 394 } |
391 return result; | 398 return result; |
392 } | 399 } |
393 | 400 |
394 static uint threads_per_core() { | 401 static uint threads_per_core() { |
395 uint result = 1; | 402 uint result = 1; |
396 if (is_intel() && _cpuid_info.std_max_function >= 0xB) { | 403 if (is_intel() && supports_processor_topology()) { |
397 result = _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus; | 404 result = _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus; |
398 } else if (_cpuid_info.std_cpuid1_edx.bits.ht != 0) { | 405 } else if (_cpuid_info.std_cpuid1_edx.bits.ht != 0) { |
399 result = _cpuid_info.std_cpuid1_ebx.bits.threads_per_cpu / | 406 result = _cpuid_info.std_cpuid1_ebx.bits.threads_per_cpu / |
400 cores_per_cpu(); | 407 cores_per_cpu(); |
401 } | 408 } |