type
status
date
slug
summary
tags
category
icon
password
The code is based on: https://gitlab.com/riseproject/riscv-optee/linux/-/tree/dev-optee-mpxy
Commit ID:
df5dc01764820f113312f7a39f221b49985bbd7ado_initcalls()
sbi_mpxy_init()- Check SBI version and if MPXY extension is supported by OpenSBI.
- Setup CPUHP notifier to setup shared memory on all CPUs.
cpuhp_thread_fun()cpuhp_invoke_callback()
__sbi_mpxy_setup_shmem()- Allocates 4KB shared memory (4KB aligned).
- Call
sbi_mpxy_set_shmemSBI call to set up MPXY shared memory for the current core. This will invoke OpenSBI’ssbi_mpxy_set_shmem()to save the shared memory address and size into current hart domain’smpxy_state(Untrusted domain).
sbi_mpxy_tee_probe()- Check SBI version and whether MPXY extension is supported by OpenSBI.
- Get channel ID from DTS property:
riscv,sbi-mpxy-channel-id. - Read MPXY protocol ID attribute (
SBI_MPXY_ATTR_MSG_PROT_ID(0x0)) from channel withsbi_mpxy_read_attrs(). - Check if the returned MPXY protocol ID equals
SBI_MPXY_MSGPROTO_TEE_ID(0x2). Throw an error if not.
sbi_mpxy_read_attrs()- Disable preemption (
get_cpu()). - Shared memory is per-core. We only need to disable the preemption to prevent the shared memory of current CPU from being corrupted by the other tasks.
- Issue SBI call:
SBI_EXT_MPXY_READ_ATTRSto read the attribute. - If successful, copy the attribute from the shared memory to the buffer.
- Enable preemption (
put_cpu()).
sbi_mpxy_write_attrs()- Disable preemption (
get_cpu()). - Shared memory is per-core. We only need to disable the preemption to prevent the shared memory of current CPU from being corrupted by the other tasks.
- Copy the attribute from the buffer to the shared memory.
- Issue SBI call:
SBI_EXT_MPXY_WRITE_ATTRSto write the attribute. - Enable preemption (
put_cpu()).
sbi_mpxy_send_message_withresp()- Disable preemption (
get_cpu()). - Shared memory is per-core. We only need to disable the preemption to prevent the shared memory of current CPU from being corrupted by the other tasks.
- Issue SBI call:
SBI_EXT_MPXY_SEND_MSG_WITH_RESPwith message ID:OPTEED_MSG_COMMUNICATE(0x1) to send the message totdomainand get the response. - This will switch to OpenSBI: If message ID is
OPTEED_MSG_COMMUNICATE(0x1) (Called fromudomain):. OpenSBI will then switch to thetdomain. - Enable preemption (
put_cpu()).