| 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 ...
|
| ab1707d1 | 01-Aug-2024 |
Mikko Rapeli <mikko.rapeli@linaro.org> |
link.mk: generate version.o in link-out-dir
When source code is piped to compiler, then the current working directory is left into debug data. If the working directory is not the output directory, t
link.mk: generate version.o in link-out-dir
When source code is piped to compiler, then the current working directory is left into debug data. If the working directory is not the output directory, then mappings which strip absolute output directory paths don't work.
Removes absolute build time paths from version.o debug info.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
show more ...
|
| 865e6147 | 01-Aug-2024 |
Mikko Rapeli <mikko.rapeli@linaro.org> |
link.mk: use CFLAGS with version.o
Should be used by all compilations.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org> |
| 97db08f5 | 22-Jul-2024 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: Translate to PA when allocating PGT with MMU enabled
If MMU is enabled, core_mmu_pgt_alloc() returns virtual address of PGT instead of physical address. Thus, it leads to some errors wh
core: riscv: Translate to PA when allocating PGT with MMU enabled
If MMU is enabled, core_mmu_pgt_alloc() returns virtual address of PGT instead of physical address. Thus, it leads to some errors when we invoke pa_to_ppn() with returned PGT which is actually the virtual address of that PGT.
Fix it by checking whether MMU is enabled or not. If MMU is enabled, we translate the returned PGT to its physical address.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>
show more ...
|
| d237e616 | 06-Feb-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: make generic notifications virtualization-aware
Makes the generic notification handling aware of virtualization. Atomic events are delivered with a guest_id parameter and asynchronous notifica
core: make generic notifications virtualization-aware
Makes the generic notification handling aware of virtualization. Atomic events are delivered with a guest_id parameter and asynchronous notifications are started per guest_id.
struct notif_data is added as guest specific data to be able to track if notifications are started for a guest.
While this patch compiles it doesn't work as intended without patches handling the ABI specific side of things.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 5e26ef8f | 01-May-2024 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: Improve the trap handler
In current RISC-V trap handler, we always save the context into struct thread_trap_regs first, and copy the saved context into another specific structure to han
core: riscv: Improve the trap handler
In current RISC-V trap handler, we always save the context into struct thread_trap_regs first, and copy the saved context into another specific structure to handle that trap. For example, thread_user_ecall_handler() copies the struct thread_trap_regs to be struct thread_scall_regs before handling this system call. In fact, such copies may drop the performance and they should be eliminated.
In this commit, the specific data structure used to save the context is determined early in the trap handler by checking the type of the trap from CSR XCAUSE. Thus, the copies between context structures are eliminated.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com> Tested-by: Yu Chien Peter Lin <peterlin@andestech.com> Tested-by: Marouene Boubakri <marouene.boubakri@nxp.com>
show more ...
|
| 956c2d50 | 12-Jun-2024 |
Etienne Carriere <etienne.carriere@foss.st.com> |
core: fix race condition on TA/PTA/StMM context loading
Fix race condition on creation of a context for single instance TAs, PTAs or StMM application. Such race condition could occur and lead to dup
core: fix race condition on TA/PTA/StMM context loading
Fix race condition on creation of a context for single instance TAs, PTAs or StMM application. Such race condition could occur and lead to duplicated contexts if connected close enough that they are created after tee_ta_init_session() calls tee_ta_init_session_with_context() and before the context are added in the centralized context list.
This is realized by keeping tee_ta_mutex held while tee_ctxes list is looked up for matching a context or a new context is added into that list with its .is_initializing field activated. For that purpose user TA and StMM application initialization function are split in 2 functions, the 2nd one used to finalizes the context creation started in the 1st function.
By the way, add inline description comments and fix indentation issues in uaer_ta.h and remove the inline comment in pseudo_ta.c that refers to TA loading whereas the function relates to PTA contexts creation.
Closes: https://github.com/OP-TEE/optee_os/issues/6801 Suggested-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|