xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/7] xen/arm: Add support for mapping mmio-sram nodes into dom0
@ 2016-09-23 18:53 Edgar E. Iglesias
  2016-09-23 18:53 ` [PATCH v4 1/7] xen/arm: p2m: Rename p2m_mmio_direct_nc -> p2m_mmio_direct_dev Edgar E. Iglesias
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Edgar E. Iglesias @ 2016-09-23 18:53 UTC (permalink / raw)
  To: xen-devel; +Cc: edgar.iglesias, julien.grall, sstabellini

From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

This series adds support for mapping mmio-sram nodes into dom0
as normal uncached MEMORY with RW perms.

If the no-memory-wc prop is present in the DTB node, we create
DEVICE RW mappings instead.

Comments welcome!

Best regards,
Edgar

ChangeLog:

v3 -> v4:
* Rename p2m_mmio_direct_nc -> p2m_mmio_direct_dev
* Rename p2m_mem_nc p2m_mmio_direct_nc
* Make p2m_mmio_direct_nc non-executable to match p2m_mmio_direct_c
* Fix typos in comments regarding shareability
* Add reference to ARMv8 specs for outer sharability attr
* Add comment describing map_regions_p2mt
* Mention the p2m type inheritance in the commit msg of path #6

v2 -> v3:
* Drop RFC
* Add comment on outer-shareable choice for non-cached mem
* Spellfix existance -> existence
* Add comment on props usage
* Props matching now only supports a single property
* Dropped p2m_access in plumbing for mapping attributes
* Rename un/map_regions to un/map_regions_p2mt
* Add path to mmio-sram device-tree bindings docs in commit msg
* Add a comment on inheriting parent mem attributes
* Dropped the mmio-sram bus

v1 -> v2
* Replace the .map method with a list of match -> map attributes
* Handle no-memory-wc by mapping as DEVICE RW
* Generalize map_regions_rw_cache instead of adding new functions

Edgar E. Iglesias (7):
  xen/arm: p2m: Rename p2m_mmio_direct_nc -> p2m_mmio_direct_dev
  xen/arm: p2m: Add support for normal non-cacheable memory
  xen/arm: Rename and generalize un/map_regions_rw_cache
  xen/device-tree: Add __DT_MATCH macros without braces
  xen/device-tree: Make dt_match_node match props
  xen/arm: domain_build: Plumb for different mapping attributes
  xen/arm: Map mmio-sram nodes as un-cached memory

 xen/arch/arm/domain_build.c   | 90 +++++++++++++++++++++++++++++++++----------
 xen/arch/arm/p2m.c            | 42 ++++++++++++++------
 xen/common/device_tree.c      |  5 ++-
 xen/include/asm-arm/p2m.h     | 24 +++++++-----
 xen/include/asm-arm/page.h    |  1 +
 xen/include/xen/device_tree.h | 20 ++++++++--
 6 files changed, 136 insertions(+), 46 deletions(-)

-- 
2.7.4


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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v4 1/7] xen/arm: p2m: Rename p2m_mmio_direct_nc -> p2m_mmio_direct_dev
  2016-09-23 18:53 [PATCH v4 0/7] xen/arm: Add support for mapping mmio-sram nodes into dom0 Edgar E. Iglesias
@ 2016-09-23 18:53 ` Edgar E. Iglesias
  2016-09-27 23:25   ` Julien Grall
  2016-09-23 18:53 ` [PATCH v4 2/7] xen/arm: p2m: Add support for normal non-cacheable memory Edgar E. Iglesias
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Edgar E. Iglesias @ 2016-09-23 18:53 UTC (permalink / raw)
  To: xen-devel; +Cc: edgar.iglesias, julien.grall, sstabellini

From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Rename p2m_mmio_direct_nc to p2m_mmio_direct_dev to better
express that we are mapping device memory. This will allow us
to use p2m_mmio_direct_nc for Normal Non-Cached mappings.

No functional change.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 xen/arch/arm/p2m.c        | 6 +++---
 xen/include/asm-arm/p2m.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 5c5049f..c3b1233 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -295,7 +295,7 @@ static void p2m_set_permission(lpae_t *e, p2m_type_t t, p2m_access_t a)
     case p2m_iommu_map_rw:
     case p2m_map_foreign:
     case p2m_grant_map_rw:
-    case p2m_mmio_direct_nc:
+    case p2m_mmio_direct_dev:
     case p2m_mmio_direct_c:
         e->p2m.xn = 1;
         e->p2m.write = 1;
