| 26e3e52d | 15-Jul-2025 |
Marouene Boubakri <marouene.boubakri@nxp.com> |
core: riscv: add initial RPMI/MPXY integration support
This commit introduces infrastructure to support RPMI communication via the SBI MPXY extension. MPXY allows supervisor software to send and rec
core: riscv: add initial RPMI/MPXY integration support
This commit introduces infrastructure to support RPMI communication via the SBI MPXY extension. MPXY allows supervisor software to send and receive RPMI messages through M-mode firmware acting as a proxy.
Functions added by this commit are sufficient to implement the RequestForward service group.
Support for asynchronous events, notifications, and MSI-based message delivery will be added in future commits.
Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com> Reviewed-by: Alvin Chang <alvinga@andestech.com>
show more ...
|
| 8020e392 | 15-Jul-2025 |
Marouene Boubakri <marouene.boubakri@nxp.com> |
riscv: sbi_mpxy_rpmi.h: add RPMI protocol-specific definitions for MPXY
Introduce sbi_mpxy_rpmi.h, a header defining RPMI message protocol attributes and message types specific to the MPXY SBI exten
riscv: sbi_mpxy_rpmi.h: add RPMI protocol-specific definitions for MPXY
Introduce sbi_mpxy_rpmi.h, a header defining RPMI message protocol attributes and message types specific to the MPXY SBI extension. This includes enums for attribute and message type identifiers, a unified RPMI message structure, and helper initializers to simplify message construction.
These definitions serve as the interface between supervisor-level RPMI clients and the underlying MPXY transport.
Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com> Reviewed-by: Alvin Chang <alvinga@andestech.com>
show more ...
|
| 693e2940 | 29-Jun-2025 |
Marouene Boubakri <marouene.boubakri@nxp.com> |
riscv: rpmi.h: add defines of RISC-V RPMI messaging protocol
The RPMI messaging protocol includes all the RPMI messages exchanged over a RPMI transport channel.
*NOTE*: The RISC-V RPMI specificatio
riscv: rpmi.h: add defines of RISC-V RPMI messaging protocol
The RPMI messaging protocol includes all the RPMI messages exchanged over a RPMI transport channel.
*NOTE*: The RISC-V RPMI specification is not yet ratified as a full standard. This is based on the v0.99 draft released during May–June 2025 The draft is frozen and in public review.
Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 30feb38a | 29-Jun-2025 |
Marouene Boubakri <marouene.boubakri@nxp.com> |
core: riscv: implement MPXY SBI extension
Introduce support for the MPXY SBI extension (EID #0x4D505859), which enables supervisor software to exchange messages through an abstract SBI interface dec
core: riscv: implement MPXY SBI extension
Introduce support for the MPXY SBI extension (EID #0x4D505859), which enables supervisor software to exchange messages through an abstract SBI interface decoupled from any specific protocol.
MPXY allows setting up per-hart shared memory for transferring messages between the supervisor and an SBI implementation. It serves as a generic backend to build messaging clients, while being agnostic of message protocol semantics.
This step provides the foundation for future inter-domain message exchange.
Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com> Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Reviewed-by: Alvin Chang <alvinga@andestech.com>
show more ...
|
| 93b4dfda | 14-Jul-2025 |
Marouene Boubakri <marouene.boubakri@nxp.com> |
core: riscv: include: misc_arch.h: include stdint.h for uint32_t type
Added <stdint.h> to ensure types like uint32_t are correctly defined, resolving implicit type issues when including this header.
core: riscv: include: misc_arch.h: include stdint.h for uint32_t type
Added <stdint.h> to ensure types like uint32_t are correctly defined, resolving implicit type issues when including this header.
Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.com>
show more ...
|
| 37ad62c2 | 15-Jul-2025 |
Marouene Boubakri <marouene.boubakri@nxp.com> |
core: riscv: sbi.h: expose sbi_ecall helper in public header
Move `sbi_ecall()` and `struct sbiret` to sbi.h to allow reuse across individual SBI extension implementations. This prepares for modular
core: riscv: sbi.h: expose sbi_ecall helper in public header
Move `sbi_ecall()` and `struct sbiret` to sbi.h to allow reuse across individual SBI extension implementations. This prepares for modularizing each SBI extension (e.g., HSM, MPXY) into its own file while centralizing the ecall interface.
Removes the now-duplicated inline definition from sbi.c.
Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.com>
show more ...
|
| cc967d3f | 28-Jun-2025 |
Marouene Boubakri <marouene.boubakri@nxp.com> |
core: riscv: sbi.h: add SBI_EXT_MPXY definition
Added `SBI_EXT_MPXY` (0x4D505859) as per latest RISC-V SBI extensions.
Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com> Reviewed-by: Alvi
core: riscv: sbi.h: add SBI_EXT_MPXY definition
Added `SBI_EXT_MPXY` (0x4D505859) as per latest RISC-V SBI extensions.
Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.com>
show more ...
|
| 1af87903 | 28-Jun-2025 |
Marouene Boubakri <marouene.boubakri@nxp.com> |
core: riscv: sbi.h: extend SBI error codes
Add more SBI error codes to synchronize with SBI specification.
Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com> Reviewed-by: Alvin Chang <alv
core: riscv: sbi.h: extend SBI error codes
Add more SBI error codes to synchronize with SBI specification.
Signed-off-by: Marouene Boubakri <marouene.boubakri@nxp.com> Reviewed-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.com>
show more ...
|
| f0a3f742 | 14-Mar-2025 |
Yu-Chien Peter Lin <peter.lin@sifive.com> |
riscv: add ELF header definitions
Add RISC-V specific ELF header definitions in a new header file to support ELF parsing for handling dynamic relocations.
We referred to u-boot/arch/riscv/cpu/start
riscv: add ELF header definitions
Add RISC-V specific ELF header definitions in a new header file to support ELF parsing for handling dynamic relocations.
We referred to u-boot/arch/riscv/cpu/start.S to obtain the definitions we need in OP-TEE.
Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Reviewed-by: Alvin Chang <alvinga@andestech.com>
show more ...
|
| 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 ...
|
| 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 ...
|
| 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 ...
|
| 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 ...
|
| f4b54213 | 27-Feb-2025 |
Huang Borong <huangborong@bosc.ac.cn> |
drivers: add RISC-V IMSIC interrupt driver
The RISC-V Advanced Interrupt Architecture (AIA) specification introduces the IMSIC as a new external interrupt controller. An IMSIC receives and records i
drivers: add RISC-V IMSIC interrupt driver
The RISC-V Advanced Interrupt Architecture (AIA) specification introduces the IMSIC as a new external interrupt controller. An IMSIC receives and records incoming message-signaled interrupts (MSIs).
This commit enables the initialization of the IMSIC based on the device tree and adds control and status registers (CSRs) for indirect access to the IMSIC as well as for reading interrupt identities.
Use the `CFG_RISCV_IMSIC` flag to control whether to build this driver.
For more details, see: https://github.com/riscv/riscv-aia
Signed-off-by: Huang Borong <huangborong@bosc.ac.cn> Reviewed-by: Alvin Chang <alvinga@andestech.com> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| ca5bd0a2 | 05-Dec-2024 |
Huang Borong <huangborong@bosc.ac.cn> |
core: riscv: Improve macros for set/clear bits CSR operations
Rename `set_csr` to `read_set_csr` and `clear_csr` to `read_clear_csr` because they perform atomic reads and set/clear bits in the CSR.
core: riscv: Improve macros for set/clear bits CSR operations
Rename `set_csr` to `read_set_csr` and `clear_csr` to `read_clear_csr` because they perform atomic reads and set/clear bits in the CSR. These two macros will return the previous value of the CSR.
Introduce new macros `set_csr` and `clear_csr`: `set_csr` uses the RISC-V `csrs` assembler pseudoinstruction to set bits in the CSR when the old value is not needed, while `clear_csr` uses the `csrc` pseudoinstruction to clear bits in the CSR, also discarding the old value.
Signed-off-by: Huang Borong <huangborong@bosc.ac.cn> Reviewed-by: Alvin Chang <alvinga@andestech.com>
show more ...
|
| 9df67cd4 | 26-Sep-2024 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: Improve thread user mode record
Make the asm definitions be more human-readable.
Besides, it's unnecessary to save and restore kernel SP and GP into thread_user_mode_rec, since they wi
core: riscv: Improve thread user mode record
Make the asm definitions be more human-readable.
Besides, it's unnecessary to save and restore kernel SP and GP into thread_user_mode_rec, since they will be setup by system call trap handler before executing thread_unwind_user_mode().
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com>
show more ...
|
| 5c718542 | 18-Aug-2024 |
Alvin Chang <alvinga@andestech.com> |
core: riscv: Remove thread_exit_user_mode()
Currently, the user mode abort and some system calls return to kernel mode by thread_exit_user_mode(). Although this function creates a shorter path to re
core: riscv: Remove thread_exit_user_mode()
Currently, the user mode abort and some system calls return to kernel mode by thread_exit_user_mode(). Although this function creates a shorter path to return to kernel mode, it leads to some problems because the function does not update the core local flags. Especially when CFG_CORE_DEBUG_CHECK_STACKS=y, some checks will fail due to wrong type of stack recorded in the core local flags.
Fix it by removing thread_exit_user_mode(). So that the core local flags can be correctly updated in the common trap handler.
Signed-off-by: Alvin Chang <alvinga@andestech.com> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.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 ...
|
| 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 ...
|