* [PATCH] lib: utils: fdt_domain: add support for root domain region inheritance
@ 2026-03-27 4:33 Yu-Chien Peter Lin
0 siblings, 0 replies; only message in thread
From: Yu-Chien Peter Lin @ 2026-03-27 4:33 UTC (permalink / raw)
To: opensbi; +Cc: zong.li, greentime.hu, 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.
Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com>
---
docs/domain_support.md | 4 ++++
lib/utils/fdt/fdt_domain.c | 46 +++++++++++++++++++++++---------------
2 files changed, 32 insertions(+), 18 deletions(-)
diff --git a/docs/domain_support.md b/docs/domain_support.md
index 93186c4a..a88f1cfb 100644
--- a/docs/domain_support.md
+++ b/docs/domain_support.md
@@ -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
diff --git a/lib/utils/fdt/fdt_domain.c b/lib/utils/fdt/fdt_domain.c
index b2fa8633..45407c22 100644
--- a/lib/utils/fdt/fdt_domain.c
+++ b/lib/utils/fdt/fdt_domain.c
@@ -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
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-03-27 4:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-27 4:33 [PATCH] lib: utils: fdt_domain: add support for root domain region inheritance Yu-Chien Peter Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox