From f2209eb854a016eabc444b45f6d6b1636949141f Mon Sep 17 00:00:00 2001 From: Bharata B Rao Date: Wed, 2 Nov 2011 14:16:08 +0530 Subject: [PATCH] Fix X86 CPU topology in KVM mode 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 Signed-off-by: Bharata B Rao Signed-off-by: Anthony Liguori --- hw/pc.c | 1 - target-i386/helper.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/pc.c b/hw/pc.c index eb4c2d8..25bfa85 100644 --- 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); diff --git a/target-i386/helper.c b/target-i386/helper.c index 6c6a167..2586aff 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -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); -- 2.7.4