Current {un}map_mmio_regions implementation has a maximum number of loops to
perform before giving up and returning to the caller. This is an issue when
mapping large MMIO regions when building the hardware domain. In order to
solve it, introduce a wrapper around {un}map_mmio_regions that takes care of
calling process_pending_softirqs between consecutive {un}map_mmio_regions
calls.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>
---
Changes since v2:
- Pull the code into a separate patch.
- Use an unbounded for loop with break conditions.
return 0;
}
+int modify_identity_mmio(struct domain *d, unsigned long pfn,
+ unsigned long nr_pages, 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;
+}
+
/*
* Local variables:
* mode: C
*/
int p2m_get_mem_access(struct domain *d, gfn_t gfn, xenmem_access_t *access);
+/*
+ * Helper for {un}mapping large MMIO regions, it will take care of calling
+ * process_pending_softirqs between consecutive {un}map_mmio_regions calls.
+ */
+int modify_identity_mmio(struct domain *d, unsigned long pfn,
+ unsigned long nr_pages, bool map);
+
#endif /* _XEN_P2M_COMMON_H */