History log of /optee_os/core/arch/riscv/ (Results 101 – 125 of 262)
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
09bbd26b15-May-2024 Yu Chien Peter Lin <peterlin@andestech.com>

riscv: plat-virt: switch to dynamic shared memory

Enable dynamic shared memory for QEMU virt machine.

Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
Reviewed-by: Alvin Chang <alvinga@an

riscv: plat-virt: switch to dynamic shared memory

Enable dynamic shared memory for QEMU virt machine.

Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
Reviewed-by: Alvin Chang <alvinga@andestech.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>

show more ...

139faa8b23-May-2024 Alvin Chang <alvinga@andestech.com>

core: riscv: Add a reserved-memory node for static shared memory

To prevent Linux from using static shared memory, include the
dedicated reserved-memory node in the device tree.

Signed-off-by: Alvi

core: riscv: Add a reserved-memory node for static shared memory

To prevent Linux from using static shared memory, include the
dedicated reserved-memory node in the device tree.

Signed-off-by: Alvin Chang <alvinga@andestech.com>
Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>

show more ...


/optee_os/.github/workflows/ci.yml
/optee_os/core/arch/arm/kernel/boot.c
/optee_os/core/arch/arm/mm/sub.mk
/optee_os/core/arch/arm/mm/tee_pager.c
/optee_os/core/arch/arm/plat-hikey/platform_config.h
/optee_os/core/arch/arm/plat-mediatek/conf.mk
kernel/boot.c
/optee_os/core/crypto/signed_hdr.c
/optee_os/core/drivers/clk/sam/at91_pmc.h
/optee_os/core/drivers/crypto/hisilicon/crypto.mk
/optee_os/core/drivers/crypto/hisilicon/hisi_qm.h
/optee_os/core/drivers/crypto/hisilicon/hpre_dh.c
/optee_os/core/drivers/crypto/hisilicon/hpre_dh.h
/optee_os/core/drivers/crypto/hisilicon/hpre_main.c
/optee_os/core/drivers/crypto/hisilicon/hpre_main.h
/optee_os/core/drivers/crypto/hisilicon/sec_hash.c
/optee_os/core/drivers/crypto/hisilicon/sec_hash.h
/optee_os/core/drivers/crypto/hisilicon/sec_hmac.c
/optee_os/core/drivers/crypto/hisilicon/sec_main.c
/optee_os/core/drivers/crypto/hisilicon/sec_main.h
/optee_os/core/drivers/crypto/hisilicon/sub.mk
/optee_os/core/drivers/crypto/se050/adaptors/include/se050.h
/optee_os/core/drivers/crypto/se050/adaptors/utils/scp_config.c
/optee_os/core/drivers/crypto/stm32/cipher.c
/optee_os/core/drivers/firewall/firewall.c
/optee_os/core/drivers/firewall/sub.mk
/optee_os/core/drivers/pm/sam/at91_pm.c
/optee_os/core/drivers/pm/sam/at91_pm.h
/optee_os/core/drivers/pm/sam/pm-defines.c
/optee_os/core/drivers/pm/sam/pm_suspend.S
/optee_os/core/drivers/sub.mk
/optee_os/core/include/drivers/firewall.h
/optee_os/core/include/drivers/firewall_device.h
/optee_os/core/include/drivers/sam/sama7-ddr.h
/optee_os/core/include/kernel/boot.h
/optee_os/core/include/kernel/dt_driver.h
/optee_os/core/include/kernel/interrupt.h
/optee_os/core/include/kernel/mutex.h
/optee_os/core/include/kernel/spinlock.h
/optee_os/core/include/kernel/user_ta.h
/optee_os/core/kernel/boot.c
/optee_os/core/kernel/dt_driver.c
/optee_os/core/kernel/sub.mk
/optee_os/core/lib/libtomcrypt/aes_accel.c
/optee_os/core/mm/mobj_dyn_shm.c
/optee_os/core/mm/sub.mk
/optee_os/lib/libutils/ext/include/fault_mitigation.h
/optee_os/scripts/ftrace_format.py
78444d3326-Apr-2024 Alvin Chang <alvinga@andestech.com>

core: riscv: Fix store 32-bit thread_core_local flags

The thread_core_local flags is a 32-bit variable. Thus, we must
explicitly use "sw" instruction, which means store 32-bit value into
specific me

core: riscv: Fix store 32-bit thread_core_local flags

The thread_core_local flags is a 32-bit variable. Thus, we must
explicitly use "sw" instruction, which means store 32-bit value into
specific memory address, to operate the thread_core_local flags.

Signed-off-by: Alvin Chang <alvinga@andestech.com>
Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>

show more ...


/optee_os/core/arch/arm/crypto/aes_modes_armv8a_ce_a64.S
/optee_os/core/arch/arm/kernel/boot.c
/optee_os/core/arch/arm/kernel/thread_spmc.c
/optee_os/core/arch/arm/plat-sam/conf.mk
/optee_os/core/arch/arm/plat-vexpress/main.c
kernel/entry.S
/optee_os/core/crypto.mk
/optee_os/core/drivers/atmel_shdwc.c
/optee_os/core/drivers/crypto/hisilicon/crypto.mk
/optee_os/core/drivers/crypto/hisilicon/hpre_dh.c
/optee_os/core/drivers/crypto/hisilicon/hpre_main.c
/optee_os/core/drivers/crypto/hisilicon/include/hpre_dh.h
/optee_os/core/drivers/crypto/hisilicon/include/hpre_main.h
/optee_os/core/drivers/crypto/hisilicon/include/sec_main.h
/optee_os/core/drivers/crypto/hisilicon/sec_main.c
/optee_os/core/drivers/crypto/hisilicon/sub.mk
/optee_os/core/drivers/ffa_console.c
/optee_os/core/drivers/pm/sam/at91_pm.c
/optee_os/core/drivers/regulator/regulator.c
/optee_os/core/drivers/sub.mk
/optee_os/core/include/drivers/atmel_shdwc.h
/optee_os/core/include/drivers/ffa_console.h
/optee_os/core/include/drivers/pm/sam/atmel_pm.h
/optee_os/core/include/drivers/stpmic1_regulator.h
/optee_os/core/kernel/callout.c
/optee_os/core/kernel/console.c
/optee_os/core/kernel/ubsan.c
/optee_os/core/lib/libtomcrypt/aes.c
/optee_os/core/lib/libtomcrypt/aes_accel.c
/optee_os/core/lib/libtomcrypt/rsa.c
/optee_os/core/lib/libtomcrypt/src/ciphers/aes/aes.c
/optee_os/core/lib/libtomcrypt/src/ciphers/aes/aes_desc.c
/optee_os/core/lib/libtomcrypt/src/ciphers/aes/aesni.c
/optee_os/core/lib/libtomcrypt/src/encauth/ccm/ccm_memory.c
/optee_os/core/lib/libtomcrypt/src/encauth/ccm/ccm_test.c
/optee_os/core/lib/libtomcrypt/src/encauth/gcm/gcm_memory.c
/optee_os/core/lib/libtomcrypt/src/hashes/tiger.c
/optee_os/core/lib/libtomcrypt/src/headers/tomcrypt.h
/optee_os/core/lib/libtomcrypt/src/headers/tomcrypt_cfg.h
/optee_os/core/lib/libtomcrypt/src/headers/tomcrypt_cipher.h
/optee_os/core/lib/libtomcrypt/src/headers/tomcrypt_custom.h
/optee_os/core/lib/libtomcrypt/src/headers/tomcrypt_hash.h
/optee_os/core/lib/libtomcrypt/src/headers/tomcrypt_mac.h
/optee_os/core/lib/libtomcrypt/src/headers/tomcrypt_macros.h
/optee_os/core/lib/libtomcrypt/src/headers/tomcrypt_pk.h
/optee_os/core/lib/libtomcrypt/src/headers/tomcrypt_pkcs.h
/optee_os/core/lib/libtomcrypt/src/headers/tomcrypt_private.h
/optee_os/core/lib/libtomcrypt/src/math/fp/ltc_ecc_fp_mulmod.c
/optee_os/core/lib/libtomcrypt/src/misc/crypt/crypt.c
/optee_os/core/lib/libtomcrypt/src/misc/crypt/crypt_register_all_ciphers.c
/optee_os/core/lib/libtomcrypt/src/misc/crypt/crypt_register_all_hashes.c
/optee_os/core/lib/libtomcrypt/src/misc/pkcs5/pkcs_5_test.c
/optee_os/core/lib/libtomcrypt/src/misc/ssh/ssh_encode_sequence_multi.c
/optee_os/core/lib/libtomcrypt/src/pk/asn1/der/choice/der_decode_choice.c
/optee_os/core/lib/libtomcrypt/src/pk/asn1/der/custom_type/der_encode_custom_type.c
/optee_os/core/lib/libtomcrypt/src/pk/asn1/der/sequence/der_encode_sequence_ex.c
/optee_os/core/lib/libtomcrypt/src/pk/asn1/der/utf8/der_decode_utf8_string.c
/optee_os/core/lib/libtomcrypt/src/pk/dsa/dsa_import.c
/optee_os/core/lib/libtomcrypt/src/pk/ecc/ecc_get_key.c
/optee_os/core/lib/libtomcrypt/src/pk/ecc/ecc_import_pkcs8.c
/optee_os/core/lib/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_decode.c
/optee_os/core/lib/libtomcrypt/src/pk/pkcs1/pkcs_1_oaep_encode.c
/optee_os/core/lib/libtomcrypt/src/pk/pkcs1/pkcs_1_v1_5_encode.c
/optee_os/core/lib/libtomcrypt/src/pk/rsa/rsa_decrypt_key.c
/optee_os/core/lib/libtomcrypt/src/pk/rsa/rsa_encrypt_key.c
/optee_os/core/lib/libtomcrypt/src/pk/rsa/rsa_verify_hash.c
/optee_os/core/lib/libtomcrypt/src/prngs/fortuna.c
/optee_os/core/lib/libtomcrypt/src/prngs/rng_get_bytes.c
/optee_os/core/lib/libtomcrypt/sub.mk
/optee_os/core/lib/scmi-server/sub.mk
/optee_os/core/mm/core_mmu.c
/optee_os/core/tee/tee_svc_cryp.c
/optee_os/ldelf/ta_elf.c
/optee_os/lib/libutee/tee_api_operations.c
/optee_os/lib/libutils/ext/include/util.h
/optee_os/mk/config.mk
6376023b10-Apr-2024 Alvin Chang <alvinga@andestech.com>

