From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mx6JG-0003tc-SE for qemu-devel@nongnu.org; Sun, 11 Oct 2009 17:50:34 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mx6JB-0003tA-FJ for qemu-devel@nongnu.org; Sun, 11 Oct 2009 17:50:33 -0400 Received: from [199.232.76.173] (port=47379 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mx6JB-0003t7-9j for qemu-devel@nongnu.org; Sun, 11 Oct 2009 17:50:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57770) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mx6JA-0001wi-Q3 for qemu-devel@nongnu.org; Sun, 11 Oct 2009 17:50:29 -0400 Date: Sun, 11 Oct 2009 23:48:20 +0200 From: "Michael S. Tsirkin" Message-ID: <20091011214820.GB6411@redhat.com> References: <1255287547-28329-1-git-send-email-gleb@redhat.com> <1255287547-28329-4-git-send-email-gleb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1255287547-28329-4-git-send-email-gleb@redhat.com> Subject: [Qemu-devel] Re: [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: Gleb Natapov Cc: kevin@koconnor.net, qemu-devel@nongnu.org On Sun, Oct 11, 2009 at 08:59:06PM +0200, Gleb Natapov wrote: > 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 This wastes memory for non-assigned devices. I think it's better, and cleaner, to make qemu increase the BAR size up to 4K for assigned devices if it wants page size alignment. > --- > 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 > >