Hi Stefano,
On 30/03/17 19:37, Stefano Stabellini wrote:
On Thu, 30 Mar 2017, Julien Grall wrote:
+/*
+ * When using ACPI, most of the MMIO regions will be mapped on-demand
+ * in stage-2 page tables for the hardware domain because Xen is not
+ * able to know from the EFI memory map the MMIO regions.
+ */
+static bool try_map_mmio(gfn_t gfn)
+{
+ struct domain *d = current->domain;
+
+ /* For the hardware domain, all MMIOs are mapped with GFN == MFN */
+ mfn_t mfn = _mfn(gfn_x(gfn));
+
+ /*
+ * Device-Tree should already have everything mapped when building
+ * the hardware domain.
+ */
+ if ( acpi_disabled )
+ return false;
+
+ if ( d != hardware_domain )
is_hardware_domain(d)
Will fix it.
+ return false;
+
+ /* The hardware domain can only map permitted MMIO regions */
+ if ( !iomem_access_permitted(d, mfn_x(mfn), mfn_x(mfn) + 1) )
+ return false;
Because of the potential of causing problems with DMA to device MMIO,
I would add a warning here, something like:
dprintk(XENLOG_WARNING, "Mapping gfn=mfn=%"PRI_gfn" to Dom%d\n",
d->domain_id);
I hope that it will help us debug issues when/if we'll actually
encounter such a case.
I don't think this will help us and it will flood the console in
debug-build (there are a lot of MMIO to map).
When SMMUs are not used, DMA to device MMIO will work regardless the
mapping in stage-2.
When SMMUs are in use, you will get a SMMU fault that tells you the
address used. With that you could know the region was not mapped.
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel