[PATCH] kernel vfio: PCI ROM size calculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The original code calculated the real size of the ROM and passed it to
QEMU which tried to do pci_register_bar and failed with error message
"ERROR: PCI region size must be pow2".

The example card is PCIe Intel E1000E with the ROM size 0x9c00.

pci_resource_len seems to be a proper solution.

Signed-off-by: Alexey Kardashevskiy <aik@xxxxxxxxx>
---
 drivers/vfio/pci/vfio_pci.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index b2f1f3a..6d4a783 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -234,12 +234,9 @@ static long vfio_pci_ioctl(void *device_data,
 			 * this gives the user an easy way to determine whether
 			 * there's anything here w/o trying to read it. */
 			if (info.index == VFIO_PCI_ROM_REGION_INDEX) {
-				void __iomem *io;
-				size_t size;
-
-				io = pci_map_rom(pdev, &size);
-				info.size = io ? size : 0;
-				pci_unmap_rom(pdev, io);
+				info.size = pci_resource_len(pdev,
+						PCI_ROM_RESOURCE);
+				info.flags |= VFIO_PCI_ROM_REGION_INDEX;
 			} else if (flags & IORESOURCE_MEM) {
 				info.size = pci_resource_len(pdev, info.index);
 				info.flags |= (VFIO_REGION_INFO_FLAG_WRITE |

-- 
Alexey
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux