From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: PCI IO regions must be power of two Date: Wed, 12 Mar 2008 12:59:55 -0300 Message-ID: <20080312155954.GA26681@dmt> References: <20080311195241.GA14276@dmt> <64F9B87B6B770947A9F8391472E032160B5F851E@ehost011-8.exch011.intermedia.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm-devel To: Uri Lublin Return-path: Content-Disposition: inline In-Reply-To: <64F9B87B6B770947A9F8391472E032160B5F851E@ehost011-8.exch011.intermedia.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org On Wed, Mar 12, 2008 at 08:39:11AM -0700, Uri Lublin wrote: > From: Marcelo Tosatti > > > >Index: kvm-userspace.hotplug2/qemu/hw/pci.c > >=================================================================== > >--- kvm-userspace.hotplug2.orig/qemu/hw/pci.c > >+++ kvm-userspace.hotplug2/qemu/hw/pci.c > >@@ -236,6 +236,13 @@ void pci_register_io_region(PCIDevice *p > > > > if ((unsigned int)region_num >= PCI_NUM_REGIONS) > > return; > >+ > >+ /* IO region size must be power of two */ > >+ if (type == PCI_ADDRESS_SPACE_IO && (size & (size-1))) { > > Why only for PCI IO regions ? Don't PCI memory regions have the same restriction ? Yes, they do. > >+ size = size << 1; > >+ size &= size-1; > > That would not make size a power of 2 (e.g. size=7 --> size=12). Right, sorry. I'll resend a patch to have virtio allocate IO regions with proper sizes and warn if the IO _or_ memory region are not power of two, as Anthony suggested. Since this problem is only visible with device hotplug (QEMU will allocate the region offsets properly during initialization) I'll wait for that to hit the tree. Thanks. ------------------------------------------------------------------------- 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/