public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH]: Fix memory corruption in-kernel IOAPIC emulation
@ 2008-01-29 23:24 Chris Lalancette
       [not found] ` <479FB5C6.6060204-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Chris Lalancette @ 2008-01-29 23:24 UTC (permalink / raw)
  To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

[-- Attachment #1: Type: text/plain, Size: 1246 bytes --]

All,
     Attached is a patch that fixes the first (of at least a couple) migration
problem that I am running into.  Basically, using the setup I described in my
last post, I was always getting "Disabling IRQ #11" once the guest reached the
destination side, and then no further activity.  Dumping the APIC on both the
source and destination side revealed something interesting:

Source:
APIC 0x2
 (pad is 0x0
 IOAPIC state:
    base_address: 0xfec00000
    ioregsel:     0x2e
    id:           0x0
    irr:          0x0
    pad:          0x0

Destination:
APIC 0x2
 (pad is 0x38)
 IOAPIC state:
    base_address: 0xf2001000
    ioregsel:     0x2e
    id:           0x0
    irr:          0x78872f3d
    pad:          0x38

You'll notice that the base_address and irr are completely bogus on the
destination side.  Although KVM_CREATE_IRQCHIP does the right thing on the
destination side when first creating the "incoming" guest, the base_address and
other fields get blown away with bogus data during the restore.  The attached
patch fixes this by only restoring the bits that we know were saved on the
source side (i.e. what's in qemu/hw/apic.c:ioapic_save()).

Signed-off-by: Chris Lalancette <clalance-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

[-- Attachment #2: kvm-60-fix-ioapic-migration.patch --]
[-- Type: text/x-patch, Size: 995 bytes --]

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 8f94a0b..b07ea3a 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1314,6 +1314,9 @@ static int kvm_vm_ioctl_get_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
 static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
 {
 	int r;
+	int i;
+	struct kvm_ioapic *kioapic;
+	struct kvm_ioapic_state *uioapic;
 
 	r = 0;
 	switch (chip->chip_id) {
@@ -1328,9 +1331,16 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
 			sizeof(struct kvm_pic_state));
 		break;
 	case KVM_IRQCHIP_IOAPIC:
-		memcpy(ioapic_irqchip(kvm),
-			&chip->chip.ioapic,
-			sizeof(struct kvm_ioapic_state));
+		kioapic = ioapic_irqchip(kvm);
+		uioapic = &chip->chip.ioapic;
+
+		kioapic->id = uioapic->id;
+		kioapic->ioregsel = uioapic->ioregsel;
+
+		for (i = 0; i < IOAPIC_NUM_PINS; i++) {
+			kioapic->redirtbl[i].bits = uioapic->redirtbl[i].bits;
+		}
+
 		break;
 	default:
 		r = -EINVAL;

[-- Attachment #3: Type: text/plain, Size: 228 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

[-- Attachment #4: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-02-05 15:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-29 23:24 [PATCH]: Fix memory corruption in-kernel IOAPIC emulation Chris Lalancette
     [not found] ` <479FB5C6.6060204-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2008-01-30 10:04   ` Avi Kivity
     [not found]     ` <47A04BB3.7020302-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-30 13:28       ` Chris Lalancette
2008-01-30 16:39       ` Chris Lalancette
     [not found]         ` <47A0A830.8040900-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2008-01-30 16:54           ` Avi Kivity
2008-01-30 21:03   ` Chris Lalancette
     [not found]     ` <47A0E613.7080408-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2008-01-31  7:24       ` Avi Kivity
     [not found]         ` <47A177BE.6020300-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-02-05 15:58           ` Chris Lalancette

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox