[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2] Fix X86 CPU topology in KVM mode

From: bharata . rao
Subject: [Qemu-devel] [PATCH v2] Fix X86 CPU topology in KVM mode
Date: Thu, 8 Sep 2011 11:03:28 +0530

From: Bharata B Rao <address@hidden>

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.

Signed-off-by: Bharata B Rao <address@hidden>
This is the next post of the fix that addresses Jan's comment about
bringing back (smp_cpus > 1) check.

The previous version was posted here:

I coudn't boot a 486 kernel successfully with qemu and hence not
sure if and how this fix breaks i486. Any help from Jan or others
who might have easy means to boot 486 would be good.

 hw/pc.c              |    1 -
 target-i386/helper.c |    5 +++++
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 5bc845a..f9cca4d 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -933,7 +933,6 @@ static CPUState *pc_new_cpu(const char *cpu_model)
     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 5df40d4..139a193 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -1256,6 +1256,11 @@ CPUX86State *cpu_x86_init(const char *cpu_model)
         return NULL;
+    if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
+        env->cpuid_apic_id = env->cpu_index;
+    }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]