return CACHE_DESCRIPTOR_UNAVAILABLE;
}
+static const CPUCaches legacy_intel_cpuid2_cache_info;
+
/* Encode cache info for CPUID[2] */
static void encode_cache_cpuid2(X86CPU *cpu,
uint32_t *eax, uint32_t *ebx,
uint32_t *ecx, uint32_t *edx)
{
CPUX86State *env = &cpu->env;
- CPUCaches *caches = &env->cache_info_cpuid2;
+ const CPUCaches *caches;
int l1d, l1i, l2, l3;
bool unmatched = false;
*eax = 1; /* Number of CPUID[EAX=2] calls required */
*ebx = *ecx = *edx = 0;
+ if (env->enable_legacy_cpuid2_cache) {
+ caches = &legacy_intel_cpuid2_cache_info;
+ } else {
+ caches = &env->cache_info_cpuid4;
+ }
+
l1d = cpuid2_cache_descriptor(caches->l1d_cache, &unmatched);
l1i = cpuid2_cache_descriptor(caches->l1i_cache, &unmatched);
l2 = cpuid2_cache_descriptor(caches->l2_cache, &unmatched);
.share_level = CPU_TOPOLOGY_LEVEL_CORE,
};
-/*FIXME: CPUID leaf 2 descriptor is inconsistent with CPUID leaf 4 */
-static CPUCacheInfo legacy_l2_cache_cpuid2 = {
- .type = UNIFIED_CACHE,
- .level = 2,
- .size = 2 * MiB,
- .line_size = 64,
- .associativity = 8,
- .share_level = CPU_TOPOLOGY_LEVEL_INVALID,
-};
-
-
/*FIXME: CPUID leaf 0x80000006 is inconsistent with leaves 2 & 4 */
static CPUCacheInfo legacy_l2_cache_amd = {
.type = UNIFIED_CACHE,
"CPU model '%s' doesn't support legacy-cache=off", name);
return;
}
- env->cache_info_cpuid2 = env->cache_info_cpuid4 = env->cache_info_amd =
- *cache_info;
+ env->cache_info_cpuid4 = env->cache_info_amd = *cache_info;
} else {
/* Build legacy cache information */
- env->cache_info_cpuid2.l1d_cache = &legacy_l1d_cache;
- env->cache_info_cpuid2.l1i_cache = &legacy_l1i_cache;
if (!cpu->consistent_cache) {
- env->cache_info_cpuid2.l2_cache = &legacy_l2_cache_cpuid2;
- } else {
- env->cache_info_cpuid2.l2_cache = &legacy_l2_cache;
+ env->enable_legacy_cpuid2_cache = true;
}
- env->cache_info_cpuid2.l3_cache = &legacy_l3_cache;
env->cache_info_cpuid4.l1d_cache = &legacy_l1d_cache;
env->cache_info_cpuid4.l1i_cache = &legacy_l1i_cache;