xen/arm: Add support for mapping mmio-sram nodes into dom0
v4 cover xen/arm: Add support for mapping mmio-sram nodes into dom0
From: "Edgar E. Iglesias" <[email protected]>
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(-)
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 1/7 xen/arm: p2m: Rename p2m_mmio_direct_nc -> p2m_mmio_direct_dev
From: "Edgar E. Iglesias" <[email protected]>
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.
--- xen/arch/arm/p2m.c | 6 +++--- xen/include/asm-arm/p2m.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
xen/arch/arm/p2m.c +3 -3
@@ -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,
xen/include/asm-arm/p2m.h +1 -1
@@ -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 */
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 1/7] xen/arm: p2m: Rename p2m_mmio_direct_nc -> p2m_mmio_direct_dev
Hi Edgar,
Quoted 9 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Rename
p2m_mmio_direct_nctop2m_mmio_direct_devto better express that we are mapping device memory. This will allow us to usep2m_mmio_direct_ncfor Normal Non-Cached mappings.No functional change.
Signed-off-by Edgar E. Iglesias <[email protected]>
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 2/7 xen/arm: p2m: Add support for normal non-cacheable memory
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Add support for describing normal non-cacheable memory.
--- 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(+)
xen/arch/arm/p2m.c +19 -0
@@ -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 ;
xen/include/asm-arm/p2m.h +1 -0
@@ -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 */
xen/include/asm-arm/page.h +1 -0
@@ -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 */
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 2/7] xen/arm: p2m: Add support for normal non-cacheable memory
Hi Edgar,
Quoted 5 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Add support for describing normal non-cacheable memory.
Signed-off-by Edgar E. Iglesias <[email protected]>
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 3/7 xen/arm: Rename and generalize un/map_regions_rw_cache
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
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.
--- 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(-)
xen/arch/arm/domain_build.c +10 -8
@@ -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
xen/arch/arm/p2m.c +10 -9
@@ -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); }
xen/include/asm-arm/p2m.h +14 -9
@@ -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,
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 3/7] xen/arm: Rename and generalize un/map_regions_rw_cache
Hi Edgar,
Quoted 9 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
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 <[email protected]>
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 4/7 xen/device-tree: Add __DT_MATCH macros without braces
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Add __DT_MATCH macros without braces to allow the creation of match descriptors with multiple combined match options.
--- xen/include/xen/device_tree.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
xen/include/xen/device_tree.h +9 -4
@@ -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 ;
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 5/7 xen/device-tree: Make dt_match_node match props
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Make dt_match_node match for a single existing property. We only search for the existence of the property, not for specific values.
--- xen/common/device_tree.c | 5 ++++- xen/include/xen/device_tree.h | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
xen/common/device_tree.c +4 -1
@@ -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++;
xen/include/xen/device_tree.h +7 -0
@@ -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 ;
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 6/7 xen/arm: domain_build: Plumb for different mapping attributes
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
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.
--- xen/arch/arm/domain_build.c | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-)
xen/arch/arm/domain_build.c +29 -13
@@ -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;
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 7/7 xen/arm: Map mmio-sram nodes as un-cached memory
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
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.
--- xen/arch/arm/domain_build.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
xen/arch/arm/domain_build.c +30 -0
@@ -48,6 +48,20 @@ struct map_range_datap2m_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;
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 7/7] xen/arm: Map mmio-sram nodes as un-cached memory
Hi Edgar,
Quoted 9 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
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 <[email protected]>
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 9 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
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
Quoted 40 lines
Best regards,
EdgarChangeLog:
v3 -> v4:
* Renamep2m_mmio_direct_nc->p2m_mmio_direct_dev
* Renamep2m_mem_ncp2m_mmio_direct_nc
* Makep2m_mmio_direct_ncnon-executable to matchp2m_mmio_direct_c
* Fix typos in comments regarding shareability
* Add reference to ARMv8 specs for outer sharability attr
* Add comment describingmap_regions_p2mt
* Mention the p2m type inheritance in the commit msg of path #6v2 -> 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
* Droppedp2m_accessin 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 busv1 -> v2
* Replace the .map method with a list of match -> map attributes
* Handle no-memory-wc by mapping as DEVICE RW
* Generalizemap_regions_rw_cacheinstead of adding new functionsEdgar E. Iglesias (7):
xen/arm: p2m: Renamep2m_mmio_direct_nc->p2m_mmio_direct_devxen/arm: p2m: Add support for normal non-cacheable memory xen/arm: Rename and generalize un/map_regions_rw_cache xen/device-tree: Add__DT_MATCHmacros without braces xen/device-tree: Makedt_match_nodematch props xen/arm:domain_build: Plumb for different mapping attributes xen/arm: Map mmio-sram nodes as un-cached memory
Quoted 11 lines
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(-)Signature · 1 line
2.7.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel