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

Re: [Xen-devel] [PATCH for-4.9] xen/arm: acpi: Map MMIO on fault in stage-2 page table for the hardware domain



Hi Stefano,

On 30/03/2017 19:55, Stefano Stabellini wrote:
On Thu, 30 Mar 2017, Julien Grall wrote:
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.

Fair enough. Do you think there is any value in adding only one debug
warning, to say that we are mapping MMIOs on trap on this platform? But
today, it would basically be the same as saying "ACPI is enabled".

I think we clearly need some documentation in tree to explain the design of Xen with ACPI and Device Tree. But this is lacking so far :/.

I can have a go when I find some times.

Cheers,

--
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.