From patchwork Sun Oct 11 18:59:06 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 35721 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6239FB70B3 for ; Mon, 12 Oct 2009 06:04:23 +1100 (EST) Received: from localhost ([127.0.0.1]:42683 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mx3iO-0008AG-SG for incoming@patchwork.ozlabs.org; Sun, 11 Oct 2009 15:04:20 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mx3dU-0006Sb-Rt for qemu-devel@nongnu.org; Sun, 11 Oct 2009 14:59:16 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mx3dQ-0006RL-7L for qemu-devel@nongnu.org; Sun, 11 Oct 2009 14:59:16 -0400 Received: from [199.232.76.173] (port=57417 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mx3dP-0006R2-5i for qemu-devel@nongnu.org; Sun, 11 Oct 2009 14:59:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35989) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mx3dO-0000lz-Kr for qemu-devel@nongnu.org; Sun, 11 Oct 2009 14:59:10 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9BIx9H2009470; Sun, 11 Oct 2009 14:59:09 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9BIx73O014921; Sun, 11 Oct 2009 14:59:08 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 29C4318D416; Sun, 11 Oct 2009 20:59:07 +0200 (IST) From: Gleb Natapov To: kevin@koconnor.net Date: Sun, 11 Oct 2009 20:59:06 +0200 Message-Id: <1255287547-28329-4-git-send-email-gleb@redhat.com> In-Reply-To: <1255287547-28329-1-git-send-email-gleb@redhat.com> References: <1255287547-28329-1-git-send-email-gleb@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 4/5] Make MMIO address page aligned in guest. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org MMIO of some devices are not page aligned, such as some EHCI controllers and virtual Realtek NIC in guest. Current guest bios doesn't guarantee the start address of MMIO page aligned. This may result in failure of device assignment, because KVM only allow to register page aligned memory slots. For example, it fails to assign EHCI controller (its MMIO size is 1KB) with virtual Realtek NIC (its MMIO size is 256Bytes), because MMIO of virtual Realtek NIC in guest starts from 0xf2001000, MMIO of the EHCI controller will starts from 0xf2001400. MMIO addresses in guest are allocated in guest bios. This patch makes MMIO address page aligned in bios, then fixes the issue. qemu-kvm commit ccc9b91a1fdfac4161461a519e10a233f5066d2f Signed-off-by: Gleb Natapov --- src/pciinit.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/src/pciinit.c b/src/pciinit.c index 29b3901..53fbfcf 100644 --- a/src/pciinit.c +++ b/src/pciinit.c @@ -10,6 +10,7 @@ #include "biosvar.h" // GET_EBDA #include "pci_ids.h" // PCI_VENDOR_ID_INTEL #include "pci_regs.h" // PCI_COMMAND +#include "paravirt.h" #define PCI_ROM_SLOT 6 #define PCI_NUM_REGIONS 7 @@ -158,6 +159,12 @@ static void pci_bios_init_device(u16 bdf) *paddr = ALIGN(*paddr, size); pci_set_io_region_addr(bdf, i, *paddr); *paddr += size; + if (kvm_para_available()) { + /* make memory address page aligned */ + /* needed for device assignment on kvm */ + if (!(val & PCI_BASE_ADDRESS_SPACE_IO)) + *paddr = (*paddr + 0xfff) & 0xfffff000; + } } } break;