Skip to contentSkip to conversation

xen/arm: Relax hw domain mapping attributes to p2m_mmio_direct_c

PATCH New Edgar E. Iglesias 1 participant 4 messages Jan 31, 2017

lore
Share & tools
lore
#0 lore raw

v3 cover xen/arm: Relax hw domain mapping attributes to p2m_mmio_direct_c

From: "Edgar E. Iglesias" <[email protected]>

This relaxes the hw domains S2 mapping attributes to p2m_mmio_direct_c.

Eventually, I think we should allow guests to execute code from on chip memories. We could follow-up with a patch that allows execution for p2m_mmio_direct_c and p2m_mmio_direct_nc. Does that sound OK?

Cheers,
Edgar

ChangeLog:

v2 -> v3:
* Add rationale and SoB line to commit message of patch #2

v1 -> v2:
* Fixed typo in commit message
* Add rationale in commit message
* Keep p2m attributes plumbing
* Add relaxation of attributes for ACPI hw domains

Edgar E. Iglesias (3):
xen/arm: dt: Relax hw domain mapping attributes to p2m_mmio_direct_c Revert "xen/arm: Map mmio-sram nodes as un-cached memory" xen/arm: acpi: Relax hw domain mapping attributes to p2m_mmio_direct_c

 xen/arch/arm/domain_build.c | 32 +-------------------------------
 xen/arch/arm/p2m.c          |  2 +-
 xen/include/public/memory.h |  6 +++---
 3 files changed, 5 insertions(+), 35 deletions(-)
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

PATCH v3 1/3 xen/arm: dt: Relax hw domain mapping attributes to p2m_mmio_direct_c

From: "Edgar E. Iglesias" <[email protected]>

Since the hardware domain is a trusted domain, we extend the trust to include making final decisions on what attributes to use when mapping memory regions.

For device-tree configured hardware domains, this patch relaxes the hardware domains mapping attributes to p2m_mmio_direct_c. This will allow the hardware domain to control the attributes via its S1 mappings.

---
 xen/arch/arm/domain_build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/domain_build.c +1 -1
index 63301e6..4fc467c 100644
@@ -1330,7 +1330,7 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,
 
 static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 {
-    const p2m_type_t default_p2mt = p2m_mmio_direct_dev;
+    const p2m_type_t default_p2mt = p2m_mmio_direct_c;
     const void *fdt;
     int new_size;
     int ret;
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw

PATCH v3 2/3 Revert "xen/arm: Map mmio-sram nodes as un-cached memory"

In reply to Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

This reverts commit 1e75ed8b64bc1a9b47e540e6f100f17ec6d97f1b.

The default attribute mappings for MMIO have been relaxed, we now rely on the hardware domain to set correct memory attributes.

---
 xen/arch/arm/domain_build.c | 30 ------------------------------
 1 file changed, 30 deletions(-)
xen/arch/arm/domain_build.c +0 -30
index 4fc467c..c97a1f5 100644
@@ -48,20 +48,6 @@ struct map_range_data
     p2m_type_t p2mt;
 };
 
-static const struct dt_device_match dev_map_attrs[] __initconst =
-{
-    {
-        __DT_MATCH_COMPATIBLE("mmio-sram"),
-        __DT_MATCH_PROP("no-memory-wc"),
-        .data = (void *) (uintptr_t) p2m_mmio_direct_dev,
-    },
-    {
-        __DT_MATCH_COMPATIBLE("mmio-sram"),
-        .data = (void *) (uintptr_t) p2m_mmio_direct_nc,
-    },
-    { /* sentinel */ },
-};
-
 //#define DEBUG_11_ALLOCATION
 #ifdef DEBUG_11_ALLOCATION
 # define D11PRINT(fmt, args...) printk(XENLOG_DEBUG fmt, ##args)
@@ -1170,21 +1156,6 @@ static int handle_device(struct domain *d, struct dt_device_node *dev,
     return 0;
 }
 
-static p2m_type_t lookup_map_attr(struct dt_device_node *node,
-                                  p2m_type_t parent_p2mt)
-{
-    const struct dt_device_match *r;
-
-    /* Search and if nothing matches, use the parent's attributes.  */
-    r = dt_match_node(dev_map_attrs, node);
-
-    /*
-     * If this node does not dictate specific mapping attributes,
-     * it inherits its parent's attributes.
-     */
-    return r ? (uintptr_t) r->data : parent_p2mt;
-}
-
 static int handle_node(struct domain *d, struct kernel_info *kinfo,
                        struct dt_device_node *node,
                        p2m_type_t p2mt)
@@ -1275,7 +1246,6 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,
                "WARNING: Path %s is reserved, skip the node as we may re-use the path.\n",
                path);
 
-    p2mt = lookup_map_attr(node, p2mt);
     res = handle_device(d, node, p2mt);
     if ( res)
         return res;
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#3 lore raw

PATCH v3 3/3 xen/arm: acpi: Relax hw domain mapping attributes to p2m_mmio_direct_c

In reply to Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Since the hardware domain is a trusted domain, we extend the trust to include making final decisions on what attributes to use when mapping memory regions.

For ACPI configured hardware domains, this patch relaxes the hardware domains mapping attributes to p2m_mmio_direct_c. This will allow the hardware domain to control the attributes via its S1 mappings.

---
 xen/arch/arm/p2m.c          | 2 +-
 xen/include/public/memory.h | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
xen/arch/arm/p2m.c +1 -1
index 09ceb37..cb5a45d 100644
@@ -1185,7 +1185,7 @@ int map_dev_mmio_region(struct domain *d,
     if ( !(nr && iomem_access_permitted(d, mfn_x(mfn), mfn_x(mfn) + nr - 1)) )
         return 0;
 
-    res = map_mmio_regions(d, gfn, nr, mfn);
+    res = p2m_insert_mapping(d, gfn, nr, mfn, p2m_mmio_direct_c);
     if ( res < 0 )
     {
         printk(XENLOG_G_ERR "Unable to map MFNs [%#"PRI_mfn" - %#"PRI_mfn" in Dom%d\n",
xen/include/public/memory.h +3 -3
index e633047..6eee0c8 100644
@@ -222,9 +222,9 @@ DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t);
                                     * XENMEM_add_to_physmap_batch only. */
 #define XENMAPSPACE_dev_mmio     5 /* device mmio region
                                       ARM only; the region is mapped in
-                                      Stage-2 using the memory attribute
-                                      "Device-nGnRE" (previously named
-                                      "Device" on ARMv7) */
+                                      Stage-2 using the Normal Memory
+                                      Inner/Outer Write-Back Cacheable
+                                      memory attribute. */
 /* ` } */
 
 /*
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel