1
1
/*********************************************************
2
* Copyright (C) 1998-2008 VMware, Inc. All rights reserved.
2
* Copyright (C) 1998-2011 VMware, Inc. All rights reserved.
4
4
* This program is free software; you can redistribute it and/or modify it
5
5
* under the terms of the GNU Lesser General Public License as published
97
*----------------------------------------------------------------------
99
* CPUIDSummary_SafeToUseMC0_CTL --
101
* Determines whether it is safe to write to the MCE control
103
* Known safe: P4, All AMD, all family 6 model > 0x1a, except core/atom
107
* True iff it is known to be safe.
112
*----------------------------------------------------------------------
115
CPUIDSummary_SafeToUseMC0_CTL(CPUIDSummary* cpuidSummary)
119
CPUIDSummary_RegsFromCpuid0(&cpuidSummary->id0, &id0);
120
return CPUID_IsVendorAMD(&id0) ||
121
(CPUID_IsVendorIntel(&id0) &&
122
(CPUID_FAMILY_IS_PENTIUM4(cpuidSummary->id1.version) ||
123
(CPUID_FAMILY_IS_P6(cpuidSummary->id1.version) &&
124
(CPUID_EFFECTIVE_MODEL(cpuidSummary->id1.version) ==
125
CPUID_MODEL_NEHALEM_1A ||
126
CPUID_EFFECTIVE_MODEL(cpuidSummary->id1.version) >=
127
CPUID_MODEL_NEHALEM_1E))));
131
/* The following functions return the number of cores per package
132
and set *numThreadsPerCore to the number of hardware threads per core. */
134
CPUIDSummary_VIACoresPerPackage(CPUIDSummary *cpuid,
135
uint32 *numThreadsPerCore)
137
*numThreadsPerCore = 1;
142
CPUIDSummary_AMDCoresPerPackage(CPUIDSummary *cpuid,
143
uint32 *numThreadsPerCore)
145
uint32 version = cpuid->id1.version, numEntries = cpuid->id80.numEntries;
146
*numThreadsPerCore = 1;
147
return CPUID_FAMILY_IS_K8STAR(version) && numEntries >= 0x80000008 ?
148
CPUID_AMDCoresPerPackage(cpuid->id88.ecx) : 1;
152
CPUIDSummary_IntelCoresPerPackage(CPUIDSummary *cpuid,
153
uint32 *numThreadsPerCore)
155
uint32 numCoresPerPackage;
157
*numThreadsPerCore = numCoresPerPackage = 1;
159
* Multi-core processors have the HT feature bit set even if they don't
160
* support HT. The reported number of HT is the total, not per core.
162
if (CPUID_ISSET(1, EDX, HTT, cpuid->id1.edxFeatures)) {
163
*numThreadsPerCore = CPUID_GET(1, EBX, LCPU_COUNT, cpuid->id1.ebx);
164
if (cpuid->id0.numEntries >= 4) {
166
CPUID_IntelCoresPerPackage(__GET_EAX_FROM_CPUID4(0));
168
ASSERT(*numThreadsPerCore % numCoresPerPackage == 0);
170
*numThreadsPerCore /= numCoresPerPackage;
173
return numCoresPerPackage;