| dfa05b24 | 09-Sep-2024 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: Set exception return PC into XEPC for entering user mode
Instead of setting exception return PC into "ra" register and assign it to XEPC, we should directly set exception return PC into
core: riscv: Set exception return PC into XEPC for entering user mode
Instead of setting exception return PC into "ra" register and assign it to XEPC, we should directly set exception return PC into "XEPC" CSR to improve code redability.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com>
show more ...
|
| 16b9b1ef | 14-Aug-2024 |
Yu Chien Peter Lin <peterlin@andestech.com> |
riscv: plat-virt: allow enabling CFG_TEE_CORE_DEBUG for virt machine
Allow enabling CFG_TEE_CORE_DEBUG to make assertions useful.
Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed
riscv: plat-virt: allow enabling CFG_TEE_CORE_DEBUG for virt machine
Allow enabling CFG_TEE_CORE_DEBUG to make assertions useful.
Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Tested-by: Alvin Chang <alvinga@andestech.com> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| b1e25277 | 14-Aug-2024 |
Yu Chien Peter Lin <peterlin@andestech.com> |
core: mm: core_mmu: add core_mmu_user_va_range_is_defined() for RISC-V
The function hasn't been implemented for RISC-V, so move the core_mmu_user_va_range_is_defined() definition to generic core_mmu
core: mm: core_mmu: add core_mmu_user_va_range_is_defined() for RISC-V
The function hasn't been implemented for RISC-V, so move the core_mmu_user_va_range_is_defined() definition to generic core_mmu.h and function implementations to arch-specific files.
Also, update the assertions where checks if user va range is defined.
Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Tested-by: Alvin Chang <alvinga@andestech.com> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 5f853a3f | 14-Aug-2024 |
Yu Chien Peter Lin <peterlin@andestech.com> |
core: riscv: core_mmu_arch: fix compile error for bit_test()
Fix the compile error in the bit_test() macro, which mistakenly uses the address of g_asid as the parameter.
Signed-off-by: Yu Chien Pet
core: riscv: core_mmu_arch: fix compile error for bit_test()
Fix the compile error in the bit_test() macro, which mistakenly uses the address of g_asid as the parameter.
Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Tested-by: Alvin Chang <alvinga@andestech.com> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 7621b0d3 | 05-Sep-2024 |
Yu Chien Peter Lin <peterlin@andestech.com> |
core: riscv: mm: fix arch_va2pa_helper() on superpage translation
Any level of PTE may be a leaf PTE in RISC-V page table, if the page is not 4KiB, the page offset should be extended to VPN fields o
core: riscv: mm: fix arch_va2pa_helper() on superpage translation
Any level of PTE may be a leaf PTE in RISC-V page table, if the page is not 4KiB, the page offset should be extended to VPN fields of virtual address.
e.g. on Sv39, if there is a leaf PTE on level-1 (2MiB megapage), it maps to physical page with (va[20:12] | va[11:0]) as the page offset.
Sv39 Virtual address: |<--- superpage offset --->| 38_______30_29______21|20______12_11____________0| | VPN[2] | VPN[1] | VPN[0] | page offset | ‾‾‾‾9‾‾‾‾‾‾‾‾‾‾9‾‾‾‾‾|‾‾‾‾9‾‾‾‾‾‾‾‾‾‾‾‾12‾‾‾‾‾‾‾| | | Physical address: | | | | 55___________30_29______21|20______12_11____________0| | PPN[2] | PPN[1] | PPN[0] | page offset | ‾‾‾‾‾‾26‾‾‾‾‾‾‾‾‾‾‾9‾‾‾‾‾'‾‾‾‾9‾‾‾‾‾‾‾‾‾‾‾‾12‾‾‾‾‾‾‾'
Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Tested-by: Alvin Chang <alvinga@andestech.com> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 7b76de3d | 24-Jul-2024 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: Let platform choose native and foreign interrupts
Platform may want to choose different types of native and foreign interrupts. This commit adds two definitions for the platforms: 1. PL
core: riscv: Let platform choose native and foreign interrupts
Platform may want to choose different types of native and foreign interrupts. This commit adds two definitions for the platforms: 1. PLAT_THREAD_EXCP_FOREIGN_INTR: to define platform specific foreign interrupts 2. PLAT_THREAD_EXCP_NATIVE_INTR: to define platform specific native interrupts.
For RISC-V virt machine, we define all external/mtimer/software interrupts as foreign interrupts. For RISC-V spike platform, we define external interrupts as foreign interrupts, and mtimer/software interrupts as native interrupts.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| ce1f8a72 | 24-Jul-2024 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: Update thread core local flags for native interrupts
Record the type of stack and the type of interrupt into thread core local flags before handling the native interrupts. Once we finis
core: riscv: Update thread core local flags for native interrupts
Record the type of stack and the type of interrupt into thread core local flags before handling the native interrupts. Once we finish the handling of the native interrupts, we clear the previous flags.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 5232a348 | 24-Jul-2024 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: Determine foreign interrupts during interrupt handling
The foreign interrupts are defined in THREAD_EXCP_FOREIGN_INTR, whose bit fields are corresponding to RISC-V MIP/SIP CSR. Thus, we
core: riscv: Determine foreign interrupts during interrupt handling
The foreign interrupts are defined in THREAD_EXCP_FOREIGN_INTR, whose bit fields are corresponding to RISC-V MIP/SIP CSR. Thus, we can determine whether the coming interrupt is foreign interrupt or not by THREAD_EXCP_FOREIGN_INTR.
However, the trap information is encoded in XCAUSE CSR. Thus, we must translate the value of XCAUSE to XIP first, and then compare the XIP with THREAD_EXCP_FOREIGN_INTR. For example, if the coming interrupt is supervisor timer interrupt, the value of SCAUSE will be 0x8000000000000005 on RV64 system. We need to translate it to be sip.STIP, which is 0x20. Then, we can further compare 0x20 with THREAD_EXCP_FOREIGN_INTR. If 0x20 is subset of THREAD_EXCP_FOREIGN_INTR, it is determined as a foreign interrupt. Finally, we call thread_foreign_interrupt_handler() to further handle it.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 8d5bae1c | 24-Jul-2024 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: Implement foreign interrupt handler
In SMP based OP-TEE system, the foreign interrupts, which are handled outside OP-TEE, might be injected during the execution of OP-TEE. When OP-TEE r
core: riscv: Implement foreign interrupt handler
In SMP based OP-TEE system, the foreign interrupts, which are handled outside OP-TEE, might be injected during the execution of OP-TEE. When OP-TEE receives such foreign interrupts, it should suspend current thread and yield the execution to the foreign domains to handle those foreign interrupts.
This commit implements thread_foreign_interrupt_handler(), which is expected to be called during trap handling. The job of this function are suspending the current thread, and returning to the other domain to let them handle the foreign interrupts.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| ef00a923 | 24-Jul-2024 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: Rename and re-order parameters of the interrupt handlers
Rename thread_interrupt_handler() to thread_native_interrupt_handler(), since we are going to support the foreign interrupt hand
core: riscv: Rename and re-order parameters of the interrupt handlers
Rename thread_interrupt_handler() to thread_native_interrupt_handler(), since we are going to support the foreign interrupt handler.
The native interrupts are handled in OP-TEE side, while the foreign interrupts are handled outside OP-TEE.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 90c16066 | 15-Aug-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: rename to core_mmu_init_phys_mem()
Rename core_mmu_init_ta_ram() to core_mmu_init_phys_mem() for a more accurate name of the function.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org
core: rename to core_mmu_init_phys_mem()
Rename core_mmu_init_ta_ram() to core_mmu_init_phys_mem() for a more accurate name of the function.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| cd7384a0 | 14-Aug-2024 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: Simplify SP setup in setup_unwind_user_mode()
The parameter "regs" is the stack pointer which is allocated to store system call registers when calling thread_scall_handler(). Thus, we c
core: riscv: Simplify SP setup in setup_unwind_user_mode()
The parameter "regs" is the stack pointer which is allocated to store system call registers when calling thread_scall_handler(). Thus, we can simply get the original stack pointer by "regs + 1" equation, and use it to exit user mode.
The code is referenced from ARM's setup_unwind_user_mode().
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com>
show more ...
|
| 980d32c4 | 19-Jun-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: open-code thread_init_stack()
The implementations of thread_init_stack() are identical and trivial for both arm and riscv. So simplify code further and open-code it where it's called from in c
core: open-code thread_init_stack()
The implementations of thread_init_stack() are identical and trivial for both arm and riscv. So simplify code further and open-code it where it's called from in core/kernel/thread.c.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Alvin Chang <alvinga@andestech.com> Tested-by: Alvin Chang <alvinga@andestech.com>
show more ...
|
| 10b2f530 | 30-Aug-2024 |
Alvin Chang <alvinga@andestech.com> |
riscv: plat-virt: Set CFG_BOOT_SYNC_CPU=n
On RISC-V QEMU virt platform, OP-TEE OS runs as S-mode. There is a secure monitor runs as M-mode and controls the hart state of the secondary CPUs in SMP sy
riscv: plat-virt: Set CFG_BOOT_SYNC_CPU=n
On RISC-V QEMU virt platform, OP-TEE OS runs as S-mode. There is a secure monitor runs as M-mode and controls the hart state of the secondary CPUs in SMP system (e.g., by SBI HSM extension) during OP-TEE OS secondary CPUs booting.
Thus, RISC-V virt platform does not need CFG_BOOT_SYNC_CPU.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 47fd7209 | 23-Jul-2024 |
Yu Chien Peter Lin <peterlin@andestech.com> |
core: drivers: riscv_zkr_rng: limit seed reading time
If the attempts to read SEED exceed 1 second for 16-bit randomness, we consider it a failure.
Also, move seed CSR field encodings to the header
core: drivers: riscv_zkr_rng: limit seed reading time
If the attempts to read SEED exceed 1 second for 16-bit randomness, we consider it a failure.
Also, move seed CSR field encodings to the header file.
Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Tested-by: Alvin Chang <alvinga@andestech.com> Acked-by: Gatien Chevallier <gatien.chevallier@foss.st.com>
show more ...
|
| 71f90c7d | 14-Aug-2024 |
Yu Chien Peter Lin <peterlin@andestech.com> |
core: riscv: core_mmu_arch: fix next level page-table translation
If arch_va2pa_helper() and core_mmu_find_table() are called when the MMU is disabled, we don't need to convert the next level page b
core: riscv: core_mmu_arch: fix next level page-table translation
If arch_va2pa_helper() and core_mmu_find_table() are called when the MMU is disabled, we don't need to convert the next level page base address with phys_to_virt(). Add core_mmu_xlat_table_entry_pa2va() to handle this address translation.
Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Tested-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| bb9980e2 | 14-Aug-2024 |
Yu Chien Peter Lin <peterlin@andestech.com> |
core: riscv: core_mmu_arch: remove address translation when initializing SATP
Fix the handling of the page table base address (pgt) by removing the unnecessary virt_to_phys(). The pgt is already a p
core: riscv: core_mmu_arch: remove address translation when initializing SATP
Fix the handling of the page table base address (pgt) by removing the unnecessary virt_to_phys(). The pgt is already a physical address, and thus does not require translation.
Additionally, since the ASID always set to 0, replaced the redundant assertions with a explicit check to ensure the MMU is disabled in the context.
Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Tested-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 2a585878 | 18-Aug-2024 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: Increase size of stacks and extra check space
To support CFG_CORE_DEBUG_CHECK_STACKS=y for RISC-V, we set STACK_CHECK_EXTRA as 1536 like what ARM does.
To avoid stack overruns when CFG
core: riscv: Increase size of stacks and extra check space
To support CFG_CORE_DEBUG_CHECK_STACKS=y for RISC-V, we set STACK_CHECK_EXTRA as 1536 like what ARM does.
To avoid stack overruns when CFG_CORE_DEBUG_CHECK_STACKS=y, we increase the size of abort stack to 4096 bytes and size of thread stack to 10240 bytes.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu-Chien Peter Lin <peterlin@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| c29c4146 | 18-Aug-2024 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: Fix initial value of a0 in "detect_csr" ASM macro
To set initial value of the register a0 to 1, the assembly code should be "li a0, 1" instead of "addi a0, a0, 1".
Signed-off-by: Alvin
core: riscv: Fix initial value of a0 in "detect_csr" ASM macro
To set initial value of the register a0 to 1, the assembly code should be "li a0, 1" instead of "addi a0, a0, 1".
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu-Chien Peter Lin <peterlin@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 7c76fdcd | 12-Jun-2024 |
Yu Chien Peter Lin <peterlin@andestech.com> |
core: riscv: apply "-march" and "-mabi" options to assembler
Update platform-aflags-generic to include the -march option. Without specifying -march, the assembler will enable the C extension by defa
core: riscv: apply "-march" and "-mabi" options to assembler
Update platform-aflags-generic to include the -march option. Without specifying -march, the assembler will enable the C extension by default and generate compressed instructions, even if CFG_RISCV_ISA_C=n.
Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 883402f5 | 28-Apr-2024 |
Yu Chien Peter Lin <peterlin@andestech.com> |
core: riscv: use configuration options for RISC-V extensions
RISC-V is a modular ISA, add config options to allow platforms to customize their binaries with specific "-march" and "-mabi".
Also, ena
core: riscv: use configuration options for RISC-V extensions
RISC-V is a modular ISA, add config options to allow platforms to customize their binaries with specific "-march" and "-mabi".
Also, enable RVC and FPU extension for QEMU virt machine.
Note that the RISC-V FPU for OP-TEE will be introduced later. Enable FPU to temporarily bypass incompatible soft/hard-fp linker errors.
Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 2bb485c3 | 14-Aug-2024 |
Jerome Forissier <jerome.forissier@linaro.org> |
kernel/link.mk: fix missing build number in version string on first build
Fix an issue with the build number in the version string. While at it, factor out the duplicated code into mk/macros.mk.
Be
kernel/link.mk: fix missing build number in version string on first build
Fix an issue with the build number in the version string. While at it, factor out the duplicated code into mk/macros.mk.
Before:
$ rm -rf out/ $ make out/arm-plat-vexpress/core/version.o UPD out/arm-plat-vexpress/core/.buildcount GEN out/arm-plat-vexpress/core/version.o cat: out/arm-plat-vexpress/core/.buildcount: No such file or directory
In addition to the error message, note the missing build number after the hash sign:
$ strings out/arm-plat-vexpress/core/version.o | grep UTC 4.3.0-48-g9c97e7d52 (gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)) # Wed Aug 14 16:17:07 UTC 2024 arm
After:
$ rm -rf out/ $ make out/arm-plat-vexpress/core/version.o UPD out/arm-plat-vexpress/core/.buildcount GEN out/arm-plat-vexpress/core/version.o $ strings out/arm-plat-vexpress/core/version.o | grep UTC 4.3.0-48-g9c97e7d52-dev (gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)) #1 Wed Aug 14 16:17:24 UTC 2024 arm
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 1eef6015 | 16-Aug-2024 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: Zeroize unused parameters before thread_return_to_udomain()
Zeroize unused parameters before calling thread_return_to_udomain() to avoid leaking information to the untrusted domain unin
core: riscv: Zeroize unused parameters before thread_return_to_udomain()
Zeroize unused parameters before calling thread_return_to_udomain() to avoid leaking information to the untrusted domain unintentionally.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| b8ef8d0b | 08-May-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: mm: introduce struct memory_map
Introduce struct memory_map to keep track of the array of struct tee_mmap_region, covering number of used entries and number of allocated entries.
core_mmap_is
core: mm: introduce struct memory_map
Introduce struct memory_map to keep track of the array of struct tee_mmap_region, covering number of used entries and number of allocated entries.
core_mmap_is_end_of_table() and MEM_AREA_END are now unused so remove them.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
show more ...
|
| eadb6be0 | 17-Jul-2024 |
Yu Chien Peter Lin <peterlin@andestech.com> |
core: riscv: core_mmu_arch: fix PPN field extraction from PTE
The upper bits of page table entry may contain other fields introduced since Priv. ISA spec. v1.11 (20211203), such as PBMT and N bits,
core: riscv: core_mmu_arch: fix PPN field extraction from PTE
The upper bits of page table entry may contain other fields introduced since Priv. ISA spec. v1.11 (20211203), such as PBMT and N bits, thus PPN field should be masked out with PTE_PPN.
Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Tested-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>
show more ...
|