Skip to content

Commit

Permalink
vfio-pci: Loosen sanity checks to allow future features
Browse files Browse the repository at this point in the history
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 <alex.williamson@redhat.com>
Cc: qemu-stable@nongnu.org
  • Loading branch information
awilliam committed Jan 8, 2013
1 parent b0223e2 commit 8fc94e5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hw/vfio_pci.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8fc94e5

Please sign in to comment.