[PATCH] qemu-kvm: x86: Fix CPU initialization

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

 



Fix regression in CPU initialization caused by merge a5b526135d and try
to avoid this in the future by dropping qemu-kvm specific pc_new_cpu. If
such refactoring is desired, it should go through upstream first.

Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
---

 hw/pc.c |   44 ++++++++++++++++++--------------------------
 1 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 6c19f55..c4117e5 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -839,31 +839,6 @@ int cpu_is_bsp(CPUState *env)
 	return env->cpuid_apic_id == 0;
 }
 
-CPUState *pc_new_cpu(int cpu, const char *cpu_model, int pci_enabled)
-{
-        CPUState *env = cpu_init(cpu_model);
-        if (!env) {
-            fprintf(stderr, "Unable to find x86 CPU definition\n");
-            exit(1);
-        }
-        if (cpu != 0)
-            env->halted = 1;
-        if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
-            env->cpuid_apic_id = env->cpu_index;
-            apic_init(env);
-        }
-        qemu_register_reset(main_cpu_reset, 0, env);
-        if (pci_enabled) {
-            apic_init(env);
-        }
-
-    /* kvm needs this to run after the apic is initialized. Otherwise,
-     * it can access invalid state and crash.
-     */
-    qemu_init_vcpu(env);
-	return env;
-}
-
 /* PC hardware initialisation */
 static void pc_init1(ram_addr_t ram_size,
                      const char *boot_device,
@@ -906,7 +881,24 @@ static void pc_init1(ram_addr_t ram_size,
     }
     
     for(i = 0; i < smp_cpus; i++) {
-	env = pc_new_cpu(i, cpu_model, pci_enabled);
+        env = cpu_init(cpu_model);
+        if (!env) {
+            fprintf(stderr, "Unable to find x86 CPU definition\n");
+            exit(1);
+        }
+        if (cpu != 0)
+            env->halted = 1;
+        if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
+            env->cpuid_apic_id = env->cpu_index;
+            apic_init(env);
+        }
+        qemu_register_reset(main_cpu_reset, 0, env);
+
+        /*
+         * FIXME: qemu-kvm needs this after apic_init as it accesses APIC
+         * structures.
+         */
+        qemu_init_vcpu(env);
     }
 
     vmport_init();
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux