summaryrefslogtreecommitdiff
path: root/lib/utils/fdt/fdt_domain.c
AgeCommit message (Collapse)Author
2026-05-18lib: utils: fdt_domain: add root-regions-inheritance policyYu-Chien Peter Lin
Introduce root-regions-inheritance DT property to control copying of root domain memregions. Support 'all' and 'm-only' modes, always inheriting firmware and M-only regions; behavior matches m-only policy when property is absent. Signed-off-by: Yu-Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-05-11lib: fdt_domain: Default boot-hart to coldboot HART for multi-domain bootYu-Chien Peter Lin
When "boot-hart" is not specified, dom->boot_hartid was left as -1U, causing domain context switching to fail. Default it to the coldboot HART to enable SMP boot in multi-domain setups, consistent with how next-arg1 is handled. Also update its description in domain_support.md. Signed-off-by: Yu-Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2025-02-12lib: utils:Check that hartid is validRaj Vishwanathan
It is possible that hartid may not be sequential and it should not be validated against SBI_HARTMASK_MAX_BITS. Instead we should check the index of the hartid, hart index, against SBI_HARTMASK_MAX_BITS. Signed-off-by: Raj Vishwanathan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2025-02-11lib: utils: Make the enforce permission bit configurable from DTChao Du
The domain_support.md documentation states that the enforce permission bit (BIT[6]) could be set in the "regions" property of a domain instance DT node. However, this bit is masked in the current implementation. This patch unmasks the bit to make it configurable from DT. Signed-off-by: Chao Du <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-10-25lib: utils/fdt: Use sbi_domain_memregion_init() when parsing domainsAnup Patel
Use sbi_domain_memregion_init() at the time of parsing domains from FDT so that sbi_domain_memregion_init() is always used for setting up all memregions. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Samuel Holland <[email protected]>
2024-08-24lib: utils: fdt_domain: Make opensbi-domain optional in CPU nodeGregor Haas
The domain_support.md documentation states that "the HART to domain instance assignment can be parsed from the device tree using *optional* DT property opensbi-domain in each CPU DT node". However, the current implementation does not treat this parameter as optional when determining which HARTs to assign to a freshly discovered domain from the device tree, causing an effect where every HART in the system must be explicitly assigned to a domain only if a domain is specified in the device tree. Instead, this patch simply ignores CPUs that do not specify a domain, and does not attempt to assign them into the recently discovered domain. Signed-off-by: Gregor Haas <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-24lib: utils/fdt: Constify FDT parsing functionsSamuel Holland
Distinguish between functions which modify the devicetree and those which only extract information from it. Other than the iterators in fdt_domain.c, this is a mechanical conversion. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-08-23lib: utils: fdt_domain: Use consistent device-tree address when next-arg1 is ↵Yu Chien Peter Lin
missing The diagram shown below illustrates the boot-flow involving OP-TEE OS initialization. (1)-----------+ | U-Boot SPL | +------------+ | v (2)-------------------------------------------------------------+ | OpenSBI (fw_dynamic) | | (4)------------------------+ | | | optee dispatcher driver | | +-----------------+-------^---------|-------+------------------+ M-mode | | | ---------+--[trusted domain]---+----.----+--[untrusted domain]------- S-mode | (coldboot domain) | | | v | | v (3)---------------------------+ |(5)----------------------------+ | OP-TEE OS | | | U-Boot | +----------------------------+ | +-----------------------------+ | | | v |(6)----------------------------+ | | Linux | | +-----------------------------+ As OP-TEE OS has device-tree node fixups that need to be passed through to the next boot stages, e.g. the reserved memory node: reserved-memory { #address-cells = <2>; #size-cells = <2>; ranges; optee_core@f1000000 { no-map; reg = <0x0 0xf1000000 // OP-TEE OS base address 0x0 0x01000000>; }; <...> }; Instead of using 0x0 as the default value, allow identical next-arg1 to be used by non-coldboot domain (i.e., untrusted domain) when the property is not provided. Also, update the description of next-arg1 property in the document. Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Alvin Chang <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-09-24lib: sbi: Extend sbi_hartmask to support both hartid and hartindexXiang W
Currently, the sbi_hartmask is indexed by hartid which puts a limit on hartid to be less than SBI_HARTMASK_MAX_BITS. We extend the sbi_hartmask implementation to use hartindex and support updating sbi_hartmask using hartid. This removes the limit on hartid and existing code works largely unmodified. Signed-off-by: Xiang W <[email protected]> Signed-off-by: Anup Patel <[email protected]>
2023-06-05lib: utils/fdt: Use heap in FDT domain parsingAnup Patel
Let's use heap allocation in FDT domain parsing instead of using a fixed size global array. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Andrew Jones <[email protected]>
2023-04-06lib: sbi: Fix how to check whether the domain contains fw_regionXiang W
Because firmware is split into rw/rx segments, it cannot be recorded by a root_fw_region. This problem is solved by adding a flag fw_region_inited to sbi_domain. Signed-off-by: Xiang W <[email protected]> Reviewed-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-02-27lib: sbi: Add system_suspend_allowed domain propertyAndrew Jones
Only privileged domains should be allowed to suspend the entire system. Give the root domain this property by default and allow other domains to be given the property by specifying it in the DT. Signed-off-by: Andrew Jones <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-02-27lib: utils/fdt/fdt_domain: Simplify region access permission checkBin Meng
The region access permission check in __fdt_parse_region() can be simplified as masking SBI_DOMAIN_MEMREGION_{M,SU}_ACCESS_MASK is enough. While we are here, update the confusing comments to match the codes. Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-01-09lib: utils: Disallow non-root domains from adding M-mode regionsHimanshu Chauhan
The M-mode regions can only be added to the root domain. The non-root domains shouldn't be able to add them from FDT. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]> Tested-by: Anup Patel <[email protected]>
2023-01-09lib: utils: Use SU-{R/W/X} flags for region permissions during parsingHimanshu Chauhan
Use the newer SU-{R/W/X} flags for checking and assigning region permissions. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]> Tested-by: Anup Patel <[email protected]>
2023-01-06treewide: Replace TRUE/FALSE with true/falseBin Meng
C language standard uses true/false for the boolean type. Let's switch to that for better language compatibility. Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Anup Patel <[email protected]> Reviewed-by: Samuel Holland <[email protected]> Tested-by: Samuel Holland <[email protected]>
2022-12-09lib: fix __fdt_parse_region()Heinrich Schuchardt
If fdt_getprop() returns NULL, this indicates an error. In this case lenp is set to an error code. But even if lenp = 0 we should not continue. If fdt_getprop() returns a wider value than we expect this is a separate error condition. In both cases the device-tree is invalid. Addresses-Coverity-ID: 1529703 ("Dereference after null check") Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2022-05-14lib: utils: check if CPU node is enabledJan Remes
Ignore CPU nodes in FDT that are not enabled. Signed-off-by: Jan Remes <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2021-05-19lib: utils/fdt: Replace strcmp with strncmpDaniel Schaefer
Use strncmp() instead of strcmp() in __fixup_find_domain_offset() so that it compiles fine when linking with external firmware (such as EDK2). Signed-off-by: Daniel Schaefer <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Abner Chang <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2021-05-19lib: utils/fdt: Don't use sbi_string functionsDaniel Schaefer
When SBI is built by external firmware, we need to use their functions, defined in libfdt_env.h. Just like 2cfd2fc9048806353298a1b967abf985901e36e8 Signed-off-by: Daniel Schaefer <[email protected]> Reviewed-by: Abner Chang <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2021-04-13lib: utils: Copy over restricted root domain memregions to FDT domainsAnup Patel
We should copy over all restricted memregions from the root domain to the domains populated from FDT. These restricted root memregions are typically firmware memregion and M-mode only mmio memregions. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Alistair Francis <[email protected]>
2020-12-16lib: utils: Remove fdt_domain_get() functionAnup Patel
The fdt_domain_get() function is now redundant because the fdt_domains_populate() function can explicitly register new domains using the sbi_domain_register() function. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Alistair Francis <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-12-16lib: utils: Allow FDT domain iteration functions to failAnup Patel
We extend fdt_iterate_each_domain() and fdt_iterate_each_memregion() functions to allow underlying iteration function to fail. This will help us catch more domain misconfiguration issues at boot time. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Alistair Francis <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2020-12-04lib: utils: Add helper routines to populate domains from FDTAnup Patel
We add various helper routines to populate domains, iterate domains, iterate domain memregions, and parse HART to domain assignment from the FDT. These helper routines can be used by platform support code and FDT fixup code. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>