6968646: JVM crashes with SIGFPE during startup
authorkvn
Wed, 14 Jul 2010 14:29:14 -0700
changeset 5927 1e309b7d96b0
parent 5926 a36f90d986b6
child 5928 f6e69b46e9e3
6968646: JVM crashes with SIGFPE during startup Summary: Check that cpuid returns valid values for processor topology (not zeros). Reviewed-by: never, twisti
hotspot/src/cpu/x86/vm/vm_version_x86.hpp
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.hpp	Mon Jul 12 22:27:18 2010 -0700
+++ b/hotspot/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 /