From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tt28L-0000Oi-18 for qemu-devel@nongnu.org; Wed, 09 Jan 2013 15:20:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tt285-0004TO-AC for qemu-devel@nongnu.org; Wed, 09 Jan 2013 15:20:20 -0500 From: Alex Williamson Date: Wed, 09 Jan 2013 12:19:35 -0700 Message-ID: <20130109191935.906.56344.stgit@bling.home> In-Reply-To: <20130109191807.906.7307.stgit@bling.home> References: <20130109191807.906.7307.stgit@bling.home> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 2/2] vfio-pci: Loosen sanity checks to allow future features List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: aliguori@us.ibm.com Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, qemu-stable@nongnu.org VFIO_PCI_NUM_REGIONS and VFIO_PCI_NUM_IRQS should never have been used in this manner as it locks a specific kernel implementation. Future features may introduce new regions or interrupt entries (VGA may add legacy ranges, AER might add an IRQ for error signalling). Fix this before it gets us into trouble. Signed-off-by: Alex Williamson Cc: qemu-stable@nongnu.org --- hw/vfio_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c index 8ec1faf..c51ae67 100644 --- a/hw/vfio_pci.c +++ b/hw/vfio_pci.c @@ -1837,13 +1837,13 @@ static int vfio_get_device(VFIOGroup *group, const char *name, VFIODevice *vdev) error_report("Warning, device %s does not support reset\n", name); } - if (dev_info.num_regions != VFIO_PCI_NUM_REGIONS) { + if (dev_info.num_regions < VFIO_PCI_CONFIG_REGION_INDEX + 1) { error_report("vfio: unexpected number of io regions %u\n", dev_info.num_regions); goto error; } - if (dev_info.num_irqs != VFIO_PCI_NUM_IRQS) { + if (dev_info.num_irqs < VFIO_PCI_MSIX_IRQ_INDEX + 1) { error_report("vfio: unexpected number of irqs %u\n", dev_info.num_irqs); goto error; }