summaryrefslogtreecommitdiff
path: root/include
AgeCommit message (Collapse)Author
2024-01-10include: sbi: Add TINFO debug trigger CSRHimanshu Chauhan
Add the missing TINFO debug trigger CSR. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2024-01-10include: sbi: Introduce common endianess conversion macroHimanshu Chauhan
Introduce cpu_to_lle and lle_to_cpu macros which invoke correct word length cpu_to_le<64/32> conversion based on __riscv_xlen. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-27include: Bump-up version to 1.4v1.4Anup Patel
This patch updates OpenSBI version to 1.4 as part of release preparation. Signed-off-by: Anup Patel <[email protected]> Signed-off-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: sbi: Remove the SBI_ETRAP error codeAnup Patel
The SBI_ETRAP error code was introduced only for doing trap redirection in generic sbi_ecall_handler(). Now the trap redirection is moved into sbi_ecall_legacy.c and SBI_ETRAP error code is only used in this source file so let us remove it. Signed-off-by: Anup Patel <[email protected]>
2023-12-19lib: sbi: Allow ecall handlers to directly update register stateAnup Patel
Some of the upcoming SBI extensions (such as SSE) will directly update register state so improve the prototype of ecall handler to accommodate this. Further, this flexibility allows us to push the trap redirection from sbi_ecall_handler() to the sbi_ecall_legacy_handler(). Signed-off-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_tlb: Reduce size of struct sbi_tlb_infoAnup Patel
Let us reduce the size of struct sbi_tlb_info by doing the following: 1) Change the data type of asid and vmid fields to uint16_t 2) Replace local_fn() function pointer with an enum Based on the above, the size of struct sbi_tlb_info is reduced by 16 bytes on RV64 and 4 bytes on RV32. Signed-off-by: Anup Patel <[email protected]>
2023-12-19lib: sbi: Detect extensions from the ISA string in DTYong-Xuan Wang
Enable access to some extensions through menvcfg and show them in "Boot HART ISA Extensions" if they are present in the device tree. Signed-off-by: Yong-Xuan Wang <[email protected]> Reviewed-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-19lib: sbi: Refactor the code for enable extensions in menvfg CSRYong-Xuan Wang
Use 1 variable to store the value of menvcfg. 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-11platform: recalculate heap size to support new tlb entry numberInochi Amaoto
Previous patch introduced a change that using hart count as the default number of tlb entries in the fifo. This makes the default tlb fifo size grow in square with the number of harts. So the default heap size is not enough to allocate tlb fifo when the hart count is big. Fixes: 52fd64b ("platform: Uses hart count as the default size of tlb info") Signed-off-by: Inochi Amaoto <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-08lib: sbi_pmu: Fix the counter info functionAtish Patra
The counter info should only return valid hardware counters for the ones set in the counter mask. Otherwise, it will report incorrect number of hardware counters to the supervisor if the platform has discontiguous counters. Fixes: c744ed77b18c ("lib: sbi_pmu: Enable noncontigous hpm event and counters") Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-08lib: sbi_pmu: Add PMU snapshot definitionsAtish Patra
OpenSBI doesn't support SBI PMU snapshot yet as there is not much benefit unless the multiple counters overflow at the same time. Just add the definition and return not supported error at this moment. The default returned error is also not supported. Thus, no functional change intended. Reviewed-by: Anup Patel <[email protected]> Signed-off-by: Atish Patra <[email protected]>
2023-12-08lib: sbi_hart: Store PMP granularity as log base 2Samuel Holland
This minimizes the need to call log2roundup() to recover the log value. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-08lib: sbi: Fix __atomic_op_bit_ord and commentsXiang W
The original code returns the value of the word before modification. When modifying the upper 32 bits under RV64, the value returned via int return will have no meaning. Corrected to return the value of the bit. And modify the function description. Signed-off-by: Xiang W <[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-06sbi: sbi_pmu: Add hw_counter_filter_mode() to pmu deviceYu Chien Peter Lin
Add support for custom PMU extensions to set inhibit bits on custom CSRs by introducing the PMU device callback hw_counter_filter_mode(). This allows the perf tool to restrict event counting under a specified privileged mode by appending a modifier, e.g. perf record -e event:k to count events only happening in kernel mode. Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Leo Yu-Chi Liang <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-06lib: sbi: Add XAndesPMU in hart extensionsYu Chien Peter Lin
Add the custom extension to hart extension list. Signed-off-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Lad Prabhakar <[email protected]> Tested-by: Lad Prabhakar <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-12-06lib: ipi: Adjust Andes PLICSW to single-bit-per-hart schemeLeo Yu-Chi Liang
The old scheme doesn't allow sending hart0 self-IPI as the corresponding bit on pending register is hardwired to 0, this could lead to unhandle IPIs on SMP systems, esp. on single-core. Furthermore, the limitation of old scheme is 8-core, instead of reserving source hart information, we assign bit (x + 1) as the enable and pending bit of hartx, this also expands the bootable hart number. The following diagram shows the enable bits of the new scheme on 32-core Andes platform. Pending regs: 0x1000 x---0---0---0---0------0---0 Pending hart ID: 0 1 2 3 ... 30 31 Interrupt ID: 0 1 2 3 4 ... 31 32 | | | | | | | Enable regs: 0x2000 x---1---0---0---0-...--0---0---> hart0 | | | | | | | 0x2080 x---0---1---0---0-...--0---0---> hart1 | | | | | | | 0x2100 x---0---0---1---0-...--0---0---> hart2 | | | | | | | 0x2180 x---0---0---0---1-...--0---0---> hart3 . . . . . . . . . . . . . . . . . . . . . 0x2f00 x---0---0---0---0-...--1---0---> hart30 | | | | | | | 0x2f80 x---0---0---0---0-...--0---1---> hart31 <-------- word 0 -------><--- word 1 ---> To send IPI to hart0, for example, another hart (including hart0 itself) will set bit 1 of first word on the pending register. We also fix indentation in andes_plicsw.h along with this patch. Fixes: ce7c490719ed ("lib: utils/ipi: Add Andes fdt ipi driver support") Signed-off-by: Leo Yu-Chi Liang <[email protected]> Reviewed-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Randolph <[email protected]> Reported-by: Lad Prabhakar <[email protected]> Link: https://lists.infradead.org/pipermail/opensbi/2023-October/005665.html Reviewed-by: Lad Prabhakar <[email protected]> Tested-by: Lad Prabhakar <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-11-17lib: sbi: change sbi_hart_features.extensions as an arrayXiang W
In the future there may be a lot of ISA extensions, a 'long' may not be able to accommodate, changed to an array for the future. Addresses-Coverity-ID: 1568357 Out-of-bounds access Fixes: 6259b2ec2d09 ("lib: utils/fdt: Fix fdt_parse_isa_extensions() implementation") Signed-off-by: Xiang W <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Anup Patel <[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-11-17include: sbi: macros for mseccfg.sseed and .useedHeinrich Schuchardt
Define macros to access the sseed and the useed bit in the machine security configuration register (mseccfg). Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-11-16platform: Uses hart count as the default size of tlb infoInochi Amaoto
For platform with high number of harts, it is better to auto detect a suitable number of entries in tlb fifo. Since allocating tlb entry for all online harts can reduce the wait time significantly, using the number of the online harts can make most platforms happy. This auto detection can avoid most duplicate code for setting tlb fifo size. Signed-off-by: Inochi Amaoto <[email protected]> Acked-by: Guo Ren <[email protected]> Reviewed-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-10-19include: sbi: Change spec version to 2.0Anup Patel
Now that SBI v2.0 specification is frozen, we change spec version implemented by OpenSBI to v2.0. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Andrew Jones <[email protected]>
2023-10-06lib: sbi: Add support for mconfigptrYangjie Zhang
RISC-V privileged specification v1.12 introduced the mconfigptr CSR which will hold the physical address of a configuration data structure. Signed-off-by: Yangjie Zhang <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-10-06firmware: Remove handling of R_RISCV_{32,64}Vivian Wang
Since everything is statically linked, we won't actually have R_RISCV_{32,64} relocations. No need to handle these. Fixes: 0f20e8adcf42 ("firmware: Support position independent execution") Signed-off-by: Vivian Wang <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-09-24include: sbi_domain: Fix permission test macrosMayuresh Chitale
The macros to test permissions must perform an exact match of all the bits in the input with the desired permission bits. Otherwise, the check returns false positives in those cases where only some of the desired permissions are set in the input. Fixes: 6c202c5 ("include: sbi: Add Smepmp specific access flags for PMP entries") Signed-off-by: Mayuresh Chitale <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-09-24include: sbi: Remove sbi_hartmask_for_each_hart() macroAnup Patel
The sbi_hartmask_for_each_hart() macro is slow and has only one user so let us completely remove the sbi_hartmask_for_each_hart() macro. Signed-off-by: Anup Patel <[email protected]>
2023-09-24lib: sbi: Maximize the use of HART index in sbi_domainAnup Patel
Let us maximize the use of HART index in sbi_domain because hartindex based hartmask access and sbi_scratch lookup is faster. Signed-off-by: Anup Patel <[email protected]>
2023-09-24lib: sbi: Remove sbi_scratch_last_hartid() macroAnup Patel
The sbi_scratch_last_hartid() macro is not of much use on platforms with really sparse hartids so let us replace use of this macro with other approaches. Signed-off-by: Anup Patel <[email protected]>
2023-09-24lib: sbi: Prefer hartindex over hartid in IPI frameworkAnup Patel
Let us prefer hartindex over hartid in IPI framework which in-turn forces IPI users to also prefer hartindex. Signed-off-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-09-24lib: sbi: Remove sbi_platform_hart_index/invalid() functionsAnup Patel
The hartid to hartindex mapping is now tracked in sbi_scratch so we don't need sbi_platform_hart_index() and sbi_platform_hart_invalid() functions hence let us remove them. Signed-off-by: Anup Patel <[email protected]>
2023-09-24lib: sbi: Introduce HART index in sbi_scratchAnup Patel
We introduce HART index and related helper functions in sbi_scratch where HART index is contiguous and each HART index maps to a physical HART id such that 0 <= HART index and HART index < SBI_HARTMASK_MAX_BITS. The HART index to HART id mapping follows the index2id mapping provided by the platform. If the platform does not provide index2id mapping then identity mapping is assumed. Signed-off-by: Anup Patel <[email protected]>
2023-09-22lib: sbi: Implement SET_FS_DIRTY() to make sure the mstatus FS dirty is setGreentime Hu
We found the mstatus.FS status is not set correctly after the SET_F64_REG() and SET_F32_REG(). We should set mstatus.FS dirty after we emulate the FPU instructions. Co-developed-by: Roy Lin <[email protected]> Signed-off-by: Roy Lin <[email protected]> Signed-off-by: Greentime Hu <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-09-10platform: Allow platforms to specify the size of tlb fifoXiang W
For some platforms with a particularly high number of harts, if the tlb fifo is too small, it case harts to wait. Platforms should be allowed to specify the size of the tlb fifo. Signed-off-by: Xiang W <[email protected]> Signed-off-by: Xing Xiaoguang <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-09-06lib: sbi: improve the definition of SBI_IPI_EVENT_MAXXiang W
The previous definition had the assumption that the machine word length is equal to the word length of LONG. Remove this assumption and add a static check to prevent errors in subsequent modifications. Signed-off-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-08-22lib: sbi_pmu: remove mhpm_count field in hart featureInochi Amaoto
After supporting noncontigous hpm event and counters in opensbi, the number of hpm counters can be calculated by the mhpm_mask. So this field is unnecessary and can be removed to save some space. Signed-off-by: Inochi Amaoto <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-08-18lib: sbi: Add support for smcntrpmfKaiwen Xue
This adds the support for ISA extension smcntrpmf. When some inhibit flags are set by a lower privilege mode for new CSRs added by smcntrpmf, OpenSBI sets the appropriate values correspondingly. Signed-off-by: Kaiwen Xue <[email protected]> Signed-off-by: Kaiwen Xue <[email protected]> Reviewed-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
2023-08-06lib: sbi_pmu: Enable noncontigous hpm event and countersMayuresh Chitale
Platforms may implement hpm events/counters non contiguously but the current implementation assumes them to be always contigous. Add a bitmap that captures the hpm events/counters as implemented in the hardware and use it to set the max limit of hardware counters visible to the OS. Counters not implemented in the hardware can't be used by the OS because those wont be described in the DT. Signed-off-by: Mayuresh Chitale <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-07-31lib: utils/reset: Remove SiFive Test reset driverAnup Patel
The functionality of SiFive Test reset driver is easily available through Syscon reset driver so let us remove the SiFive Test driver. Signed-off-by: Anup Patel <[email protected]>
2023-07-31lib: utils/regmap: Add simple FDT based regmap frameworkAnup Patel
We add a simple FDT based regmap framework which is built on top of generic regmap library. The phandle of FDT regmap DT node is treated as unique regmap ID. The FDT based regmap drivers will be probed on-demand from fdt_regmap_get_by_phandle() and fdt_regmap_get() called by the regmap client drivers. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Xiang W <[email protected]>
2023-07-31lib: utils/regmap: Add generic regmap access libraryAnup Patel
We add generic regmap access library which is independent of hardware description format (FDT or ACPI). The OpenSBI platform support or regmap drivers can register regmap instances which can be discovered by different regmap clients based on the unique ID of regmap instances. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Xiang W <[email protected]>
2023-07-31include: sbi_utils: Remove driver pointer from struct i2c_adapterAnup Patel
The "driver" pointer in struct i2c_adapter is not used anywhere so let us remove it. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Xiang W <[email protected]>
2023-07-31include: sbi: fix CSR define of mseccfgXiang W
Because the CSR names in the spec are mseccfg and mseccfgh. Remove CSR_MSECCFG_LOWER and CSR_MSECCFG_UPPER and directly define CSR_MSECCFG and CSR_MSECCFGH. Signed-off-by: Xiang W <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-07-13lib: sbi: Add functions to map/unmap shared memoryHimanshu Chauhan
When Smepmp is enabled, M-mode will need to map/unmap the shared memory before it can read/write to it. This patch adds functions to create dynamic short-lived mappings. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-07-13lib: sbi: Add support for SmepmpHimanshu Chauhan
- If Smepmp is enabled, the access flags of an entry are determined based on truth table defined in Smepmp. - First PMP entry (index 0) is reserved. - Existing boot PMP entries start from index 1. - Since enabling Smepmp revokes the access privileges of the M-mode software on S/U-mode region, first PMP entry is used to map/unmap the shared memory between M and S/U-mode. This allows a temporary access window for the M-mode software to read/write to S/U-mode memory region. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[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]>