[PATCH 1/9] pci-assign: Optionally enable 64bit BARs in guest

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

 



To date we've only exposed BARs as 32bit even if the device
physically supports 64bit BARs.  Enable 64bit BARs to be
exposed as such in the guest, which may free up MMIO below
4G should the guest choose to use it.

This adds a new mem64= option to pci-assign, with the
default being off for testing and enablement.  The goal
is to eventually make this enabled by default.

Signed-off-by: Alex Williamson <alex.williamson@xxxxxxxxxx>
---

 hw/device-assignment.c |   13 +++++++++++--
 hw/device-assignment.h |    2 ++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index 7f4a5ec..07ae0a0 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -49,6 +49,7 @@
 #define IORESOURCE_IRQ      0x00000400
 #define IORESOURCE_DMA      0x00000800
 #define IORESOURCE_PREFETCH 0x00002000  /* No side effects */
+#define IORESOURCE_MEM_64   0x00100000
 
 /* #define DEVICE_ASSIGNMENT_DEBUG 1 */
 
@@ -377,6 +378,11 @@ static int assigned_dev_register_regions(PCIRegion *io_regions,
                 ? PCI_BASE_ADDRESS_MEM_PREFETCH
                 : PCI_BASE_ADDRESS_SPACE_MEMORY;
 
+            if ((pci_dev->features & ASSIGNED_DEVICE_USE_MEM64_MASK) &&
+                (cur_region->type & IORESOURCE_MEM_64)) {
+                t |= PCI_BASE_ADDRESS_MEM_TYPE_64;
+            }
+
             /* map physical memory */
             pci_dev->v_addrs[i].u.r_virtbase = mmap(NULL, cur_region->size,
                                                     PROT_WRITE | PROT_READ,
@@ -569,8 +575,9 @@ again:
         rp->valid = 0;
         rp->resource_fd = -1;
         size = end - start + 1;
-        flags &= IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH;
-        if (size == 0 || (flags & ~IORESOURCE_PREFETCH) == 0)
+        flags &= IORESOURCE_IO | IORESOURCE_MEM |
+                 IORESOURCE_PREFETCH | IORESOURCE_MEM_64;
+        if (size == 0 || !(flags & (IORESOURCE_IO | IORESOURCE_MEM)))
             continue;
         if (flags & IORESOURCE_MEM) {
             flags &= ~IORESOURCE_IO;
@@ -1701,6 +1708,8 @@ static PCIDeviceInfo assign_info = {
                         ASSIGNED_DEVICE_USE_IOMMU_BIT, true),
         DEFINE_PROP_BIT("prefer_msi", AssignedDevice, features,
                         ASSIGNED_DEVICE_PREFER_MSI_BIT, true),
+        DEFINE_PROP_BIT("mem64", AssignedDevice, features,
+                        ASSIGNED_DEVICE_USE_MEM64_BIT, false),
         DEFINE_PROP_INT32("bootindex", AssignedDevice, bootindex, -1),
         DEFINE_PROP_STRING("configfd", AssignedDevice, configfd_name),
         DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/device-assignment.h b/hw/device-assignment.h
index 1b4aecc..8ee2274 100644
--- a/hw/device-assignment.h
+++ b/hw/device-assignment.h
@@ -76,9 +76,11 @@ typedef struct {
 
 #define ASSIGNED_DEVICE_USE_IOMMU_BIT	0
 #define ASSIGNED_DEVICE_PREFER_MSI_BIT	1
+#define ASSIGNED_DEVICE_USE_MEM64_BIT	2
 
 #define ASSIGNED_DEVICE_USE_IOMMU_MASK	(1 << ASSIGNED_DEVICE_USE_IOMMU_BIT)
 #define ASSIGNED_DEVICE_PREFER_MSI_MASK	(1 << ASSIGNED_DEVICE_PREFER_MSI_BIT)
+#define ASSIGNED_DEVICE_USE_MEM64_MASK	(1 << ASSIGNED_DEVICE_USE_MEM64_BIT)
 
 typedef struct AssignedDevice {
     PCIDevice dev;

--
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