@@ -366,7 +366,7 @@ static lpae_t mfn_to_p2m_entry(mfn_t mfn, p2m_type_t t, p2m_access_t a)
 
     switch ( t )
     {
-    case p2m_mmio_direct_nc:
+    case p2m_mmio_direct_dev:
         e.p2m.mattr = MATTR_DEV;
         e.p2m.sh = LPAE_SH_OUTER;
         break;
@@ -1237,7 +1237,7 @@ int map_mmio_regions(struct domain *d,
                      unsigned long nr,
                      mfn_t mfn)
 {
-    return p2m_insert_mapping(d, start_gfn, nr, mfn, p2m_mmio_direct_nc);
+    return p2m_insert_mapping(d, start_gfn, nr, mfn, p2m_mmio_direct_dev);
 }
 
 int unmap_mmio_regions(struct domain *d,
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index 6251b37..b342122 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -91,7 +91,7 @@ typedef enum {
     p2m_invalid = 0,    /* Nothing mapped here */
     p2m_ram_rw,         /* Normal read/write guest RAM */
     p2m_ram_ro,         /* Read-only; writes are silently dropped */
-    p2m_mmio_direct_nc, /* Read/write mapping of genuine MMIO area non-cacheable */
+    p2m_mmio_direct_dev,/* Read/write mapping of genuine Device MMIO area */
     p2m_mmio_direct_c,  /* Read/write mapping of genuine MMIO area cacheable */
     p2m_map_foreign,    /* Ram pages from foreign domain */
     p2m_grant_map_rw,   /* Read/write grant mapping */
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 2/7] xen/arm: p2m: Add support for normal non-cacheable memory
  2016-09-23 18:53 [PATCH v4 0/7] xen/arm: Add support for mapping mmio-sram nodes into dom0 Edgar E. Iglesias
  2016-09-23 18:53 ` [PATCH v4 1/7] xen/arm: p2m: Rename p2m_mmio_direct_nc -> p2m_mmio_direct_dev Edgar E. Iglesias
@ 2016-09-23 18:53 ` Edgar E. Iglesias
  2016-09-27 23:37   ` Julien Grall
  2016-09-23 18:53 ` [PATCH v4 3/7] xen/arm: Rename and generalize un/map_regions_rw_cache Edgar E. Iglesias
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Edgar E. Iglesias @ 2016-09-23 18:53 UTC (permalink / raw)
  To: xen-devel; +Cc: edgar.iglesias, julien.grall, sstabellini

From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Add support for describing normal non-cacheable memory.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 xen/arch/arm/p2m.c         | 19 +++++++++++++++++++
 xen/include/asm-arm/p2m.h  |  1 +
 xen/include/asm-arm/page.h |  1 +
 3 files changed, 21 insertions(+)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index c3b1233..9912658 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -296,6 +296,7 @@ static void p2m_set_permission(lpae_t *e, p2m_type_t t, p2m_access_t a)
     case p2m_map_foreign:
     case p2m_grant_map_rw:
     case p2m_mmio_direct_dev:
+    case p2m_mmio_direct_nc:
     case p2m_mmio_direct_c:
         e->p2m.xn = 1;
         e->p2m.write = 1;
@@ -376,6 +377,24 @@ static lpae_t mfn_to_p2m_entry(mfn_t mfn, p2m_type_t t, p2m_access_t a)
         e.p2m.sh = LPAE_SH_OUTER;
         break;
 
+    /*
+     * ARM ARM: Overlaying the shareability attribute (DDI
+     * 0406C.b B3-1376 to 1377)
+     *
+     * A memory region with a resultant memory type attribute of Normal,
+     * and a resultant cacheability attribute of Inner Non-cacheable,
+     * Outer Non-cacheable, must have a resultant shareability attribute
+     * of Outer Shareable, otherwise shareability is UNPREDICTABLE.
+     *
+     * On ARMv8 shareability is ignored and explicitly treated as Outer
+     * Shareable for Normal Inner Non_cacheable, Outer Non-cacheable.
+     * See the note for table D4-40, in page 1788 of the ARM DDI 0487A.j.
+     */
+    case p2m_mmio_direct_nc:
+        e.p2m.mattr = MATTR_MEM_NC;
+        e.p2m.sh = LPAE_SH_OUTER;
+        break;
+
     default:
         e.p2m.mattr = MATTR_MEM;
         e.p2m.sh = LPAE_SH_INNER;
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index b342122..9708fdc 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -92,6 +92,7 @@ typedef enum {
     p2m_ram_rw,         /* Normal read/write guest RAM */
     p2m_ram_ro,         /* Read-only; writes are silently dropped */
     p2m_mmio_direct_dev,/* Read/write mapping of genuine Device MMIO area */
+    p2m_mmio_direct_nc, /* Read/write mapping of genuine MMIO area non-cacheable */
     p2m_mmio_direct_c,  /* Read/write mapping of genuine MMIO area cacheable */
     p2m_map_foreign,    /* Ram pages from foreign domain */
     p2m_grant_map_rw,   /* Read/write grant mapping */
diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h
index 015ed63..f50fe60 100644
--- a/xen/include/asm-arm/page.h
+++ b/xen/include/asm-arm/page.h
@@ -84,6 +84,7 @@
  *
  */
 #define MATTR_DEV     0x1
+#define MATTR_MEM_NC  0x5
 #define MATTR_MEM     0xf
 
 /* Flags for get_page_from_gva, gvirt_to_maddr etc */
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 3/7] xen/arm: Rename and generalize un/map_regions_rw_cache
  2016-09-23 18:53 [PATCH v4 0/7] xen/arm: Add support for mapping mmio-sram nodes into dom0 Edgar E. Iglesias
  2016-09-23 18:53 ` [PATCH v4 1/7] xen/arm: p2m: Rename p2m_mmio_direct_nc -> p2m_mmio_direct_dev Edgar E. Iglesias
  2016-09-23 18:53 ` [PATCH v4 2/7] xen/arm: p2m: Add support for normal non-cacheable memory Edgar E. Iglesias
@ 2016-09-23 18:53 ` Edgar E. Iglesias
  2016-09-27 23:45   ` Julien Grall
  2016-09-23 18:53 ` [PATCH v4 4/7] xen/device-tree: Add __DT_MATCH macros without braces Edgar E. Iglesias
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Edgar E. Iglesias @ 2016-09-23 18:53 UTC (permalink / raw)
  To: xen-devel; +Cc: edgar.iglesias, julien.grall, sstabellini

From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Rename and generalize un/map_regions_rw_cache into
un/map_regions_p2mt. The new functions take the mapping
attributes as an argument.

No functional change.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 xen/arch/arm/domain_build.c | 18 ++++++++++--------
 xen/arch/arm/p2m.c          | 19 ++++++++++---------
 xen/include/asm-arm/p2m.h   | 23 ++++++++++++++---------
 3 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 35ab08d..f022342 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1518,10 +1518,11 @@ static void acpi_map_other_tables(struct domain *d)
     {
         addr = acpi_gbl_root_table_list.tables[i].address;
         size = acpi_gbl_root_table_list.tables[i].length;
-        res = map_regions_rw_cache(d,
-                                   _gfn(paddr_to_pfn(addr)),
-                                   DIV_ROUND_UP(size, PAGE_SIZE),
-                                   _mfn(paddr_to_pfn(addr)));
+        res = map_regions_p2mt(d,
+                               _gfn(paddr_to_pfn(addr)),
+                               DIV_ROUND_UP(size, PAGE_SIZE),
+                               _mfn(paddr_to_pfn(addr)),
+                               p2m_mmio_direct_c);
         if ( res )
         {
              panic(XENLOG_ERR "Unable to map ACPI region 0x%"PRIx64
@@ -1874,10 +1875,11 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     acpi_create_efi_mmap_table(d, &kinfo->mem, tbl_add);
 
     /* Map the EFI and ACPI tables to Dom0 */
-    rc = map_regions_rw_cache(d,
-                              _gfn(paddr_to_pfn(d->arch.efi_acpi_gpa)),
-                              PFN_UP(d->arch.efi_acpi_len),
-                              _mfn(paddr_to_pfn(virt_to_maddr(d->arch.efi_acpi_table))));
+    rc = map_regions_p2mt(d,
+                          _gfn(paddr_to_pfn(d->arch.efi_acpi_gpa)),
+                          PFN_UP(d->arch.efi_acpi_len),
+                          _mfn(paddr_to_pfn(virt_to_maddr(d->arch.efi_acpi_table))),
+                          p2m_mmio_direct_c);
     if ( rc != 0 )
     {
         printk(XENLOG_ERR "Unable to map EFI/ACPI table 0x%"PRIx64
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 9912658..8e7eb68 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1235,18 +1235,19 @@ static inline int p2m_remove_mapping(struct domain *d,
                              0, p2m_invalid, d->arch.p2m.default_access);
 }
 
-int map_regions_rw_cache(struct domain *d,
-                         gfn_t gfn,
-                         unsigned long nr,
-                         mfn_t mfn)
+int map_regions_p2mt(struct domain *d,
+                     gfn_t gfn,
+                     unsigned long nr,
+                     mfn_t mfn,
+                     p2m_type_t p2mt)
 {
-    return p2m_insert_mapping(d, gfn, nr, mfn, p2m_mmio_direct_c);
+    return p2m_insert_mapping(d, gfn, nr, mfn, p2mt);
 }
 
-int unmap_regions_rw_cache(struct domain *d,
-                           gfn_t gfn,
-                           unsigned long nr,
-                           mfn_t mfn)
+int unmap_regions_p2mt(struct domain *d,
+                       gfn_t gfn,
+                       unsigned long nr,
+                       mfn_t mfn)
 {
     return p2m_remove_mapping(d, gfn, nr, mfn);
 }
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index 9708fdc..a684ed0 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -167,15 +167,20 @@ mfn_t p2m_lookup(struct domain *d, gfn_t gfn, p2m_type_t *t);
 /* Clean & invalidate caches corresponding to a region of guest address space */
 int p2m_cache_flush(struct domain *d, gfn_t start, unsigned long nr);
 
-int map_regions_rw_cache(struct domain *d,
-                         gfn_t gfn,
-                         unsigned long nr,
-                         mfn_t mfn);
-
-int unmap_regions_rw_cache(struct domain *d,
-                           gfn_t gfn,
-                           unsigned long nr,
-                           mfn_t mfn);
+/*
+ * Map a region in the guest p2m with a specific p2m type.
+ * The memory attributes will be derived from the p2m type.
+ */
+int map_regions_p2mt(struct domain *d,
+                     gfn_t gfn,
+                     unsigned long nr,
+                     mfn_t mfn,
+                     p2m_type_t p2mt);
+
+int unmap_regions_p2mt(struct domain *d,
+                       gfn_t gfn,
+                       unsigned long nr,
+                       mfn_t mfn);
 
 int map_dev_mmio_region(struct domain *d,
                         gfn_t gfn,
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 4/7] xen/device-tree: Add __DT_MATCH macros without braces
  2016-09-23 18:53 [PATCH v4 0/7] xen/arm: Add support for mapping mmio-sram nodes into dom0 Edgar E. Iglesias
                   ` (2 preceding siblings ...)
  2016-09-23 18:53 ` [PATCH v4 3/7] xen/arm: Rename and generalize un/map_regions_rw_cache Edgar E. Iglesias
@ 2016-09-23 18:53 ` Edgar E. Iglesias
  2016-09-23 18:53 ` [PATCH v4 5/7] xen/device-tree: Make dt_match_node match props Edgar E. Iglesias
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Edgar E. Iglesias @ 2016-09-23 18:53 UTC (permalink / raw)
  To: xen-devel; +Cc: edgar.iglesias, julien.grall, sstabellini

From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Add __DT_MATCH macros without braces to allow the creation
of match descriptors with multiple combined match options.

Acked-by: Julien Grall <julien.grall@arm.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 xen/include/xen/device_tree.h | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
index 3657ac2..da153a5 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -32,10 +32,15 @@ struct dt_device_match {
     const void *data;
 };
 
-#define DT_MATCH_PATH(p)                { .path = p }
-#define DT_MATCH_TYPE(typ)              { .type = typ }
-#define DT_MATCH_COMPATIBLE(compat)     { .compatible = compat }
-#define DT_MATCH_NOT_AVAILABLE()        { .not_available = 1 }
+#define __DT_MATCH_PATH(p)              .path = p
+#define __DT_MATCH_TYPE(typ)            .type = typ
+#define __DT_MATCH_COMPATIBLE(compat)   .compatible = compat
+#define __DT_MATCH_NOT_AVAILABLE()      .not_available = 1
+
+#define DT_MATCH_PATH(p)                { __DT_MATCH_PATH(p) }
+#define DT_MATCH_TYPE(typ)              { __DT_MATCH_TYPE(typ) }
+#define DT_MATCH_COMPATIBLE(compat)     { __DT_MATCH_COMPATIBLE(compat) }
+#define DT_MATCH_NOT_AVAILABLE()        { __DT_MATCH_NOT_AVAILABLE() }
 
 typedef u32 dt_phandle;
 
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 5/7] xen/device-tree: Make dt_match_node match props
  2016-09-23 18:53 [PATCH v4 0/7] xen/arm: Add support for mapping mmio-sram nodes into dom0 Edgar E. Iglesias
                   ` (3 preceding siblings ...)
  2016-09-23 18:53 ` [PATCH v4 4/7] xen/device-tree: Add __DT_MATCH macros without braces Edgar E. Iglesias
@ 2016-09-23 18:53 ` Edgar E. Iglesias
  2016-09-23 18:53 ` [PATCH v4 6/7] xen/arm: domain_build: Plumb for different mapping attributes Edgar E. Iglesias
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Edgar E. Iglesias @ 2016-09-23 18:53 UTC (permalink / raw)
  To: xen-devel; +Cc: edgar.iglesias, julien.grall, sstabellini

From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Make dt_match_node match for a single existing property.
We only search for the existence of the property, not
for specific values.

Acked-by: Julien Grall <julien.grall@arm.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 xen/common/device_tree.c      | 5 ++++-
 xen/include/xen/device_tree.h | 7 +++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index b39c8ca..1be074b 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -319,7 +319,7 @@ dt_match_node(const struct dt_device_match *matches,
         return NULL;
 
     while ( matches->path || matches->type ||
-            matches->compatible || matches->not_available )
+            matches->compatible || matches->not_available || matches->prop)
     {
         bool_t match = 1;
 
@@ -335,6 +335,9 @@ dt_match_node(const struct dt_device_match *matches,
         if ( matches->not_available )
             match &= !dt_device_is_available(node);
 
+        if ( matches->prop )
+            match &= dt_find_property(node, matches->prop, NULL) != NULL;
+
         if ( match )
             return matches;
         matches++;
diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
index da153a5..0aecbe0 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -29,6 +29,11 @@ struct dt_device_match {
     const char *type;
     const char *compatible;
     const bool_t not_available;
+    /*
+     * Property name to search for. We only search for the property's
+     * existence.
+     */
+    const char *prop;
     const void *data;
 };
 
@@ -36,11 +41,13 @@ struct dt_device_match {
 #define __DT_MATCH_TYPE(typ)            .type = typ
 #define __DT_MATCH_COMPATIBLE(compat)   .compatible = compat
 #define __DT_MATCH_NOT_AVAILABLE()      .not_available = 1
+#define __DT_MATCH_PROP(p)              .prop = p
 
 #define DT_MATCH_PATH(p)                { __DT_MATCH_PATH(p) }
 #define DT_MATCH_TYPE(typ)              { __DT_MATCH_TYPE(typ) }
 #define DT_MATCH_COMPATIBLE(compat)     { __DT_MATCH_COMPATIBLE(compat) }
 #define DT_MATCH_NOT_AVAILABLE()        { __DT_MATCH_NOT_AVAILABLE() }
+#define DT_MATCH_PROP(p)                { __DT_MATCH_PROP(p) }
 
 typedef u32 dt_phandle;
 
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 6/7] xen/arm: domain_build: Plumb for different mapping attributes
  2016-09-23 18:53 [PATCH v4 0/7] xen/arm: Add support for mapping mmio-sram nodes into dom0 Edgar E. Iglesias
                   ` (4 preceding siblings ...)
  2016-09-23 18:53 ` [PATCH v4 5/7] xen/device-tree: Make dt_match_node match props Edgar E. Iglesias
@ 2016-09-23 18:53 ` Edgar E. Iglesias
  2016-09-23 18:53 ` [PATCH v4 7/7] xen/arm: Map mmio-sram nodes as un-cached memory Edgar E. Iglesias
  2016-09-28  1:31 ` [PATCH v4 0/7] xen/arm: Add support for mapping mmio-sram nodes into dom0 Stefano Stabellini
  7 siblings, 0 replies; 13+ messages in thread
From: Edgar E. Iglesias @ 2016-09-23 18:53 UTC (permalink / raw)
  To: xen-devel; +Cc: edgar.iglesias, julien.grall, sstabellini

From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Add plumbing for passing around mapping attributes.
Nodes that don't specifically state their type will inherit
their type from their parent.

This is in preparation for allowing us to differentiate the attributes
for specific device nodes.

We still use the same DEVICE mappings for all nodes so this
patch has no functional change.

Acked-by: Julien Grall <julien.grall@arm.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 xen/arch/arm/domain_build.c | 42 +++++++++++++++++++++++++++++-------------
 1 file changed, 29 insertions(+), 13 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index f022342..0c30121 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -42,6 +42,12 @@ static void __init parse_dom0_mem(const char *s)
 }
 custom_param("dom0_mem", parse_dom0_mem);
 
+struct map_range_data
+{
+    struct domain *d;
+    p2m_type_t p2mt;
+};
+
 //#define DEBUG_11_ALLOCATION
 #ifdef DEBUG_11_ALLOCATION
 # define D11PRINT(fmt, args...) printk(XENLOG_DEBUG fmt, ##args)
@@ -974,7 +980,8 @@ static int map_range_to_domain(const struct dt_device_node *dev,
                                u64 addr, u64 len,
                                void *data)
 {
-    struct domain *d = data;
+    struct map_range_data *mr_data = data;
+    struct domain *d = mr_data->d;
     bool_t need_mapping = !dt_device_for_passthrough(dev);
     int res;
 
@@ -991,10 +998,12 @@ static int map_range_to_domain(const struct dt_device_node *dev,
 
     if ( need_mapping )
     {
-        res = map_mmio_regions(d,
+        res = map_regions_p2mt(d,
                                _gfn(paddr_to_pfn(addr)),
                                DIV_ROUND_UP(len, PAGE_SIZE),
-                               _mfn(paddr_to_pfn(addr)));
+                               _mfn(paddr_to_pfn(addr)),
+                               mr_data->p2mt);
+
         if ( res < 0 )
         {
             printk(XENLOG_ERR "Unable to map 0x%"PRIx64
@@ -1005,7 +1014,8 @@ static int map_range_to_domain(const struct dt_device_node *dev,
         }
     }
 
-    dt_dprintk("  - MMIO: %010"PRIx64" - %010"PRIx64"\n", addr, addr + len);
+    dt_dprintk("  - MMIO: %010"PRIx64" - %010"PRIx64" P2MType=%x\n",
+               addr, addr + len, mr_data->p2mt);
 
     return 0;
 }
@@ -1016,8 +1026,10 @@ static int map_range_to_domain(const struct dt_device_node *dev,
  * the child resources available to domain 0.
  */
 static int map_device_children(struct domain *d,
-                               const struct dt_device_node *dev)
+                               const struct dt_device_node *dev,
+                               p2m_type_t p2mt)
 {
+    struct map_range_data mr_data = { .d = d, .p2mt = p2mt };
     int ret;
 
     if ( dt_device_type_is_equal(dev, "pci") )
@@ -1029,7 +1041,7 @@ static int map_device_children(struct domain *d,
         if ( ret < 0 )
             return ret;
 
-        ret = dt_for_each_range(dev, &map_range_to_domain, d);
+        ret = dt_for_each_range(dev, &map_range_to_domain, &mr_data);
         if ( ret < 0 )
             return ret;
     }
@@ -1045,7 +1057,8 @@ static int map_device_children(struct domain *d,
  *  - Assign the device to the guest if it's protected by an IOMMU
  *  - Map the IRQs and iomem regions to DOM0
  */
-static int handle_device(struct domain *d, struct dt_device_node *dev)
+static int handle_device(struct domain *d, struct dt_device_node *dev,
+                         p2m_type_t p2mt)
 {
     unsigned int nirq;
     unsigned int naddr;
@@ -1111,6 +1124,7 @@ static int handle_device(struct domain *d, struct dt_device_node *dev)
     /* Give permission and map MMIOs */
     for ( i = 0; i < naddr; i++ )
     {
+        struct map_range_data mr_data = { .d = d, .p2mt = p2mt };
         res = dt_device_get_address(dev, i, &addr, &size);
         if ( res )
         {
@@ -1119,12 +1133,12 @@ static int handle_device(struct domain *d, struct dt_device_node *dev)
             return res;
         }
 
-        res = map_range_to_domain(dev, addr, size, d);
+        res = map_range_to_domain(dev, addr, size, &mr_data);
         if ( res )
             return res;
     }
 
-    res = map_device_children(d, dev);
+    res = map_device_children(d, dev, p2mt);
     if ( res )
         return res;
 
@@ -1132,7 +1146,8 @@ static int handle_device(struct domain *d, struct dt_device_node *dev)
 }
 
 static int handle_node(struct domain *d, struct kernel_info *kinfo,
-                       struct dt_device_node *node)
+                       struct dt_device_node *node,
+                       p2m_type_t p2mt)
 {
     static const struct dt_device_match skip_matches[] __initconst =
     {
@@ -1219,7 +1234,7 @@ 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);
 
-    res = handle_device(d, node);
+    res = handle_device(d, node, p2mt);
     if ( res)
         return res;
 
@@ -1241,7 +1256,7 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,
 
     for ( child = node->child; child != NULL; child = child->sibling )
     {
-        res = handle_node(d, kinfo, child);
+        res = handle_node(d, kinfo, child, p2mt);
         if ( res )
             return res;
     }
@@ -1273,6 +1288,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 void *fdt;
     int new_size;
     int ret;
@@ -1292,7 +1308,7 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 
     fdt_finish_reservemap(kinfo->fdt);
 
-    ret = handle_node(d, kinfo, dt_host);
+    ret = handle_node(d, kinfo, dt_host, default_p2mt);
     if ( ret )
         goto err;
 
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 7/7] xen/arm: Map mmio-sram nodes as un-cached memory
  2016-09-23 18:53 [PATCH v4 0/7] xen/arm: Add support for mapping mmio-sram nodes into dom0 Edgar E. Iglesias
                   ` (5 preceding siblings ...)
  2016-09-23 18:53 ` [PATCH v4 6/7] xen/arm: domain_build: Plumb for different mapping attributes Edgar E. Iglesias
@ 2016-09-23 18:53 ` Edgar E. Iglesias
  2016-09-27 23:52   ` Julien Grall
  2016-09-28  1:31 ` [PATCH v4 0/7] xen/arm: Add support for mapping mmio-sram nodes into dom0 Stefano Stabellini
  7 siblings, 1 reply; 13+ messages in thread
From: Edgar E. Iglesias @ 2016-09-23 18:53 UTC (permalink / raw)
  To: xen-devel; +Cc: edgar.iglesias, julien.grall, sstabellini

From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Map mmio-sram nodes as un-cached memory. If the node
has set the no-memory-wc property, we map it as device.

The DTS bindings for mmio-sram nodes can be found in the
Linux tree under Documentation/devicetree/bindings/sram/sram.txt.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 xen/arch/arm/domain_build.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 0c30121..f1c5526 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -48,6 +48,20 @@ 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)
@@ -1145,6 +1159,21 @@ 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)
@@ -1234,6 +1263,7 @@ 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;
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 1/7] xen/arm: p2m: Rename p2m_mmio_direct_nc -> p2m_mmio_direct_dev
  2016-09-23 18:53 ` [PATCH v4 1/7] xen/arm: p2m: Rename p2m_mmio_direct_nc -> p2m_mmio_direct_dev Edgar E. Iglesias
@ 2016-09-27 23:25   ` Julien Grall
  0 siblings, 0 replies; 13+ messages in thread
From: Julien Grall @ 2016-09-27 23:25 UTC (permalink / raw)
  To: Edgar E. Iglesias, xen-devel; +Cc: edgar.iglesias, sstabellini

Hi Edgar,

On 23/09/2016 11:53, Edgar E. Iglesias wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
>
> Rename p2m_mmio_direct_nc to p2m_mmio_direct_dev to better
> express that we are mapping device memory. This will allow us
> to use p2m_mmio_direct_nc for Normal Non-Cached mappings.
>
> No functional change.
>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>

Reviewed-by: Julien Grall <julien.grall@arm.com>

Regards,

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 2/7] xen/arm: p2m: Add support for normal non-cacheable memory
  2016-09-23 18:53 ` [PATCH v4 2/7] xen/arm: p2m: Add support for normal non-cacheable memory Edgar E. Iglesias
@ 2016-09-27 23:37   ` Julien Grall
  0 siblings, 0 replies; 13+ messages in thread
From: Julien Grall @ 2016-09-27 23:37 UTC (permalink / raw)
  To: Edgar E. Iglesias, xen-devel; +Cc: edgar.iglesias, sstabellini

Hi Edgar,

On 23/09/2016 11:53, Edgar E. Iglesias wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
>
> Add support for describing normal non-cacheable memory.
>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>

Acked-by: Julien Grall <julien.grall@arm.com>

Regards,

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 3/7] xen/arm: Rename and generalize un/map_regions_rw_cache
  2016-09-23 18:53 ` [PATCH v4 3/7] xen/arm: Rename and generalize un/map_regions_rw_cache Edgar E. Iglesias
@ 2016-09-27 23:45   ` Julien Grall
  0 siblings, 0 replies; 13+ messages in thread
From: Julien Grall @ 2016-09-27 23:45 UTC (permalink / raw)
  To: Edgar E. Iglesias, xen-devel; +Cc: edgar.iglesias, sstabellini

Hi Edgar,

On 23/09/2016 11:53, Edgar E. Iglesias wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
>
> Rename and generalize un/map_regions_rw_cache into
> un/map_regions_p2mt. The new functions take the mapping
> attributes as an argument.
>
> No functional change.
>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>

Acked-by: Julien Grall <julien.grall@arm.com>

Regards,

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 7/7] xen/arm: Map mmio-sram nodes as un-cached memory
  2016-09-23 18:53 ` [PATCH v4 7/7] xen/arm: Map mmio-sram nodes as un-cached memory Edgar E. Iglesias
@ 2016-09-27 23:52   ` Julien Grall
  0 siblings, 0 replies; 13+ messages in thread
From: Julien Grall @ 2016-09-27 23:52 UTC (permalink / raw)
  To: Edgar E. Iglesias, xen-devel; +Cc: edgar.iglesias, sstabellini

Hi Edgar,

On 23/09/2016 11:53, Edgar E. Iglesias wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
>
> Map mmio-sram nodes as un-cached memory. If the node
> has set the no-memory-wc property, we map it as device.
>
> The DTS bindings for mmio-sram nodes can be found in the
> Linux tree under Documentation/devicetree/bindings/sram/sram.txt.
>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>

Acked-by: Julien Grall <julien.grall@arm.com>

Regards,

-- 
Julien Grall

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 0/7] xen/arm: Add support for mapping mmio-sram nodes into dom0
  2016-09-23 18:53 [PATCH v4 0/7] xen/arm: Add support for mapping mmio-sram nodes into dom0 Edgar E. Iglesias
                   ` (6 preceding siblings ...)
  2016-09-23 18:53 ` [PATCH v4 7/7] xen/arm: Map mmio-sram nodes as un-cached memory Edgar E. Iglesias
@ 2016-09-28  1:31 ` Stefano Stabellini
  7 siblings, 0 replies; 13+ messages in thread
From: Stefano Stabellini @ 2016-09-28  1:31 UTC (permalink / raw)
  To: Edgar E. Iglesias; +Cc: edgar.iglesias, julien.grall, sstabellini, xen-devel

On Fri, 23 Sep 2016, Edgar E. Iglesias wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
> 
> This series adds support for mapping mmio-sram nodes into dom0
> as normal uncached MEMORY with RW perms.
> 
> If the no-memory-wc prop is present in the DTB node, we create
> DEVICE RW mappings instead.
> 
> Comments welcome!

Committed


> Best regards,
> Edgar
> 
> ChangeLog:
> 
> v3 -> v4:
> * Rename p2m_mmio_direct_nc -> p2m_mmio_direct_dev
> * Rename p2m_mem_nc p2m_mmio_direct_nc
> * Make p2m_mmio_direct_nc non-executable to match p2m_mmio_direct_c
> * Fix typos in comments regarding shareability
> * Add reference to ARMv8 specs for outer sharability attr
> * Add comment describing map_regions_p2mt
> * Mention the p2m type inheritance in the commit msg of path #6
> 
> v2 -> v3:
> * Drop RFC
> * Add comment on outer-shareable choice for non-cached mem
> * Spellfix existance -> existence
> * Add comment on props usage
> * Props matching now only supports a single property
> * Dropped p2m_access in plumbing for mapping attributes
> * Rename un/map_regions to un/map_regions_p2mt
> * Add path to mmio-sram device-tree bindings docs in commit msg
> * Add a comment on inheriting parent mem attributes
> * Dropped the mmio-sram bus
> 
> v1 -> v2
> * Replace the .map method with a list of match -> map attributes
> * Handle no-memory-wc by mapping as DEVICE RW
> * Generalize map_regions_rw_cache instead of adding new functions
> 
> Edgar E. Iglesias (7):
>   xen/arm: p2m: Rename p2m_mmio_direct_nc -> p2m_mmio_direct_dev
>   xen/arm: p2m: Add support for normal non-cacheable memory
>   xen/arm: Rename and generalize un/map_regions_rw_cache
>   xen/device-tree: Add __DT_MATCH macros without braces
>   xen/device-tree: Make dt_match_node match props
>   xen/arm: domain_build: Plumb for different mapping attributes
>   xen/arm: Map mmio-sram nodes as un-cached memory
> 
>  xen/arch/arm/domain_build.c   | 90 +++++++++++++++++++++++++++++++++----------
>  xen/arch/arm/p2m.c            | 42 ++++++++++++++------
>  xen/common/device_tree.c      |  5 ++-
>  xen/include/asm-arm/p2m.h     | 24 +++++++-----
>  xen/include/asm-arm/page.h    |  1 +
>  xen/include/xen/device_tree.h | 20 ++++++++--
>  6 files changed, 136 insertions(+), 46 deletions(-)
> 
> -- 
> 2.7.4
> 

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-09-28  1:31 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-23 18:53 [PATCH v4 0/7] xen/arm: Add support for mapping mmio-sram nodes into dom0 Edgar E. Iglesias
2016-09-23 18:53 ` [PATCH v4 1/7] xen/arm: p2m: Rename p2m_mmio_direct_nc -> p2m_mmio_direct_dev Edgar E. Iglesias
2016-09-27 23:25   ` Julien Grall
2016-09-23 18:53 ` [PATCH v4 2/7] xen/arm: p2m: Add support for normal non-cacheable memory Edgar E. Iglesias
2016-09-27 23:37   ` Julien Grall
2016-09-23 18:53 ` [PATCH v4 3/7] xen/arm: Rename and generalize un/map_regions_rw_cache Edgar E. Iglesias
2016-09-27 23:45   ` Julien Grall
2016-09-23 18:53 ` [PATCH v4 4/7] xen/device-tree: Add __DT_MATCH macros without braces Edgar E. Iglesias
2016-09-23 18:53 ` [PATCH v4 5/7] xen/device-tree: Make dt_match_node match props Edgar E. Iglesias
2016-09-23 18:53 ` [PATCH v4 6/7] xen/arm: domain_build: Plumb for different mapping attributes Edgar E. Iglesias
2016-09-23 18:53 ` [PATCH v4 7/7] xen/arm: Map mmio-sram nodes as un-cached memory Edgar E. Iglesias
2016-09-27 23:52   ` Julien Grall
2016-09-28  1:31 ` [PATCH v4 0/7] xen/arm: Add support for mapping mmio-sram nodes into dom0 Stefano Stabellini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).