From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Lalancette Subject: [PATCH]: Fix memory corruption in-kernel IOAPIC emulation Date: Tue, 29 Jan 2008 18:24:54 -0500 Message-ID: <479FB5C6.6060204@redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020207090500020307060607" To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org This is a multi-part message in MIME format. --------------020207090500020307060607 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 --------------020207090500020307060607 Content-Type: text/x-patch; name="kvm-60-fix-ioapic-migration.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="kvm-60-fix-ioapic-migration.patch" 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; --------------020207090500020307060607 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- 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/ --------------020207090500020307060607 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kvm-devel mailing list kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/kvm-devel --------------020207090500020307060607--