aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChuang Xu <xuchuangxclwt@bytedance.com>2024-06-11 11:23:14 +0800
committerMichael Tokarev <mjt@tls.msk.ru>2024-07-01 09:49:12 +0300
commit40e04161b33167b17455209504286d2e02fea632 (patch)
tree6345ff815f6c9cb1d9adc747752982db8cded527
parentdf0e72dc86967f0e23d7810652389390c392293f (diff)
downloadqemu-40e04161b33167b17455209504286d2e02fea632.zip
qemu-40e04161b33167b17455209504286d2e02fea632.tar.gz
qemu-40e04161b33167b17455209504286d2e02fea632.tar.bz2
i386/cpu: fixup number of addressable IDs for processor cores in the physical package
When QEMU is started with: -cpu host,host-cache-info=on,l3-cache=off \ -smp 2,sockets=1,dies=1,cores=1,threads=2 Guest can't acquire maximum number of addressable IDs for processor cores in the physical package from CPUID[04H]. When creating a CPU topology of 1 core per package, host-cache-info only uses the Host's addressable core IDs field (CPUID.04H.EAX[bits 31-26]), resulting in a conflict (on the multicore Host) between the Guest core topology information in this field and the Guest's actual cores number. Fix it by removing the unnecessary condition to cover 1 core per package case. This is safe because cores_per_pkg will not be 0 and will be at least 1. Fixes: d7caf13b5fcf ("x86: cpu: fixup number of addressable IDs for logical processors sharing cache") Signed-off-by: Guixiong Wei <weiguixiong@bytedance.com> Signed-off-by: Yipeng Yin <yinyipeng@bytedance.com> Signed-off-by: Chuang Xu <xuchuangxclwt@bytedance.com> Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Message-ID: <20240611032314.64076-1-xuchuangxclwt@bytedance.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> (cherry picked from commit 903916f0a017fe4b7789f1c6c6982333a5a71876) Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> (Mjt: fixup for 8.2 due to other changes in this area past 9.0)
-rw-r--r--target/i386/cpu.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 4dbfbfb..8f318a5 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6097,10 +6097,8 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
if (*eax & 31) {
int host_vcpus_per_cache = 1 + ((*eax & 0x3FFC000) >> 14);
int vcpus_per_socket = cs->nr_cores * cs->nr_threads;
- if (cs->nr_cores > 1) {
- *eax &= ~0xFC000000;
- *eax |= (pow2ceil(cs->nr_cores) - 1) << 26;
- }
+ *eax &= ~0xFC000000;
+ *eax |= (pow2ceil(cs->nr_cores) - 1) << 26;
if (host_vcpus_per_cache > vcpus_per_socket) {
*eax &= ~0x3FFC000;
*eax |= (pow2ceil(vcpus_per_socket) - 1) << 14;