src/cpu/x86/vm/vm_version_x86.hpp

changeset 1977
76efbe666d6c
parent 1907
c18cbe5936b8
child 2002
079980c86f33
     1.1 --- a/src/cpu/x86/vm/vm_version_x86.hpp	Mon Jun 28 14:54:39 2010 -0700
     1.2 +++ b/src/cpu/x86/vm/vm_version_x86.hpp	Tue Jun 29 10:34:00 2010 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates.  All Rights Reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -114,6 +114,14 @@
    1.11      } bits;
    1.12    };
    1.13  
    1.14 +  union TplCpuidBEbx {
    1.15 +    uint32_t value;
    1.16 +    struct {
    1.17 +      uint32_t logical_cpus : 16,
    1.18 +                            : 16;
    1.19 +    } bits;
    1.20 +  };
    1.21 +
    1.22    union ExtCpuid1Ecx {
    1.23      uint32_t value;
    1.24      struct {
    1.25 @@ -211,6 +219,25 @@
    1.26      uint32_t     dcp_cpuid4_ecx; // unused currently
    1.27      uint32_t     dcp_cpuid4_edx; // unused currently
    1.28  
    1.29 +    // cpuid function 0xB (processor topology)
    1.30 +    // ecx = 0
    1.31 +    uint32_t     tpl_cpuidB0_eax;
    1.32 +    TplCpuidBEbx tpl_cpuidB0_ebx;
    1.33 +    uint32_t     tpl_cpuidB0_ecx; // unused currently
    1.34 +    uint32_t     tpl_cpuidB0_edx; // unused currently
    1.35 +
    1.36 +    // ecx = 1
    1.37 +    uint32_t     tpl_cpuidB1_eax;
    1.38 +    TplCpuidBEbx tpl_cpuidB1_ebx;
    1.39 +    uint32_t     tpl_cpuidB1_ecx; // unused currently
    1.40 +    uint32_t     tpl_cpuidB1_edx; // unused currently
    1.41 +
    1.42 +    // ecx = 2
    1.43 +    uint32_t     tpl_cpuidB2_eax;
    1.44 +    TplCpuidBEbx tpl_cpuidB2_ebx;
    1.45 +    uint32_t     tpl_cpuidB2_ecx; // unused currently
    1.46 +    uint32_t     tpl_cpuidB2_edx; // unused currently
    1.47 +
    1.48      // cpuid function 0x80000000 // example, unused
    1.49      uint32_t ext_max_function;
    1.50      uint32_t ext_vendor_name_0;
    1.51 @@ -316,6 +343,9 @@
    1.52    static ByteSize ext_cpuid1_offset() { return byte_offset_of(CpuidInfo, ext_cpuid1_eax); }
    1.53    static ByteSize ext_cpuid5_offset() { return byte_offset_of(CpuidInfo, ext_cpuid5_eax); }
    1.54    static ByteSize ext_cpuid8_offset() { return byte_offset_of(CpuidInfo, ext_cpuid8_eax); }
    1.55 +  static ByteSize tpl_cpuidB0_offset() { return byte_offset_of(CpuidInfo, tpl_cpuidB0_eax); }
    1.56 +  static ByteSize tpl_cpuidB1_offset() { return byte_offset_of(CpuidInfo, tpl_cpuidB1_eax); }
    1.57 +  static ByteSize tpl_cpuidB2_offset() { return byte_offset_of(CpuidInfo, tpl_cpuidB2_eax); }
    1.58  
    1.59    // Initialization
    1.60    static void initialize();
    1.61 @@ -349,7 +379,12 @@
    1.62    static uint cores_per_cpu()  {
    1.63      uint result = 1;
    1.64      if (is_intel()) {
    1.65 -      result = (_cpuid_info.dcp_cpuid4_eax.bits.cores_per_cpu + 1);
    1.66 +      if (_cpuid_info.std_max_function >= 0xB) {
    1.67 +        result = _cpuid_info.tpl_cpuidB1_ebx.bits.logical_cpus /
    1.68 +                 _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus;
    1.69 +      } else {
    1.70 +        result = (_cpuid_info.dcp_cpuid4_eax.bits.cores_per_cpu + 1);
    1.71 +      }
    1.72      } else if (is_amd()) {
    1.73        result = (_cpuid_info.ext_cpuid8_ecx.bits.cores_per_cpu + 1);
    1.74      }
    1.75 @@ -358,7 +393,9 @@
    1.76  
    1.77    static uint threads_per_core()  {
    1.78      uint result = 1;
    1.79 -    if (_cpuid_info.std_cpuid1_edx.bits.ht != 0) {
    1.80 +    if (is_intel() && _cpuid_info.std_max_function >= 0xB) {
    1.81 +      result = _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus;
    1.82 +    } else if (_cpuid_info.std_cpuid1_edx.bits.ht != 0) {
    1.83        result = _cpuid_info.std_cpuid1_ebx.bits.threads_per_cpu /
    1.84                 cores_per_cpu();
    1.85      }

mercurial