Skip to content

Commit

Permalink
i386/cpu: Use CPUCacheInfo.share_level to encode CPUID[0x8000001D].EA…
Browse files Browse the repository at this point in the history
…X[bits 25:14]

CPUID[0x8000001D].EAX[bits 25:14] NumSharingCache: number of logical
processors sharing cache.

The number of logical processors sharing this cache is
NumSharingCache + 1.

After cache models have topology information, we can use
CPUCacheInfo.share_level to decide which topology level to be encoded
into CPUID[0x8000001D].EAX[bits 25:14].

Tested-by: Yongwei Ma <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
Tested-by: Babu Moger <[email protected]>
Reviewed-by: Babu Moger <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
trueptolemy authored and bonzini committed May 22, 2024
1 parent f602eb9 commit 5eb608a
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions target/i386/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,20 +478,12 @@ static void encode_cache_cpuid8000001d(CPUCacheInfo *cache,
uint32_t *eax, uint32_t *ebx,
uint32_t *ecx, uint32_t *edx)
{
uint32_t num_sharing_cache;
assert(cache->size == cache->line_size * cache->associativity *
cache->partitions * cache->sets);

*eax = CACHE_TYPE(cache->type) | CACHE_LEVEL(cache->level) |
(cache->self_init ? CACHE_SELF_INIT_LEVEL : 0);

/* L3 is shared among multiple cores */
if (cache->level == 3) {
num_sharing_cache = 1 << apicid_die_offset(topo_info);
} else {
num_sharing_cache = 1 << apicid_core_offset(topo_info);
}
*eax |= (num_sharing_cache - 1) << 14;
*eax |= max_thread_ids_for_cache(topo_info, cache->share_level) << 14;

assert(cache->line_size > 0);
assert(cache->partitions > 0);
Expand Down

0 comments on commit 5eb608a

Please sign in to comment.