riscv: plat-virt: Enable CFG_HWRNG_PTA

Enable CFG_HWRNG_PTA with the implementation of the RISC-V
Zkr driver which provides the hardware entropy source.

Signed-off-by: Alvin Chang <alvinga@andestec

riscv: plat-virt: Enable CFG_HWRNG_PTA

Enable CFG_HWRNG_PTA with the implementation of the RISC-V
Zkr driver which provides the hardware entropy source.

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 ...

e10bcf3b07-Apr-2024 Alvin Chang <alvinga@andestech.com>

core: riscv: Add seed CSR detection helper

Any attempted access to unimplemented or restricted CSRs will
raise an illegal instruction, so we can set up a temporary
trap handler to validate if the us

core: riscv: Add seed CSR detection helper

Any attempted access to unimplemented or restricted CSRs will
raise an illegal instruction, so we can set up a temporary
trap handler to validate if the use of CSRs is allowed in
the privileged mode where OP-TEE OS is running. Add a helper
for this specific purpose.

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 ...


/optee_os/.github/workflows/ci.yml
/optee_os/CHANGELOG.md
/optee_os/core/arch/arm/dts/stm32mp251.dtsi
/optee_os/core/arch/arm/include/kernel/thread_spmc.h
/optee_os/core/arch/arm/kernel/secure_partition.c
/optee_os/core/arch/arm/kernel/spmc_sp_handler.c
/optee_os/core/arch/arm/kernel/thread_spmc.c
/optee_os/core/arch/arm/plat-sam/conf.mk
/optee_os/core/arch/arm/plat-sam/platform_sama5d2.c
/optee_os/core/arch/arm/plat-sam/platform_sama7g5.c
/optee_os/core/arch/arm/plat-sam/sub.mk
/optee_os/core/arch/arm/plat-stm32mp2/conf.mk
/optee_os/core/arch/arm/plat-vexpress/conf.mk
include/riscv.h
kernel/csr_detect.S
kernel/sub.mk
/optee_os/core/core.mk
/optee_os/core/drivers/atmel_wdt.c
/optee_os/core/drivers/clk/clk.c
/optee_os/core/drivers/clk/sam/sub.mk
/optee_os/core/drivers/crypto/hisilicon/hpre_main.c
/optee_os/core/drivers/crypto/hisilicon/include/hpre_main.h
/optee_os/core/drivers/crypto/hisilicon/sub.mk
/optee_os/core/drivers/crypto/stm32/stm32_cryp.c
/optee_os/core/drivers/firewall/stm32_rifsc.c
/optee_os/core/drivers/regulator/regulator.c
/optee_os/core/drivers/stm32_fmc.c
/optee_os/core/drivers/stm32_hpdma.c
/optee_os/core/drivers/stm32_hsem.c
/optee_os/core/drivers/stm32_i2c.c
/optee_os/core/drivers/stm32_ipcc.c
/optee_os/core/drivers/stm32_rng.c
/optee_os/core/drivers/sub.mk
/optee_os/core/include/drivers/clk.h
/optee_os/core/include/drivers/regulator.h
/optee_os/core/include/drivers/stm32_i2c.h
/optee_os/core/include/drivers/stm32_rif.h
/optee_os/core/include/dt-bindings/firewall/stm32mp25-rif.h
/optee_os/core/include/dt-bindings/firewall/stm32mp25-rifsc.h
/optee_os/core/include/kernel/mutex.h
/optee_os/core/include/kernel/mutex_pm_aware.h
/optee_os/core/include/kernel/notif.h
/optee_os/core/include/kernel/spinlock.h
/optee_os/core/include/kernel/wait_queue.h
/optee_os/core/include/optee_rpc_cmd.h
/optee_os/core/kernel/mutex.c
/optee_os/core/kernel/notif.c
/optee_os/core/kernel/panic.c
/optee_os/core/kernel/user_ta.c
/optee_os/core/kernel/wait_queue.c
/optee_os/mk/config.mk
4c4387dc26-Feb-2024 Alvin Chang <alvinga@andestech.com>

