| b9807372 | 25-May-2025 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: dynamic allocation of thread_core_local and its stacks
Refer to commit 59724f223500 ("core: dynamic allocation of thread_core_local and its stacks"), we implement the code for RISC-V ar
core: riscv: dynamic allocation of thread_core_local and its stacks
Refer to commit 59724f223500 ("core: dynamic allocation of thread_core_local and its stacks"), we implement the code for RISC-V architecture. With CFG_DYN_STACK_CONFIG enabled, the thread_core_local and the two stacks, tmp_stack and abt_stack, are dynamically allocated.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 5eb31236 | 17-May-2025 |
Alvin Chang <alvinga@andestech.com> |
riscv: mm: Fix VA base for canonical addresses
RISC-V defines the following virtual address rules: - For Sv39 (39-bit VA), bits 63–39 all equal to bit 38 of VA - For Sv48 (48-bit VA), bits 63–48 all
riscv: mm: Fix VA base for canonical addresses
RISC-V defines the following virtual address rules: - For Sv39 (39-bit VA), bits 63–39 all equal to bit 38 of VA - For Sv48 (48-bit VA), bits 63–48 all equal to bit 47 of VA - For Sv57 (57-bit VA), bits 63–57 all equal to bit 56 of VA
In other words, the most-significant bits of VA base must be all one if the highest SvXX address bit of VA is one.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 27ef0a31 | 15-Mar-2025 |
Yu-Chien Peter Lin <peter.lin@sifive.com> |
core: riscv: mm: add per-mapping VA range validation
Replace single maximum VA check with individual VA range validation for each memory map entry during MMU initialization, providing earlier detect
core: riscv: mm: add per-mapping VA range validation
Replace single maximum VA check with individual VA range validation for each memory map entry during MMU initialization, providing earlier detection of invalid mappings.
Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 26685a91 | 15-Mar-2025 |
Yu-Chien Peter Lin <peter.lin@sifive.com> |
core: mm: factor out virtual address range validation to arch code
Move virtual address range validation into architecture-specific code since different architectures have different constraints on v
core: mm: factor out virtual address range validation to arch code
Move virtual address range validation into architecture-specific code since different architectures have different constraints on valid VA ranges:
- For ARM, addresses must be within the VA width supported by the MMU - For RISC-V, additional checks are needed on RV64 to ensure addresses are canonically valid
Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 16ea0367 | 14-Mar-2025 |
Yu-Chien Peter Lin <peter.lin@sifive.com> |
riscv: mm: fix map_offset data type
Fix the data type of map_offset to allow storing 64-bit offset on RV64.
Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Reviewed-by: Alvin Chang <alving
riscv: mm: fix map_offset data type
Fix the data type of map_offset to allow storing 64-bit offset on RV64.
Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 232f1cde | 08-Mar-2025 |
Yu-Chien Peter Lin <peter.lin@sifive.com> |
core: mm: refactor ASLR mapping for architecture support
To allow adding RISC-V ASLR support, add arch_aslr_base_addr() which will be used to apply architecture specific ASLR base calculation.
Sign
core: mm: refactor ASLR mapping for architecture support
To allow adding RISC-V ASLR support, add arch_aslr_base_addr() which will be used to apply architecture specific ASLR base calculation.
Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Suggested-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Alvin Chang <alvinga@andestech.com>
show more ...
|
| e6a8329a | 08-May-2025 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: Call page_alloc_init()
Call page_alloc_init() from init_primary() after unused boot memory has been released.
This commit is to synchronize the boot stages with ARM architecture, intro
core: riscv: Call page_alloc_init()
Call page_alloc_init() from init_primary() after unused boot memory has been released.
This commit is to synchronize the boot stages with ARM architecture, introduced in commit 0e12fb0c2d75 ("core: arm: boot: call page_alloc_init()") and commit 3e7d042b5d1e ("core: arm: boot: fix calling page_alloc_init()").
Signed-off-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.com>
show more ...
|
| f4ea1751 | 08-May-2025 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: Refactor boot
Move initialization of thread_core_local[] from very early to boot_init_primary_late() and introduce boot_init_primary_runtime().
This commit is to synchronize the boot s
core: riscv: Refactor boot
Move initialization of thread_core_local[] from very early to boot_init_primary_late() and introduce boot_init_primary_runtime().
This commit is to synchronize the boot stages with ARM architecture, introduced in commit b5ec8152f3e5 ("core: arm: refactor boot") and commit b0da0d592ac4 ("core: boot: add boot_init_primary_runtime()").
Signed-off-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.com>
show more ...
|
| 6bfaca07 | 20-Mar-2025 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: Remove init_sec_mon()
In RISC-V architecture, the secure monitor is always initialized before jumping into OP-TEE. Thus, init_sec_mon() can be deprecated.
Signed-off-by: Alvin Chang <a
core: riscv: Remove init_sec_mon()
In RISC-V architecture, the secure monitor is always initialized before jumping into OP-TEE. Thus, init_sec_mon() can be deprecated.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.com>
show more ...
|
| 91d4649d | 20-Mar-2025 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: add thread_count to thread_init_threads()
Add a thread_count parameter to thread_init_threads(). This must currently always be equal to CFG_NUM_THREADS, but may become a dynamic configuration
core: add thread_count to thread_init_threads()
Add a thread_count parameter to thread_init_threads(). This must currently always be equal to CFG_NUM_THREADS, but may become a dynamic configuration parameter with CFG_DYN_CONFIG=y in later patches.
The array threads[] is changed into a pointer to allow dynamic allocation in later patches. The assembly code is updated accordingly to handle a pointer instead of an array.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Alvin Chang <alvinga@andestech.com> Tested-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Tested-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| a4c2e0cb | 20-Mar-2025 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: add core_count to thread_init_thread_core_local()
Add a core_count parameter to thread_init_thread_core_local() to enable dynamic configuration of the number of supported cores when configured
core: add core_count to thread_init_thread_core_local()
Add a core_count parameter to thread_init_thread_core_local() to enable dynamic configuration of the number of supported cores when configured with CFG_DYN_STACK_CONFIG=y, or it must be equal to CFG_TEE_CORE_NB_CORE. This is needed in later patches where the number of cores is configured dynamically.
The array thread_core_local[] is changed into a pointer to allow dynamic allocation in later patches. The assembly code is updated accordingly to handle a pointer instead of an array.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Alvin Chang <alvinga@andestech.com> Tested-by: Alvin Chang <alvinga@andestech.com> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| f5dbcd82 | 24-Apr-2025 |
Alvin Chang <alvinga@andestech.com> |
riscv: mm: Fix core_mmu_entry_is_branch()
We must also check V bit to determine non-leaf PTE.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.co
riscv: mm: Fix core_mmu_entry_is_branch()
We must also check V bit to determine non-leaf PTE.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.com>
show more ...
|
| 71214c12 | 11-Apr-2025 |
Alvin Chang <alvinga@andestech.com> |
riscv: mm: support Sv48 and Sv57 address translation for core and TA
Add the macros for Sv57 address translation mode. Add CFG_RISCV_MMU_MODE into riscv.mk and set it as 39 by default to enable Sv39
riscv: mm: support Sv48 and Sv57 address translation for core and TA
Add the macros for Sv57 address translation mode. Add CFG_RISCV_MMU_MODE into riscv.mk and set it as 39 by default to enable Sv39 virtual address translation scheme.
Currently, TA virtual memory occupies 1GB space, and TAs page table should be an entry inside a level 2 (VPN[2]) page table, which is decided by user_va_idx variable. For Sv39 translation scheme, it starts from VPN[2], so nothing to do. For Sv48 translation scheme, we need to allocate entry 0 of level 3 (VPN[3]) page table, and let it point to the level 2 page table used by TA. For Sv57 translation scheme, we need to further allocate entry 0 of level 4 (VPN[4]) page table, and let it point to the level 3 page table.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 1da54125 | 11-Apr-2025 |
Alvin Chang <alvinga@andestech.com> |
riscv: mm: Explicitly set user VA range inside L2(RV64) and L1(RV32) VPN
Add macros for level and bit shift of virtual page number (VPN) encoded in RISC-V virtual address. Explicitly set range of us
riscv: mm: Explicitly set user VA range inside L2(RV64) and L1(RV32) VPN
Add macros for level and bit shift of virtual page number (VPN) encoded in RISC-V virtual address. Explicitly set range of user virtual address inside level 2 VPN by giving CORE_MMU_VPN2_SHIFT since the CORE_MMU_BASE_TABLE_SHIFT is not always based on level 2 VPN if the MMU scheme is not Sv39.
For RV32, there is only two-level VPN. The user VA range would be inside level 1 VPN.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 2642a3da | 11-Apr-2025 |
Alvin Chang <alvinga@andestech.com> |
riscv: mm: clean up macro definitions
Rename RISCV_SATP_ASID_SIZE to RISCV_SATP_ASID_WIDTH since it is used to represent width of bits. Also remove redundant RISCV_MMU_ASID_WIDTH since we already ha
riscv: mm: clean up macro definitions
Rename RISCV_SATP_ASID_SIZE to RISCV_SATP_ASID_WIDTH since it is used to represent width of bits. Also remove redundant RISCV_MMU_ASID_WIDTH since we already have RISCV_SATP_ASID_WIDTH. Fix a minor compiler warning due to inconsistent data types on variable comparison.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| b598f903 | 30-Mar-2025 |
Yu-Chien Peter Lin <peter.lin@sifive.com> |
core: riscv: allow enabling CFG_WITH_STACK_CANARIES
Remove force disablement of randomized stack canary for OP-TEE core.
Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Reviewed-by: Alvin
core: riscv: allow enabling CFG_WITH_STACK_CANARIES
Remove force disablement of randomized stack canary for OP-TEE core.
Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Tested-by: Alvin Chang <alvinga@andestech.com>
show more ...
|
| 71ee6d2a | 30-Mar-2025 |
Yu-Chien Peter Lin <peter.lin@sifive.com> |
core: riscv: support random stack canaries for stack protector
Call plat_get_random_stack_canaries() and update the value of __stack_chk_guard during early initialization, so that the random stack c
core: riscv: support random stack canaries for stack protector
Call plat_get_random_stack_canaries() and update the value of __stack_chk_guard during early initialization, so that the random stack canaries can be used to detect stack overflow and buffer overflow.
Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Co-developed-by: Alvin Chang <alvinga@andestech.com> Signed-off-by: Alvin Chang <alvinga@andestech.com>
show more ...
|
| 0ae5ef34 | 03-Apr-2025 |
Thomas Bourgoin <thomas.bourgoin@foss.st.com> |
tree wide: fix header files dependencies in linker files
When linking with a generated linker script like kern.ld.S, dependencies with header file are not regenerated. Same issue as commit acdc32afe
tree wide: fix header files dependencies in linker files
When linking with a generated linker script like kern.ld.S, dependencies with header file are not regenerated. Same issue as commit acdc32afe18f ("mk/compile.mk: fix header dependency in .d file")
Add option -MP used to fix error generated when removing header files.
Signed-off-by: Thomas Bourgoin <thomas.bourgoin@foss.st.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 49c6ad2a | 06-Jan-2025 |
Yu-Chien Peter Lin <peter.lin@sifive.com> |
core: riscv: add SiFive Unleashed and Unmatched board support
Add SiFive Unleashed and Unmatched board support.
Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Reviewed-by: Samuel Holland
core: riscv: add SiFive Unleashed and Unmatched board support
Add SiFive Unleashed and Unmatched board support.
Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Reviewed-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Zong Li <zong.li@sifive.com> Acked-by: Alvin Chang <alvinga@andestech.com> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 2e27ec6c | 12-Jan-2025 |
Yu-Chien Peter Lin <peter.lin@sifive.com> |
riscv: kernel: support booting non-contiguous non-zero-based hart IDs
Currently, OP-TEE assumes 0 <= hartid < CFG_TEE_CORE_NB_CORE, and must be contiguous, which fails to accommodate different CPU t
riscv: kernel: support booting non-contiguous non-zero-based hart IDs
Currently, OP-TEE assumes 0 <= hartid < CFG_TEE_CORE_NB_CORE, and must be contiguous, which fails to accommodate different CPU topologies. For example, some RISC-V platforms, such as the HiFive Unmatched board, do not run Linux and OP-TEE on hart0, as it is a monitor core without supervisor mode support.
To address this, introduce hart_index, which is used to index per-hart structures, such as thread_core_local and root_pgt. The hart_index will range from 0 to (CFG_TEE_CORE_NB_CORE - 1), and the primary hart will have an index of 0.
Additionally, a new function, boot_primary_init_core_ids(), is added to initialize secondary hart IDs for booting via sbi_hsm_hart_start().
Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Reviewed-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Zong Li <zong.li@sifive.com> Reviewed-by: Alvin Chang <alvinga@andestech.com>
show more ...
|
| 72fc7d74 | 12-Jan-2025 |
Yu-Chien Peter Lin <peter.lin@sifive.com> |
riscv: kernel: sbi: introduce sbi_hsm_hart_get_status() function
Introduce sbi_hsm_hart_get_status() function and add comment for sbi_hsm_hart_start().
Signed-off-by: Yu-Chien Peter Lin <peter.lin@
riscv: kernel: sbi: introduce sbi_hsm_hart_get_status() function
Introduce sbi_hsm_hart_get_status() function and add comment for sbi_hsm_hart_start().
Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Reviewed-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Zong Li <zong.li@sifive.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| e27b0796 | 25-Jan-2025 |
Yu-Chien Peter Lin <peter.lin@sifive.com> |
riscv: plat-virt: move stack alignment definition
The 16-byte stack alignment is a RISC-V ABI requirement that applies to all RISC-V platforms. Move this definition from the virt platform configurat
riscv: plat-virt: move stack alignment definition
The 16-byte stack alignment is a RISC-V ABI requirement that applies to all RISC-V platforms. Move this definition from the virt platform configuration to riscv.h.
Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Reviewed-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Zong Li <zong.li@sifive.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| e413d9ee | 12-Jan-2025 |
Yu-Chien Peter Lin <peter.lin@sifive.com> |
riscv: kernel: entry.S: remove unused boot_args array
The boot_args array is unused anywhere and its contents are cleared during the zeroing of the .bss section, so it serves no purpose. Removing it
riscv: kernel: entry.S: remove unused boot_args array
The boot_args array is unused anywhere and its contents are cleared during the zeroing of the .bss section, so it serves no purpose. Removing it simplifies the code.
Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Reviewed-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Zong Li <zong.li@sifive.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 949b0c0c | 15-Jan-2025 |
Aleksandr Iashchenko <aleksandr.iashchenko@linutronix.de> |
ta: enable ubsan support for TAs
Introduce CFG_TA_SANITIZE_UNDEFINED config to sanitize trusted applications. If CFG_TA_SANITIZE_UNDEFINED is set sanitize flags are propagated to internal TAs (avb,
ta: enable ubsan support for TAs
Introduce CFG_TA_SANITIZE_UNDEFINED config to sanitize trusted applications. If CFG_TA_SANITIZE_UNDEFINED is set sanitize flags are propagated to internal TAs (avb, pkcs11, remoteproc, trusted_keys) and external TAs, which are built with the devkit.
Signed-off-by: Aleksandr Iashchenko <aleksandr.iashchenko@linutronix.de> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 96f43358 | 26-Feb-2025 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: add nex_dyn_vaspace and tee_dyn_vaspace areas
Add MEM_AREA_NEX_DYN_VASPACE and MEM_AREA_TEE_DYN_VASPACE areas for dynamic Nexus and TEE memory mapping. This will be used to map additional heap
core: add nex_dyn_vaspace and tee_dyn_vaspace areas
Add MEM_AREA_NEX_DYN_VASPACE and MEM_AREA_TEE_DYN_VASPACE areas for dynamic Nexus and TEE memory mapping. This will be used to map additional heap and the stacks in later patches.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|