Skip to contentSkip to conversation

Apic creation should not depend on pci

PATCH New Gleb Natapov 1 participant 2 messages Jun 10, 2009

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 Apic creation should not depend on pci

It should depend on whether cpu has APIC.

---
 hw/pc.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)
hw/pc.c +1 -5
index 0934778..d5b4112 100644
@@ -878,12 +878,8 @@ static void pc_init1(ram_addr_t ram_size,
         }
         if (i != 0)
             env->halted = 1;
-        if (smp_cpus > 1) {
-            /* XXX: enable it in all cases */
-            env->cpuid_features |= CPUID_APIC;
-        }
         qemu_register_reset(main_cpu_reset, 0, env);
-        if (pci_enabled) {
+        if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
             apic_init(env);
         }
     }
Signature · 1 line
1.6.2.1
#1 lore raw

PATCH v2 2/2 Don't register cpu reset handler for cpu with APIC.

APIC reset handler already resets cpu. Also register cpu_reset handler directly to make it impossible to add additional code to main_cpu_reset() by mistake.

---
 hw/pc.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)
hw/pc.c +3 -7
index d5b4112..0cdc2a2 100644
@@ -751,12 +751,6 @@ static void load_linux(target_phys_addr_t option_rom,
     generate_bootsect(option_rom, gpr, seg, 0);
 }
 
-static void main_cpu_reset(void *opaque)
-{
-    CPUState *env = opaque;
-    cpu_reset(env);
-}
-
 static const int ide_iobase[2] = { 0x1f0, 0x170 };
 static const int ide_iobase2[2] = { 0x3f6, 0x376 };
 static const int ide_irq[2] = { 14, 15 };
@@ -878,9 +872,11 @@ static void pc_init1(ram_addr_t ram_size,
         }
         if (i != 0)
             env->halted = 1;
-        qemu_register_reset(main_cpu_reset, 0, env);
         if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) {
+            /* APIC reset callback resets cpu */
             apic_init(env);
+        } else {
+            qemu_register_reset((QEMUResetHandler*)cpu_reset, 0, env);
         }
     }
 
Signature · 1 line
1.6.2.1