core: riscv: Prepare SATP for each hart

To support multiple harts environment, we have allocated root page table
for each hart. Further more, we need to prepare value of CSR SATP, which
holds the ph

core: riscv: Prepare SATP for each hart

To support multiple harts environment, we have allocated root page table
for each hart. Further more, we need to prepare value of CSR SATP, which
holds the physical page number (PPN) of the root page table, for each
hart.

This commit enlarges the "struct core_mmu_config" for RISC-V
architecture to hold the value of CSR SATP for all the harts. In early
boot stage, each hart should initialize its CSR SATP from "struct
core_mmu_config".

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>
Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>

show more ...

fe9a268226-Feb-2024 Alvin Chang <alvinga@andestech.com>

core: riscv: Allocate root page table for each hart

To support multiple hart environment, each hart must have its dedicated
root page table. This commit enlarges the root page table. Also, when
the

core: riscv: Allocate root page table for each hart

To support multiple hart environment, each hart must have its dedicated
root page table. This commit enlarges the root page table. Also, when
the primary hart initializes the page table, we also copy the contents
of its root page table to the secondary harts' root page tables.
Therefore, all the harts have initial page tables at the boot time.

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>
Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>

show more ...

1cf7e98d14-Mar-2024 Jens Wiklander <jens.wiklander@linaro.org>

core: replace REGISTER_TIME_SOURCE()

Remove REGISTER_TIME_SOURCE() and implement tee_time_get_sys_time() and
tee_time_get_sys_time_protection_level() directly in the file where
REGISTER_TIME_SOURCE(

core: replace REGISTER_TIME_SOURCE()

Remove REGISTER_TIME_SOURCE() and implement tee_time_get_sys_time() and
tee_time_get_sys_time_protection_level() directly in the file where
REGISTER_TIME_SOURCE() was used previously.

By avoiding indirect calls the linker can optimize the dependency tree
properly and we can remove the DECLARE_KEEP_PAGER() directive needed for
arm_cntpct_time_source.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>

show more ...

63bfec5e02-Mar-2024 Alvin Chang <alvinga@andestech.com>

core: riscv: Apply SM-based boot flow for secondary harts

When the system adopts M-mode secure monitor based solution, the
secondary harts need to hand over the control back to the secure
monitor af

core: riscv: Apply SM-based boot flow for secondary harts

When the system adopts M-mode secure monitor based solution, the
secondary harts need to hand over the control back to the secure
monitor after the initial boot sequence. Add related code for this
purpose.

Signed-off-by: Alvin Chang <alvinga@andestech.com>
Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>

show more ...

058cf71210-Nov-2023 Alvin Chang <alvinga@andestech.com>

core: riscv: Do not restrict primary hart to hart ID 0 only

The ID of primary hart should not be restricted to zero. Thus,
determining primary hart and secondart harts by zero hart ID is not
feasibl

core: riscv: Do not restrict primary hart to hart ID 0 only

The ID of primary hart should not be restricted to zero. Thus,
determining primary hart and secondart harts by zero hart ID is not
feasible.

We refer to RISC-V linux kernel [1] to fix this issue, by adding a
"hart_lottery" variable. The first hart who enters OP-TEE will win the
lottery, atomically increment this variable, and be the primary hart.
Other harts enter OP-TEE later won't win the lottery, so they execute
the secondary boot sequence.

[1]:
https://github.com/torvalds/linux/blob/v6.7/arch/riscv/kernel/head.S#L244

Signed-off-by: Alvin Chang <alvinga@andestech.com>
Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>

show more ...

1706a28423-Jan-2024 Alvin Chang <alvinga@andestech.com>

core: riscv: Change the condition of communication with untrusted domain

Use CFG_RISCV_WITH_M_MODE_SM to determine if OP-TEE uses M-mode secure
monitor based solution to communicate with the untruse

core: riscv: Change the condition of communication with untrusted domain

Use CFG_RISCV_WITH_M_MODE_SM to determine if OP-TEE uses M-mode secure
monitor based solution to communicate with the untrusetd domain.

Signed-off-by: Alvin Chang <alvinga@andestech.com>
Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>

show more ...

83abc78423-Jan-2024 Alvin Chang <alvinga@andestech.com>

riscv: plat-virt: Set CFG_RISCV_WITH_M_MODE_SM as 'y'

In RISC-V QEMU virtual platform, OP-TEE OS uses M-mode secure monitor
based solution to communicate with the untrusted domain. Therefore, set
CF

riscv: plat-virt: Set CFG_RISCV_WITH_M_MODE_SM as 'y'

In RISC-V QEMU virtual platform, OP-TEE OS uses M-mode secure monitor
based solution to communicate with the untrusted domain. Therefore, set
CFG_RISCV_WITH_M_MODE_SM to 'y' in its configuration file.

Signed-off-by: Alvin Chang <alvinga@andestech.com>
Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>

show more ...

a30b448623-Jan-2024 Alvin Chang <alvinga@andestech.com>

core: riscv: Add CFG_RISCV_WITH_M_MODE_SM and dependency checking

OP-TEE may communicate with the untrusted domain by different solutions,
such as M-mode secure monitor based solution, or direct mes

core: riscv: Add CFG_RISCV_WITH_M_MODE_SM and dependency checking

OP-TEE may communicate with the untrusted domain by different solutions,
such as M-mode secure monitor based solution, or direct messaging based
solution. This commit adds CFG_RISCV_WITH_M_MODE_SM to indicate that
OP-TEE uses M-mode secure monitor based solution for the communication.

The CFG_RISCV_WITH_M_MODE_SM should depend on CFG_RISCV_S_MODE and
CFG_RISCV_SBI, since we are using "ecall" to trap into M-mode secure
monitor.

Signed-off-by: Alvin Chang <alvinga@andestech.com>
Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>

show more ...

ea11f51223-Oct-2023 Alvin Chang <alvinga@andestech.com>

core: riscv: Apply mask/unmask exceptions when operating page table

Add missing thread_{mask/unmask}_exceptions() when we operate the page
table. This is referenced from ARM architecture.

Signed-of

core: riscv: Apply mask/unmask exceptions when operating page table

Add missing thread_{mask/unmask}_exceptions() when we operate the page
table. This is referenced from ARM architecture.

Signed-off-by: Alvin Chang <alvinga@andestech.com>
Tested-by: Marouene Boubakri <marouene.boubakri@nxp.com>
Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>

show more ...

d1d1ca2323-Oct-2023 Alvin Chang <alvinga@andestech.com>

core: riscv: Apply STATUS helper for RPC resume

Since RPC resume is a kind of exception return, we invoke
xstatus_for_xret() to prepare the CSR STATUS for exception return. But
the actual value of S

core: riscv: Apply STATUS helper for RPC resume

Since RPC resume is a kind of exception return, we invoke
xstatus_for_xret() to prepare the CSR STATUS for exception return. But
the actual value of STATUS when calling thread_rpc() is still saved in
stack. This is to unify the behavior between RPC suspend and resume.

Signed-off-by: Alvin Chang <alvinga@andestech.com>
Tested-by: Marouene Boubakri <marouene.boubakri@nxp.com>
Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>

show more ...

de45f2fb23-Oct-2023 Alvin Chang <alvinga@andestech.com>

core: riscv: Apply exception return to handle_user_mode_panic()

Now thread_exit_user_mode() executes exception return to kernel mode.
Invoke xstatus_for_xret() helper function to prepare CSR STATUS

core: riscv: Apply exception return to handle_user_mode_panic()

Now thread_exit_user_mode() executes exception return to kernel mode.
Invoke xstatus_for_xret() helper function to prepare CSR STATUS for
exception return.

Signed-off-by: Alvin Chang <alvinga@andestech.com>
Tested-by: Marouene Boubakri <marouene.boubakri@nxp.com>
Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>

show more ...

4fe3a3f723-Oct-2023 Alvin Chang <alvinga@andestech.com>

core: riscv: Refine thread trap handler

In order to support SMP, we made change on CSR SCRATCH from kernel stack
pointer to be kernel TP(thread_core_local). So that we can get TP from
SCRATCH easily

core: riscv: Refine thread trap handler

In order to support SMP, we made change on CSR SCRATCH from kernel stack
pointer to be kernel TP(thread_core_local). So that we can get TP from
SCRATCH easily in trap handler when the thread is in user mode. We also
save/restore CSR IE, kernel GP and SP so that we can handle task
migration to another hart.

Signed-off-by: Alvin Chang <alvinga@andestech.com>
Tested-by: Marouene Boubakri <marouene.boubakri@nxp.com>
Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>

show more ...

b5bb30b323-Oct-2023 Alvin Chang <alvinga@andestech.com>

core: riscv: Refine thread enter/exit user mode

Now when thread is in user mode, the kernel TP is saved into CSR SCRATCH
instead of into kernel stack. The IE is also considered since it
contains mas

core: riscv: Refine thread enter/exit user mode

Now when thread is in user mode, the kernel TP is saved into CSR SCRATCH
instead of into kernel stack. The IE is also considered since it
contains masks of different exceptions.

Apply exception return to thread_exit_user_mode() to let hart correctly
back to kernel mode from exception.

Signed-off-by: Alvin Chang <alvinga@andestech.com>
Tested-by: Marouene Boubakri <marouene.boubakri@nxp.com>
Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>

show more ...

09653bca23-Oct-2023 Alvin Chang <alvinga@andestech.com>

core: riscv: Apply exception return to resume thread

In current implementation, the thread is resumed by function return. It
is not suitable for all scenarios, especially when the thread should be
r

core: riscv: Apply exception return to resume thread

In current implementation, the thread is resumed by function return. It
is not suitable for all scenarios, especially when the thread should be
resumed to user mode. The kernel mode can not return to user mode by
pure function return.

This commit applies exception return to resume the thread. The EPC and
IE are added into thread context. The xstatus_for_xret() helper function
is added to prepare the value of CSR STATUS for exception return.
Currently we only consider PIE(previous interrupt-enable) and
PP(previous privilege mode) for exception return.

We clear thread context when the context is reinitialized, enable native
interrupt, and setup kernel GP/TP. The thread_resume() now takes care of
restoring CSR EPC, STATUS, IE, SCRATCH and all general-purpose
registers. Finally it executes exception return to target privilege mode
encoded in CSR STATUS. The registers GP and TP are also restored since
user mode may use them.

This commit also modify the usage of CSR SCRATCH. In current
implementation the SCRATCH is used to save kernel stack pointer when the
thread is in user mode. The value of TP, which stores thread_core_local
structure, is saved into kernel stack before entering user mode. The
trap handler can then get TP(thread_core_local) from kernel stack. This
is not suitable for SMP system, since the thread might be resumed to
another core, and that core gets wrong TP from kernel stack. Fix it by
directly storing TP into CSR SCRATCH.

Signed-off-by: Alvin Chang <alvinga@andestech.com>
Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>
Tested-by: Marouene Boubakri <marouene.boubakri@nxp.com>

show more ...

fab37ad702-Mar-2024 Etienne Carriere <etienne.carriere@foss.st.com>

core: kernel: factorize delay and timeout implementation

Factorize RISC-V and Arm architectures implementation of delay and
timeout API functions into generic core kernel source directory.

Architec

core: kernel: factorize delay and timeout implementation

Factorize RISC-V and Arm architectures implementation of delay and
timeout API functions into generic core kernel source directory.

Architecture or platform only need to implement timer tick count
read function delay_cnt_read() and timer tick frequency (in Hertz)
delay_cnt_freq() which is related to CFG_CORE_HAS_GENERIC_TIMER support.

Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>

show more ...

51b745fa02-Mar-2024 Etienne Carriere <etienne.carriere@foss.st.com>

core: riscv: force enable of CFG_CORE_HAS_GENERIC_TIMER

Ensure CFG_CORE_HAS_GENERIC_TIMER is enabled for RISC-V architecture
since the current implementation provides the necessary routines
in delay

core: riscv: force enable of CFG_CORE_HAS_GENERIC_TIMER

Ensure CFG_CORE_HAS_GENERIC_TIMER is enabled for RISC-V architecture
since the current implementation provides the necessary routines
in delay_arch.h outside any configuration switch directive. This change
clarifies riscv based platforms configuration that previously depended
on CFG_CORE_HAS_GENERIC_TIMER default enabling from mk/config.mk.

Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>

show more ...

d1c9f59a03-Feb-2024 Yu Chien Peter Lin <peterlin@andestech.com>

riscv: sbi_console: prefer SBI v2.0 DBCN ecall over legacy sbi_console_putchar()

As the legacy sbi_console_putchar() may be deprecated in the future,
it is recommended to use sbi_dbcn_write_byte() p

riscv: sbi_console: prefer SBI v2.0 DBCN ecall over legacy sbi_console_putchar()

As the legacy sbi_console_putchar() may be deprecated in the future,
it is recommended to use sbi_dbcn_write_byte() provided by SBI v2.0
DBCN extension [1]. However, if the DBCN extension is not supported,
sbi_console_putchar() can still be used as the last resort.

Link: https://github.com/riscv-non-isa/riscv-sbi-doc/blob/v2.0/src/ext-debug-console.adoc#function-console-write-byte-fid-2 [1]
Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
Reviewed-by: Alvin Chang <alvinga@andestech.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>

show more ...

76a2df5704-Mar-2024 Yu Chien Peter Lin <peterlin@andestech.com>

riscv: sbi_console: remove unused sbi_console_flush()

sbi_console_flush() won't be implemented, remove the empty function.

Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
Reviewed-by: Al

riscv: sbi_console: remove unused sbi_console_flush()

sbi_console_flush() won't be implemented, remove the empty function.

Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
Reviewed-by: Alvin Chang <alvinga@andestech.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>

show more ...

db96d03004-Mar-2024 Yu Chien Peter Lin <peterlin@andestech.com>

riscv: sbi_console: remove global spinlock

sbi_console_putc() has been protected by puts_lock, so
remove the superfluous spinlock.

Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
Reviewe

riscv: sbi_console: remove global spinlock

sbi_console_putc() has been protected by puts_lock, so
remove the superfluous spinlock.

Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
Reviewed-by: Alvin Chang <alvinga@andestech.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>

show more ...

4d36f99e04-Mar-2024 Yu Chien Peter Lin <peterlin@andestech.com>

riscv: sbi_console: remove unneeded #ifdef CFG_RISCV_SBI_CONSOLE

sbi_console.c has been assigned conditionally based on
CFG_RISCV_SBI_CONSOLE in sub.mk. Remove the #ifdef preprocessor
directive.

Si

riscv: sbi_console: remove unneeded #ifdef CFG_RISCV_SBI_CONSOLE

sbi_console.c has been assigned conditionally based on
CFG_RISCV_SBI_CONSOLE in sub.mk. Remove the #ifdef preprocessor
directive.

Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
Reviewed-by: Alvin Chang <alvinga@andestech.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>

show more ...

1234567891011