i386/cpu: Use CPUCacheInfo.share_level to encode CPUID[4]
authorZhao Liu <zhao1.liu@intel.com>
Wed, 24 Apr 2024 15:49:28 +0000 (23:49 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 22 May 2024 17:56:27 +0000 (19:56 +0200)
commitf602eb925ac5d51d09de6c4b32ba8a5142055492
treedf78330e7c9e73693112a7b3eb5860bd24e2fd47
parent9fcba76ab9c264d06394696c304f2462d9296918
i386/cpu: Use CPUCacheInfo.share_level to encode CPUID[4]

CPUID[4].EAX[bits 25:14] is used to represent the cache topology for
Intel CPUs.

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

And since with the helper max_processor_ids_for_cache(), the filed
CPUID[4].EAX[bits 25:14] (original virable "num_apic_ids") is parsed
based on cpu topology levels, which are verified when parsing -smp, it's
no need to check this value by "assert(num_apic_ids > 0)" again, so
remove this assert().

Additionally, wrap the encoding of CPUID[4].EAX[bits 31:26] into a
helper to make the code cleaner.

Tested-by: Yongwei Ma <yongwei.ma@intel.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Message-ID: <20240424154929.1487382-21-zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/cpu.c
target/i386/cpu.h