type
status
date
slug
summary
tags
category
icon
password
The code is based on: https://gitlab.com/riseproject/riscv-optee/optee_os/-/tree/dev-optee-mpxy
Commit ID:
75df9ba41a404aec897399ead0ff0aebcbff48ca
tee_ta_init_user_ta_session()
- Initialize user TA for the UUID, assign
ctx->ts_ctx.ops
touser_ta_ops
by callingset_ta_ctx_ops()
.user_ta_ops
will be the global callbacks for the user TAs; assigntee_ta_session->ts_sess.handle_scall
toscall_handle_user_ta()
.scall_handle_user_ta()
will be the default callback to handle the syscall from user TA:
tee_ta_complete_user_ta_session()
- Call
ldelf_load_ldelf()
to loadldelf
program to the memory for this User TA. ldelf
is responsible for loading the user TA ELF image residing in REE to the memory.- If
ldelf_load_ldelf()
returnsTEE_SUCCESS
, callldelf_init_with_ldelf()
ldelf_load_ldelf()
loads user TA ELF and fill in user TA ELF’s information tostruct user_mode_ctx
.
user_ta_enter_open_session()
- Call
user_ta_enter()
with function ID:UTEE_ENTRY_FUNC_OPEN_SESSION
.
user_ta_enter_invoke_cmd()
- Call
user_ta_enter()
with function ID:UTEE_ENTRY_FUNC_INVOKE_COMMAND
.
user_ta_enter()
- Call
thread_enter_user_mode()
to switch to U-mode.utc->utcx.entry_func
(user TA’s entry function address, filled byldelf
) will be called after switching to U-mode. - E.g. For
optee_example_hello_world
, i.e.8aaaf200-2450-11e4-abe2-0002a5d5c51b.elf
, theentry_func
is0x400405f8
=>__ta_entry().
__ta_entry()
is the first user TA API called from TEE core (defined inta/user_ta_header.c
).- It’s assigned in TA’s Makefile:
__ta_entry()
will call__utee_entry()
(defined inlib/libutee/user_ta_entry.c
) to invoke the function (e.g.TA_OpenSessionEntryPoint()
,TA_InvokeCommandEntryPoint()
… etc) defined by user TA based on function ID.- User TA is linked with
libutee
. - And the end,
__ta_entry()
will call__utee_return()
(defined inlib/libutee/user_ta_entry.c
), to return from user TA. __utee_return()
is actually a syscall, syscall ID:TEE_SCN_RETURN
. Therefore,tee_ta_session->ts_sess.handle_scall
, e.g.scall_handle_user_ta()
, will eventually be called.
scall_handle_user_ta()
:- Handle syscall according to
tee_syscall_table
: