]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
xen/mm: move modify_identity_mmio to global file
authorRoger Pau Monne <roger.pau@citrix.com>
Tue, 11 Apr 2017 07:41:10 +0000 (08:41 +0100)
committerRoger Pau Monne <roger.pau@citrix.com>
Tue, 11 Apr 2017 07:41:10 +0000 (08:41 +0100)
Mostly code motion, this function will be needed in other parts apart from PVH
Dom0 build. Also note that the __init attribute is dropped.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/hvm/dom0_build.c
xen/common/memory.c
xen/include/xen/p2m-common.h

index db9be87612b25b97ad1b7067d7b61283b7fe5002..07bfa0be46e488444017a8673b84b5de7f473611 100644 (file)
@@ -59,32 +59,6 @@ static struct acpi_madt_interrupt_override __initdata *intsrcovr;
 static unsigned int __initdata acpi_nmi_sources;
 static struct acpi_madt_nmi_source __initdata *nmisrc;
 
-static int __init modify_identity_mmio(struct domain *d, unsigned long pfn,
-                                       unsigned long nr_pages, const bool map)
-{
-    int rc;
-
-    for ( ; ; )
-    {
-        rc = (map ? map_mmio_regions : unmap_mmio_regions)
-             (d, _gfn(pfn), nr_pages, _mfn(pfn));
-        if ( rc == 0 )
-            break;
-        if ( rc < 0 )
-        {
-            printk(XENLOG_WARNING
-                   "Failed to identity %smap [%#lx,%#lx) for d%d: %d\n",
-                   map ? "" : "un", pfn, pfn + nr_pages, d->domain_id, rc);
-            break;
-        }
-        nr_pages -= rc;
-        pfn += rc;
-        process_pending_softirqs();
-    }
-
-    return rc;
-}
-
 /* Populate a HVM memory range using the biggest possible order. */
 static int __init pvh_populate_memory_range(struct domain *d,
                                             unsigned long start,
index 52879e74387ce6050e6304a629efe996294fc4d2..66a5232fd18934380db351b693dde848ea67a0b4 100644 (file)
@@ -1438,6 +1438,38 @@ int prepare_ring_for_helper(
     return 0;
 }
 
+int modify_identity_mmio(struct domain *d, unsigned long pfn,
+                         unsigned long nr_pages, const bool map)
+{
+    int rc;
+
+    /*
+     * Make sure this function is only used by the hardware domain, because it
+     * can take an arbitrary long time, and could DoS the whole system.
+     */
+    ASSERT(is_hardware_domain(d));
+
+    for ( ; ; )
+    {
+        rc = (map ? map_mmio_regions : unmap_mmio_regions)
+             (d, _gfn(pfn), nr_pages, _mfn(pfn));
+        if ( rc == 0 )
+            break;
+        if ( rc < 0 )
+        {
+            printk(XENLOG_WARNING
+                   "Failed to identity %smap [%#lx,%#lx) for d%d: %d\n",
+                   map ? "" : "un", pfn, pfn + nr_pages, d->domain_id, rc);
+            break;
+        }
+        nr_pages -= rc;
+        pfn += rc;
+        process_pending_softirqs();
+    }
+
+    return rc;
+}
+
 /*
  * Local variables:
  * mode: C
index 8cd5a6b503939779b825f113b304f75072760566..869630231ccff914aeb8cacd295963dc65b82c2d 100644 (file)
@@ -13,4 +13,8 @@ int unmap_mmio_regions(struct domain *d,
                        unsigned long nr,
                        mfn_t mfn);
 
+
+int modify_identity_mmio(struct domain *d, unsigned long pfn,
+                         unsigned long nr_pages, const bool map);
+
 #endif /* _XEN_P2M_COMMON_H */