lib: utils: fdt_domain: add support for root domain region inheritance
PATCH 1/1 lib: utils: fdt_domain: add support for root domain region inheritance
Add the "root-regions" property in domain device-tree nodes to allow domains to inherit all regions from the root domain. This simplifies configuration for domains that need access to most root domain regions with only minor exclusions or additions.
--- docs/domain_support.md | 4 ++++ lib/utils/fdt/fdt_domain.c | 46 +++++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 18 deletions(-)
docs/domain_support.md +4 -0
@@ -159,6 +159,10 @@ The DT properties of a domain instance DT node are as follows: * **possible-harts** (Optional) - The list of CPU DT node phandles for the the domain instance. This list represents the possible HARTs of the domain instance. +* **root-regions** (Optional) - A boolean flag indicating whether this domain + inherits ALL memory regions from the root domain. If this property is present, + the domain will include with all root domain regions and then overlay with + regions specified in the **regions** property for additional restrictions. * **regions** (Optional) - The list of domain memory region DT node phandle and access permissions for the domain instance. Each list entry is a pair of DT node phandle and access permissions. The access permissions are
lib/utils/fdt/fdt_domain.c +28 -18
53 lines not on this page · raw message
Signature · 7 lines
2.48.0 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
Quoted 5 lines · Yu-Chien Peter Lin
Add the "root-regions" property in domain device-tree nodes to allow domains to inherit all regions from the root domain. This simplifies configuration for domains that need access to most root domain regions with only minor exclusions or additions.
Overall, this is a good approach but I suggest renaming this property to "root-regions-inheritance" which takes the following possible values:
1) "all" : Inherit all regions from the root domain
2) "su-only": Inherit regions accessible to S-mode or U-mode from the root domain
3) "none": Inherit no regions from the root domain
From the above, if "root-regions-inheritance" is not set then it is assumed to be "su-only".
Regards,
Anup
Quoted 88 lines
Signed-off-by Yu-Chien Peter Lin <[email protected]>--- docs/domain_support.md | 4 ++++ lib/utils/fdt/fdt_domain.c | 46 +++++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 18 deletions(-)docs/domain_support.md +4
-0@@ -159,6 +159,10 @@ The DT properties of a domain instance DT node are as follows: * **possible-harts** (Optional) - The list of CPU DT node phandles for the the domain instance. This list represents the possible HARTs of the domain instance. +* **root-regions** (Optional) - A boolean flag indicating whether this domain + inherits ALL memory regions from the root domain. If this property is present, + the domain will include with all root domain regions and then overlay with + regions specified in the **regions** property for additional restrictions. * **regions** (Optional) - The list of domain memory region DT node phandle and access permissions for the domain instance. Each list entry is a pair of DT node phandle and access permissions. The access permissions arelib/utils/fdt/fdt_domain.c +28
-19@@ -373,25 +373,35 @@ static int __fdt_parse_domain(const void *fdt, int domain_offset, void *opaque)if (err) goto fail_free_all; -/* -* Copy over root domain memregions which don't allow -* read, write and execute from lower privilege modes. -* -* These root domain memregions without read, write, -* and execute permissions include: -* 1) firmware region protecting the firmware memory -* 2) mmio regions protecting M-mode only mmio devices -*/ -sbi_domain_for_each_memregion (&root, reg) { -if ((reg->flags &SBI_DOMAIN_MEMREGION_SU_READABLE ) || - (reg->flags &SBI_DOMAIN_MEMREGION_SU_WRITABLE ) || - (reg->flags &SBI_DOMAIN_MEMREGION_SU_EXECUTABLE )) -continue ; -if (preg.max_regions <= preg.region_count) { - err =SBI_EINVAL ; - goto fail_free_all; +if (fdt_get_property (fdt, domain_offset,"root-regions" ,NULL )) { +sbi_domain_for_each_memregion (&root, reg) { +if (preg.max_regions <= preg.region_count) { + err =SBI_EINVAL ; + goto fail_free_all; + } +memcpy (&dom->regions[preg.region_count++], reg,sizeof (*reg)); + } + }else { +/* +* Copy over root domain memregions which don't allow +* read, write and execute from lower privilege modes. +* +* These root domain memregions without read, write, +* and execute permissions include: +* 1) firmware region protecting the firmware memory +* 2) mmio regions protecting M-mode only mmio devices +*/ +sbi_domain_for_each_memregion (&root, reg) { +if ((reg->flags &SBI_DOMAIN_MEMREGION_SU_READABLE ) || + (reg->flags &SBI_DOMAIN_MEMREGION_SU_WRITABLE ) || + (reg->flags &SBI_DOMAIN_MEMREGION_SU_EXECUTABLE )) +continue ; +if (preg.max_regions <= preg.region_count) { + err =SBI_EINVAL ; + goto fail_free_all; + } +memcpy (&dom->regions[preg.region_count++], reg,sizeof (*reg)); } -memcpy (&dom->regions[preg.region_count++], reg,sizeof (*reg)); } dom->fw_region_inited = root.fw_region_inited; --2.48.0
--
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
Signature · 3 lines
opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
Hi Anup,
Thanks for suggetion, I'd like to double-check before sending v2 patch.
Quoted 8 lines · Anup Patel
Quoted 5 lines · Yu-Chien Peter Lin
Add the "root-regions" property in domain device-tree nodes to allow domains to inherit all regions from the root domain. This simplifies configuration for domains that need access to most root domain regions with only minor exclusions or additions.
Quoted 6 lines
Overall, this is a good approach but I suggest renaming this property to "root-regions-inheritance" which takes the following possible values:
1) "all" : Inherit all regions from the root domain
2) "su-only": Inherit regions accessible to S-mode or U-mode from the root domain
1. Do you mean:
a) any root regions that have any SU permission bits set regardless of the M‑mode permission bits, or
b) only regions that satisfy SBI_DOMAIN_MEMREGION_SU_ONLY_ACCESS(flags)?
2. For firmware regions marked with SBI_DOMAIN_MEMREGION_FW, should those always be inherited, even when "root-regions-inheritance" is "none" or "su-only"?
Thanks,
Peter Lin
Quoted 7 lines
3) "none": Inherit no regions from the root domain
From the above, if "root-regions-inheritance" is not set then it is assumed to be "su-only".
Regards,
Anup
Signature · 3 lines
opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
Quoted 18 lines · Yu-Chien Peter Lin
Hi Anup,
Thanks for suggetion, I'd like to double-check before sending v2 patch.
Quoted 11 lines · Anup Patel
Quoted 5 lines · Yu-Chien Peter Lin
Add the "root-regions" property in domain device-tree nodes to allow domains to inherit all regions from the root domain. This simplifies configuration for domains that need access to most root domain regions with only minor exclusions or additions.
Overall, this is a good approach but I suggest renaming this property to "root-regions-inheritance" which takes the following possible values:
Quoted 8 lines
Quoted 3 lines
1) "all" : Inherit all regions from the root domain
2) "su-only": Inherit regions accessible to S-mode or U-mode from the root domain1. Do you mean:
a) any root regions that have any SU permission bits set regardless of the M‑mode permission bits, or
b) only regions that satisfySBI_DOMAIN_MEMREGION_SU_ONLY_ACCESS(flags)?
Actually, none of these. Apologies for the confusion.
I meant the current policy of copying select regions from root domain to non-root domain which is only copy regions which have no SU permissions set.
This means the following possible values:
1) "all" : Inherit all regions from the root domain
2) "m-only": Inherit regions of root domain not having any SU permissions set (current policy) which also covers firmware regions.
3) "none": Inherit no regions from the root domain
Quoted 2 lines
2. For firmware regions marked with
SBI_DOMAIN_MEMREGION_FW, should those always be inherited, even when "root-regions-inheritance" is "none" or "su-only"?
Yes, FW regions should always be inherited because these are for OpenSBI itself and OpenSBI is always resident in background.
Regards,
Anup
Signature · 3 lines
opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
Quoted 43 lines · Anup Patel
Quoted 18 lines · Yu-Chien Peter Lin
Hi Anup,
Thanks for suggetion, I'd like to double-check before sending v2 patch.
Quoted 11 lines · Anup Patel
Quoted 5 lines · Yu-Chien Peter Lin
Add the "root-regions" property in domain device-tree nodes to allow domains to inherit all regions from the root domain. This simplifies configuration for domains that need access to most root domain regions with only minor exclusions or additions.
Overall, this is a good approach but I suggest renaming this property to "root-regions-inheritance" which takes the following possible values:
Quoted 8 lines
Quoted 3 lines
1) "all" : Inherit all regions from the root domain
2) "su-only": Inherit regions accessible to S-mode or U-mode from the root domain1. Do you mean:
a) any root regions that have any SU permission bits set regardless of the M‑mode permission bits, or
b) only regions that satisfySBI_DOMAIN_MEMREGION_SU_ONLY_ACCESS(flags)?Actually, none of these. Apologies for the confusion.
I meant the current policy of copying select regions from root domain to non-root domain which is only copy regions which have no SU permissions set.
This means the following possible values:
1) "all" : Inherit all regions from the root domain
2) "m-only": Inherit regions of root domain not having any SU permissions set (current policy) which also covers firmware regions.
3) "none": Inherit no regions from the root domain
Quoted 6 lines
Quoted 2 lines
2. For firmware regions marked with
SBI_DOMAIN_MEMREGION_FW, should those always be inherited, even when "root-regions-inheritance" is "none" or "su-only"?Yes, FW regions should always be inherited because these are for OpenSBI itself and OpenSBI is always resident in background.
Thinking about this more, the "none" option should not be there because m-only regions (including fw regions) are always required for proper functioning of OpenSBI.
Regards,
Anup
Signature · 3 lines
opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi