summaryrefslogtreecommitdiff
path: root/lib/utils/fdt
AgeCommit message (Collapse)Author
2026-07-22lib: utils/irqchip/aplic: add MSI mode support with IMSIC parent linkingPawandeep Oza
Add parent_unique_id fields to struct aplic_data for IMSIC parent linking in MSI mode. Store parent IMSIC unique_id during FDT parsing of the APLIC node. Add aplic_is_msi_mode() complementing aplic_is_direct_mode() to consolidate delivery mode detection. Add APLIC_TARGET_EIID() macro for packing the EIID field into the TARGET register. Add parent_unique_id and parent_irq_map fields to struct aplic_data. parent_unique_id identifies the upstream IMSIC irqchip device resolved via sbi_irqchip_find_device() during hwirq_setup. parent_irq_map is a per-source array allocated at cold init time to track the EIID assigned by the IMSIC for each APLIC source. Restore aplic_writel_msicfg() and re-introduce MSI address register programming in aplic_init(), gated on aplic_is_msi_mode(). Set the DOMAINCFG_DM bit to switch the hardware to MSI delivery mode when no IDC structures are present. Add aplic_program_msi_target() to pack hart_index, guest_index, and EIID into the APLIC_TARGET register. Add aplic_write_msi() as the sbi_irqchip write_msi callback that extracts EIID and hart_index from the MSI message and calls aplic_program_msi_target(). Add aplic_msi_callback() as the MSI receive callback that dispatches to sbi_irqchip_process_hwirq() on the APLIC chip. Extend aplic_hwirq_setup() with an MSI path that resolves the parent IMSIC chip by parent_unique_id, registers an MSI route via sbi_irqchip_register_msi(), and stores the allocated EIID in parent_irq_map for the source being configured. Extend aplic_hwirq_set_affinity() with an MSI path that delegates affinity reprogramming to the parent IMSIC chip via sbi_irqchip_set_affinity() using the stored parent_irq_map entry. Guard warm_init, process_hwirqs, and hwirq_eoi with early returns in MSI mode as interrupt delivery and acknowledgement are handled by the IMSIC in that configuration. Signed-off-by: Oza Pawandeep <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-06-12platform: generic: Optimize extensions_init() to parse ISA extensions onceAnup Patel
Instead of parsing ISA extensions separately for each hart in the generic_extensions_init() function, it is better to parse ISA extensions for all available harts in the cold boot path. Also, this allows us to remove fdt_isa_bitmap from scratch space and directly initialize "extensions" in struct sbi_hart_features for each hart. Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
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]>
2026-03-22lib: utils/irqchip: Add unique_id to plic, aplic, and imsic dataAnup Patel
Add a 32-bit unique ID to plic, aplic, and imsic data which can be used to differentiate multiple irqchip devices. Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2026-03-09lib: fdt_helper: Removed unnecessary dt parsing checkVictoriano Morales
The check for the address being different from 0 for the UART, PLIC, APLIC and IMSIC dt nodes is unnnecessary and could skip valid nodes. Signed-off-by: Victoriano Morales <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2025-12-08lib: utils: Use SBI_DOMAIN_MMIO to check MMIO device permissionsSamuel Holland
Drivers or platforms may create memory regions with the MMIO flag set that contain S-mode-accessible MMIO devices. This is strictly correct and should be allowed, along with the existing default case of S-mode-accessible MMIO devices appearing in non-MMIO memory regions. When passed SBI_DOMAIN_MMIO, sbi_domain_check_addr() will perform the correct set of permission checks. Signed-off-by: Samuel Holland <[email protected]> Reviewed-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-07-23lib: utils: fdt: fix "ranges" translationMax Hsu
According to the Device Tree Spec, Chapter 2.3.8 "ranges" [1]: The parent address size will be determined from the #address-cells property of the node that defines the parent’s address space. In fdt_translate_address(), which considered the parent address size is the child address size, this commit fix the two address sizes and parsing the address independently. Signed-off-by: Max Hsu <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2025-06-16lib: utils: Fix fdt_parse_aclint_node() for non-contiguous hartidAnup Patel
Currently, the fdt_parse_aclint_node() does not handle non-contiguous hartid correctly and returns incorrect first_hartid and hart_count. This is because the for-loop in fdt_parse_aclint_node() skips a hartid for which hartindex is not available (aka corresponding CPU DT node is disabled). For example, on a platform with 4 HARTs (hartid 0, 1, 2, and 3) where CPU DT nodes with hartid 0 and 2 are disabled, the fdt_parse_aclint_node() returns first_hartid = 1 and hart_count = 3 which is incorrect. To address the above issue, drop the sbi_hartid_to_hartindex() check from the for-loop of fdt_parse_aclint_node(). Fixes: 5e90e54a1a53 ("lib: utils:Check that hartid is valid") Reported-by: Maria Mbaye <[email protected]> Signed-off-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2025-06-16lib: utils/irqchip: always parse msi information for each aplic deviceInochi Amaoto
OpenSBI only parses MSI information of the first next level subdomain for now, which makes the root domain misconfigured in some case: 1. the msi is not enabled on the first subdomain of the root domain, but other subdomains enable MSI. 2. the root domain is set as direct mode, but its subdomains enable MSI. So it is needed to parse all child of the root domain, Otherwise, the some non-root domains are broken. As the specification says, it is safe to parse the MSI information of all its subdomain and write the msiaddrcfg register of the non root domain as they are read only. Parse the aplic MSI information recursively for all aplic device. Reviewed-by: Anup Patel <[email protected]> Signed-off-by: Inochi Amaoto <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2025-05-20lib: utils: fdt: Claim Zicntr if time CSR emulation is possibleYao Zi
OpenSBI is capable of emulating time CSR through an external timer for HARTs that don't implement a full Zicntr extension. Let's add Zicntr extension in the FDT if CSR emulation is active. This avoids hardcoding the extension in the devicetree, which may confuse pre-SBI bootloaders. Signed-off-by: Yao Zi <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2025-04-24lib: sbi: Set the scratch allocation to alignment to cacheline sizeRaj Vishwanathan
Set the scratch allocation alignment to cacheline size specified by riscv,cbom-block-size in the DTS file to avoid two atomic variables from the same cache line causing livelock on some platforms. If the cacheline is not specified, we set it a default value. Signed-off-by: Raj Vishwanathan <[email protected]> Reviewed-by: Anup Patel <[email protected]> Reviewed-by: Samuel Holland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2025-04-23lib: utils/fdt: Remove fdt_match_node()Samuel Holland
This function has been obsoleted by the fdt_driver library and is no longer used. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2025-04-15lib: sbi: Remove unnecessary SBI_INIT_LIST_HEADXiang W
No need to initialise the nodes to be added to the linked list Signed-off-by: Xiang W <[email protected]> Reviewed-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
2025-03-26lib: utils: Make sure that hartid and the scratch are alignedRaj Vishwanathan
Harts associated with an ACLINT_MSWI need not have sequential hartids. It is insufficient to use first_hartid and hart_count. To account for non-sequential hart ids, include the empty hart-ids' generate hart-count. Signed-off-by: Raj Vishwanathan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2025-03-24lib: utils/fdt: Respect compatible string fallback prioritySamuel Holland
When matching drivers to DT nodes, always match all drivers against the first compatible string before considering fallback compatible strings. This ensures the most specific match is always selected, regardless of the order of the drivers or match structures, as long as no compatible string appears in multiple match structures. Fixes: 1ccc52c427f3 ("lib: utils/fdt: Add helpers for generic driver initialization") Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2025-02-19lib: utils/fdt: Allocate fdt_pmu_evt_select on the heapSamuel Holland
This reduces .bss size by 8 KiB, and should reduce overall memory usage since most platforms will have significantly fewer than 512 entries in this table. At the same time, it removes the fixed table size limit. Since the table is only used within fdt_pmu.c, instead of updating the extern declaration, make the table local to this file. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2025-02-19lib: utils/fdt: Remove redundant PMU property length checksSamuel Holland
If a property value is too small, len will be zero after the division on the next line, so the property will be ignored. This is the same behavior as when the length check fails. Furthermore, the first two length checks were already ineffectual, because each item in those arrays is 12 bytes long, not 8. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2025-02-12lib: utils: Initialize miscellaneous drivers in one passSamuel Holland
For driver subsystems that are not tightly integrated into the OpenSBI init sequence, it is not important that the drivers are initialized in any particular order. By putting all of these drivers in one array, they can all be initialized with a single pass through the devicetree. This saves about 10 ms of boot time on HiFive Unmatched. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2025-02-12lib: utils/fdt: Remove fdt_find_match()Samuel Holland
Now that all drivers are using the fdt_driver functions for initialization, this function is unused and can be removed. Signed-off-by: Samuel Holland <[email protected]> Reviewed-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]>
2025-02-11lib: utils/fdt: update fdt_parse_aplic_node()Huang Borong
1. Initialize struct imsic_data imsic to 0 at definition to prevent the use of uninitialized memory, ensuring the variable starts with known values. 2. Remove the redundant memset call on the "aplic" parameter since the memory for aplic is allocated using sbi_zalloc() by the caller irqchip_aplic_cold_init(), which guarantees it is already set to 0. Signed-off-by: Huang Borong <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-12-21lib: utils: Mark RPMI drivers as experimentalSamuel Holland
These drivers were merged on an experimental basis without the RPMI specification being frozen. As a result, they may not be compatible with the frozen version of the RPMI protocol. Additionally, their devicetree bindings have not been reviewed and are subject to change. Warn the user that these drivers make no compatibility guarantees, and that their behavior and devicetree bindings may change incompatibly in future versions of OpenSBI. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-12-06lib: utils/fdt: Allow dynamic registration of FDT fixup callbacksAnup Patel
It should possible to fixup FDT from any part of OpenSBI so add fdt_register_general_fixup() which allows dynamic registration of FDT fixup callbacks. Signed-off-by: Anup Patel <[email protected]>
2024-11-28lib: utils/fdt: Add helpers for generic driver initializationSamuel Holland
Currently, each driver subsystem contains its own code for matching drivers against the platform's devicetree blob. This bloats firmware size because the several FDT scanning loops are almost exact copies of each other, and is confusing because the loops do have some subtle differences. Furthermore, the existing match algorithm is inefficient: it scans the FDT structure separately for each driver in the list. A faster algorithm scans the FDT blob only once, matching all drivers in the list for each `compatible` property seen. Add new helpers implementing this faster algorithm. Since they must iterate through the list of drivers, the driver structure cannot be opaque. However, since the driver list is an array of pointers, the `struct fdt_driver` can be embedded in a subsystem-specific driver structure if needed. These three helpers cover all existing use cases for driver initialization within OpenSBI. An additional benefit of centralized driver initialization is the consistent use of fdt_node_is_enabled(). Signed-off-by: Samuel Holland <[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-09-26lib: sbi: Update sbi_domain_is_assigned_hart() to take a hart indexSamuel Holland
This removes redundant hartid to hartindex conversions from four call sites and provides a net reduction in code size. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[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]>
2024-07-23lib: utils/fdt: Add support for parsing riscv,isa-extensionsConor Dooley
A new property has been added, with an extensive rationale at [1], that can be used in place of "riscv,isa" to indicate what extensions are supported by a given platform that is a list of strings rather than a single string. There are some differences between the new property, "riscv,isa-extensions" and the incumbent "riscv,isa" - chief among them for the sake of parsing being the list of strings, as opposed to a string. Another advantage is strictly defined meanings for each string in a dt-binding, rather than deriving meaning from RVI standards. This may likely to some divergence over time, but, at least for now, there's no relevant differences between the two for an M-Mode program. Add support for the new property in OpenSBI, prioritising it, before falling back to the, now deprecated, "riscv,isa" property if it is not present. Link: https://lore.kernel.org/all/20230702-eats-scorebook-c951f170d29f@spud/ [1] Signed-off-by: Conor Dooley <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-06-05lib: utils/fdt: Fix DT property for APLIC delegationAnup Patel
During Linux AIA driver review, the APLIC DT property for interrupt delegation was renamed to "riscv,delegation" so let's use the new DT property name and fallback to old DT property name if the new DT property name is not available. Fixes: 34612193af92 ("lib: utils/irqchip: Add FDT based driver for APLIC") Signed-off-by: Anup Patel <[email protected]>
2024-04-10lib: utils: check correct value in fdt_node_offset_by_compatibleHeinrich Schuchardt
After calling fdt_node_offset_by_compatible() we must check its return value and not an unrelated value. Addresses-Coverity-ID: 1584993 Logically dead code Fixes: 67ce5a763cfb ("platform: generic: Add support for specify coldboot harts in DT") Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-02-20platform: generic: Add support for specify coldboot harts in DTCheng Yang
Added support for the generic platform to specify the set of coldboot hart in DT. If not specified in DT, all harts are allowed to coldboot as before. The functions related to sbi_hartmask are not available before coldboot, so I used bitmap, and added a new bitmap_test() function to test whether a certain bit of the bitmap is set. Signed-off-by: Cheng Yang <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-27lib: utils/timer: mtimer: only use regname for aclintInochi Amaoto
The parser will fail if the timer is clint timer and has regname property. As the regname is only meaningful for aclint, it is more robust to only check regname for aclint timer. Fixes: 6112d58 ("lib: utils/fdt: Allow to use reg-names when parsing ACLINT") Signed-off-by: Inochi Amaoto <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-19lib: utils/irqchip: Add shared MMIO region for PLIC in root domainAnup Patel
On platforms with Smepmp, the MMIO regions accessed by M-mode need to be explicitly marked with M-mode only read/write or shared (both (M-mode and S-mode) read/write permission. If the above is not done then runtime PLIC access from M-mode on platforms with Smepmp will result in access fault when further results in CPU hotplug not working. Signed-off-by: Anup Patel <[email protected]>
2023-12-19lib: sbi: Using one array to define the name of extensionsYong-Xuan Wang
Define an array sbi_hart_ext to map extension ID and name , and use it for ISA parsing and printing out the supported extensions. Signed-off-by: Yong-Xuan Wang <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-11lib: utils/fdt: Allow to use reg-names when parsing ACLINTInochi Amaoto
Currently, the fdt_parse_aclint_node() follows a fixed order to parse ACLINT timer. This may cause the undesirable result when the ACLINT device does not support mtime without adding an empty entry for it in the DT. To be robust, make fdt_parse_aclint_node() support "reg-names" property, so it can parse the DT in an order independent way. For compatibility, fdt_parse_aclint_node() only use "reg-names" when parsing ACLINT timer, and will fallback to the old way if "reg-names" property is not found. Link: https://lore.kernel.org/all/20231114-skedaddle-precinct-66c8897227bb@squawk/ Signed-off-by: Inochi Amaoto <[email protected]> Reviewed-by: Anup patel <[email protected]>
2023-12-06lib: utils: fdt_pmu: Do not iterate over the fdt_pmu_evt_select tableYu Chien Peter Lin
The valid entry count is tracking by hw_event_count so there is no need to check the whole table. Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-06lib: utils: fdt_pmu: Make the fdt_pmu_evt_select table global variableYu Chien Peter Lin
To allow platform override pmu_init() filling the translation table fdt_pmu_evt_select[] when PMU node doesn't provide such information, we need to share the table and its entry counter with other .c file. We also define the structures of PMU property in fdt_helper.h, so we can initialize the mappings in arrays. Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-06lib: utils: fdt_fixup: Allow preserving PMU propertiesYu Chien Peter Lin
Add a Kconfig option to control PMU fixup, so the next stage software can dump the PMU node including event mapping information for debugging purposes. Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-06sbi: sbi_pmu: Improve sbi_pmu_init() error handlingYu Chien Peter Lin
This patch makes the following changes: - As sbi_platform_pmu_init() returns a negative error code on failure, let sbi_pmu_init() print out the error code with sbi_dprintf(). - In order to distinguish the SBI_EFAIL error returned by sbi_pmu_add_*_counter_map(), return SBI_ENOENT to indicate that fdt_pmu_setup() failed to locate "riscv,pmu" node, and generic_pmu_init() ignores such case. Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Anup Patel <[email protected]> Reviewed-by: Lad Prabhakar <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2023-11-17lib: sbi: Add Zkr in hart extensionsHeinrich Schuchardt
- Add Zkr as extension in sbi_hart_extensions enum - Return "zkr" string for Zkr extension from sbi_hart_extension_id2string Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-10-06lib: utils: Simplify SET_ISA_EXT_MAP()Heinrich Schuchardt
The define is hard to read. The continue statement does not do what was intended. * Remove do {} while (false); * Change the name to set_multi_letter_ext - Other local macros are lower case too. - Refer to the fact that this is only used for multi-letter extensions. Addresses-Coverity-ID: 1568359 Unexpected control flow Fixes: d72f5f17478d ("lib: utils: Add detection of Smepmp from ISA string in FDT") Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-10-06lib: utils/fdt: simplify dt_parse_isa_extensionsHeinrich Schuchardt
hart_exts == NULL can only occur if offset and node address lead to an overflow resulting in exactly NULL. As we don't catch other values of overflow it does not make sense to treat this one as special. Addresses-Coverity-ID: 1568355 Logically dead code Addresses-Coverity-ID: 1568358 Logically dead code Fixes: 6259b2ec2d09 ("lib: utils/fdt: Fix fdt_parse_isa_extensions() implementation") Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Xiang W <[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-08-06lib: utils/fdt: Fix fdt_parse_isa_extensions() implementationAnup Patel
Currently, the fdt_parse_isa_extensions() tries to parse the ISA string once for each HART. This ISA string parsing can fail for secondary HARTs if the FDT memory is already overwritten by the supervisor OS. To tackle this issue, we improve the fdt_parse_isa_extensions() implementation to pre-parse ISA string for all HARTs during cold boot. Fixes: d72f5f17478d ("lib: utils: Add detection of Smepmp from ISA string in FDT") Signed-off-by: Anup Patel <[email protected]> Tested-By: Mayuresh Chitale<[email protected]>
2023-07-13lib: utils: Add detection of Smepmp from ISA string in FDTHimanshu Chauhan
- Add function to parse ISA string in FDT. - Set Smepmp feature bit in extensions if "smepmp" string is found in ISA string. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-06-15platform/lib: Set no-map attribute on all PMP regionsAlexandre Ghiti
This reverts commit 6966ad0abe70 ("platform/lib: Allow the OS to map the regions that are protected by PMP"). It was thought at the time of this commit that allowing the kernel to map PMP protected regions was safe but it is actually not: for example, the hibernation process will try to access any linear mapping page and then will fault on such mapped PMP regions [1]. Another issue is that the device tree specification [2] states that a !no-map region must be declared as EfiBootServicesData/Code in the EFI memory map which would make the PMP protected regions reclaimable by the kernel. And to circumvent this, RISC-V edk2 diverges from the DT specification to declare those regions as EfiReserved. The no-map attribute was removed to allow the kernel to use hugepages larger than 2MB to map the linear mapping to improve the performance but actually a recent talk from Mike Rapoport [3] stated that the performance benefit was marginal. For all those reasons, let's mark all the PMP protected regions as "no-map". [1] https://lore.kernel.org/linux-riscv/CAAYs2=gQvkhTeioMmqRDVGjdtNF_vhB+vm_1dHJxPNi75YDQ_Q@mail.gmail.com/ [2] "3.5.4 /reserved-memory and UEFI" https://github.com/devicetree-org/devicetree-specification/releases/download/v0.4-rc1/devicetree-specification-v0.4-rc1.pdf [3] https://lwn.net/Articles/931406/ Signed-off-by: Alexandre Ghiti <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Xiang W <[email protected]>