Fix X86 CPU topology in KVM mode
authorBharata B Rao <bharata.rao@gmail.com>
Wed, 2 Nov 2011 08:46:08 +0000 (14:16 +0530)
committerAnthony Liguori <aliguori@us.ibm.com>
Wed, 2 Nov 2011 12:55:05 +0000 (07:55 -0500)
apic id returned to guest kernel in ebx for cpuid(function=1) depends on
CPUX86State->cpuid_apic_id which gets populated after the cpuid information
is cached in the host kernel. This results in broken CPU topology in guest.

Fix this by setting cpuid_apic_id before cpuid information is passed to
the host kernel. This is done by moving the setting of cpuid_apic_id
to cpu_x86_init() where it will work for both KVM as well as TCG modes.

Acked-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Bharata B Rao <bharata.rao@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/pc.c
target-i386/helper.c

diff --git a/hw/pc.c b/hw/pc.c
index eb4c2d8770c1aeac5db9d8f9a987cfe4c824de68..25bfa8502226560b0ad206d3cc0e571727c801fa 100644 (file)
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -941,7 +941,6 @@ static CPUState *pc_new_cpu(const char *cpu_model)
         exit(1);
     }
     if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
-        env->cpuid_apic_id = env->cpu_index;
         env->apic_state = apic_init(env, env->cpuid_apic_id);
     }
     qemu_register_reset(pc_cpu_reset, env);
index 6c6a1675df4e81010e7b8577d2d3f228d65cd7a9..2586aff700d178bc7b05fc7d59da7f06691ce7fd 100644 (file)
@@ -1257,6 +1257,7 @@ CPUX86State *cpu_x86_init(const char *cpu_model)
         cpu_x86_close(env);
         return NULL;
     }
+    env->cpuid_apic_id = env->cpu_index;
     mce_init(env);
 
     qemu_init_vcpu(env);