Skip to contentSkip to conversation

In-kernel ioapic and bug #2143498

PATCH Fabio Checconi 1 participant 1 message Oct 4, 2008 KVM

lore
Share & tools
lore
#0 lore raw

Hi all,
I can reproduce bug #2143498 (FreeBSD fails to reboot), and it seems
to be related to the ioapic reset; using -no-kvm-irqchip solves the problem, at least here.

Looking at the code I've not found where the in-kernel ioapic is reset; the patch below reloads its state from userspace in the reset handler and seems to make things work, does it make sense?

Thank you.

---

qemu/hw/apic.c +9 -2
index 62cbd98..8db8ca9 100644
@@ -1271,11 +1271,18 @@ static int ioapic_load(QEMUFile *f, void *opaque, int version_id)
 static void ioapic_reset(void *opaque)
 {
     IOAPICState *s = opaque;
-    int i;
+    int i, id = s->id;
 
     memset(s, 0, sizeof(*s));
+    s->id = id;
+    s->base_address = 0xfec00000;
+
     for(i = 0; i < IOAPIC_NUM_PINS; i++)
         s->ioredtbl[i] = 1 << 16; /* mask LVT */
+
+    if (kvm_enabled() && qemu_kvm_irqchip_in_kernel()) {
+        kvm_kernel_ioapic_load_from_user(s);
+    }
 }
 
 static CPUReadMemoryFunc *ioapic_mem_read[3] = {
@@ -1298,8 +1305,8 @@ IOAPICState *ioapic_init(void)
     s = qemu_mallocz(sizeof(IOAPICState));
     if (!s)
         return NULL;
-    ioapic_reset(s);
     s->id = last_apic_id++;
+    ioapic_reset(s);
 
     io_memory = cpu_register_io_memory(0, ioapic_mem_read,
                                        ioapic_mem_write, s);