From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Gleb Natapov 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> Subject: [Qemu-devel] [PATCH 4/5] Make MMIO address page aligned in guest. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: kevin@koconnor.net Cc: qemu-devel@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; -- 1.6.3.3