summaryrefslogtreecommitdiff
path: root/include/sbi
AgeCommit message (Collapse)Author
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-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: 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-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-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-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-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: sbi: Add smepmp in hart extensionsHimanshu Chauhan
- Add Smepmp as extension in sbi_hart_extensions enum - Return "smepmp" string for Smepmp extension from sbi_hart_extension_id2string Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-07-13include: sbi: Add Smepmp specific access flags for PMP entriesHimanshu Chauhan
Smepmp specification defines a truth table based on which the access is allowed to different modes. This patch adds different flags based on this truth table. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-07-13lib: sbi: Add functions to manipulate PMP entriesHimanshu Chauhan
- Add a function to disable a given PMP entry. - Add a function to check if a given entry is disabled. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-07-13include: sbi: Add macro definitions for mseccfg CSRHimanshu Chauhan
- Add macros for Machine Security Configuration (mseccfg) CSR - Add macros to access/manipulate bits in msecfg CSR Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
2023-07-09lib: sbi: Alphabetically sort HART ISA extensionsAnup Patel
Let us follow alphabetical order for HART ISA extension so that it is simpler to maintain. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Xiang W <[email protected]>
2023-07-09lib: sbi: Add Zihpm as a HART ISA extensionAnup Patel
Recently ratified Zihpm ISA extension covers all [m]hpm* CSRs so we add Zihpm as a HART ISA extension in OpenSBI. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Xiang W <[email protected]>
2023-07-09lib: sbi: Add Zicntr as a HART ISA extensionAnup Patel
Recently ratified Zicntr ISA extension covers cycle, time and instret CSRs so we replace the "time" ISA extension with "zicntr" ISA extension in OpenSBI. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Xiang W <[email protected]>
2023-06-23include: Bump-up version to 1.3v1.3Anup Patel
This patch updates OpenSBI version to 1.3 as part of release preparation. Signed-off-by: Anup Patel <[email protected]>
2023-06-05lib: sbi: Use scratch space to save per-HART domain pointerAnup Patel
Instead of using a global array indexed by hartid, we should use scratch space to save per-HART domain pointer. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Andrew Jones <[email protected]>
2023-06-05lib: sbi: Print scratch size and usage at boot timeAnup Patel
The scratch space being a scarce resource so let us print it's size and usage at boot time. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Andrew Jones <[email protected]>
2023-06-05lib: sbi: Introduce simple heap allocatorAnup Patel
We provide simple heap allocator to manage the heap space provided by OpenSBI firmware and platform. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Andrew Jones <[email protected]>
2023-06-05platform: Allow platforms to specify heap sizeAnup Patel
We extend struct sbi_platform and struct sbi_scratch to allow platforms specify the heap size to the OpenSBI firmwares. The OpenSBI firmwares will use this information to determine the location of heap and provide heap base address in per-HART scratch space. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Andrew Jones <[email protected]>