]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
x86/physdev: enable PHYSDEVOP_pci_mmcfg_reserved for PVH Dom0
authorRoger Pau Monne <roger.pau@citrix.com>
Thu, 22 Mar 2018 13:59:00 +0000 (14:59 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 23 Mar 2018 09:18:40 +0000 (10:18 +0100)
So that MMCFG regions not present in the MCFG ACPI table can be added
at run time by the hardware domain.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
xen/arch/x86/hvm/hypercall.c
xen/arch/x86/hvm/io.c
xen/arch/x86/physdev.c

index 5742dd1797b47d98e137fa72fea1c3c002ec4dff..85eacd7d338e515c746363d0380638aab10a8bd5 100644 (file)
@@ -89,6 +89,11 @@ static long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         if ( !has_pirq(curr->domain) )
             return -ENOSYS;
         break;
+
+    case PHYSDEVOP_pci_mmcfg_reserved:
+        if ( !has_vpci(curr->domain) )
+            return -ENOSYS;
+        break;
     }
 
     if ( !curr->hcall_compat )
index 04425c064baa70aa100843b49d1ca4ebe56efc00..556810c12627174cbd08ec543f9e2f8dfe0bb4d7 100644 (file)
@@ -507,10 +507,9 @@ static const struct hvm_mmio_ops vpci_mmcfg_ops = {
     .write = vpci_mmcfg_write,
 };
 
-int __hwdom_init register_vpci_mmcfg_handler(struct domain *d, paddr_t addr,
-                                             unsigned int start_bus,
-                                             unsigned int end_bus,
-                                             unsigned int seg)
+int register_vpci_mmcfg_handler(struct domain *d, paddr_t addr,
+                                unsigned int start_bus, unsigned int end_bus,
+                                unsigned int seg)
 {
     struct hvm_mmcfg *mmcfg, *new = xmalloc(struct hvm_mmcfg);
 
@@ -535,9 +534,16 @@ int __hwdom_init register_vpci_mmcfg_handler(struct domain *d, paddr_t addr,
         if ( new->addr < mmcfg->addr + mmcfg->size &&
              mmcfg->addr < new->addr + new->size )
         {
+            int ret = -EEXIST;
+
+            if ( new->addr == mmcfg->addr &&
+                 new->start_bus == mmcfg->start_bus &&
+                 new->segment == mmcfg->segment &&
+                 new->size == mmcfg->size )
+                ret = 0;
             write_unlock(&d->arch.hvm_domain.mmcfg_lock);
             xfree(new);
-            return -EEXIST;
+            return ret;
         }
 
     if ( list_empty(&d->arch.hvm_domain.mmcfg_regions) )
index 380d36f6b9a9fc216879ff41bc99d98b56c0326c..984491c3dcdc1afbb02477d0ac1bef27455a4d56 100644 (file)
@@ -557,6 +557,17 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
 
         ret = pci_mmcfg_reserved(info.address, info.segment,
                                  info.start_bus, info.end_bus, info.flags);
+        if ( !ret && has_vpci(currd) )
+        {
+            /*
+             * For HVM (PVH) domains try to add the newly found MMCFG to the
+             * domain.
+             */
+            ret = register_vpci_mmcfg_handler(currd, info.address,
+                                              info.start_bus, info.end_bus,
+                                              info.segment);
+        }
+
         break;
     }