Add handlers for OP-TEE TA request and execution result#564
Add handlers for OP-TEE TA request and execution result#564sangho2 wants to merge 52 commits intosanghle/lvbs/optee_msg_handler_1from
Conversation
bd37e2f to
9c7a30d
Compare
9c7a30d to
0f0c934
Compare
2cd83ef to
5b4fcf9
Compare
8b2b117 to
a91950e
Compare
a91950e to
8700931
Compare
| /// # Panics | ||
| /// | ||
| /// Panics if XSAVE areas are not allocated or if an invalid VTL value is provided. | ||
| pub fn save_extended_states(&self, vtl: u8) { |
There was a problem hiding this comment.
Intel calls it Extended States
litebox_runner_lvbs/src/lib.rs
Outdated
| vtl_switch_loop_entry(platform) | ||
| } | ||
|
|
||
| // Tentative OP-TEE message handler upcall implementation. |
There was a problem hiding this comment.
Nit: should we move this comment down to be right next to the implementation?
| ) -> Result<i64, litebox_common_linux::errno::Errno> { | ||
| let smc_args_addr: usize = smc_args_addr.truncate(); | ||
| match optee_msg_handler(smc_args_addr) { | ||
| Ok(smc_arg) => { |
There was a problem hiding this comment.
optee_msg_handler returns an smc_arg? I would expect a handler to return a result.
|
|
||
| #[inline] | ||
| fn page_align_down(address: u64) -> u64 { | ||
| fn page_align_down_u64(address: u64) -> u64 { |
There was a problem hiding this comment.
Why do we need to change the function name?
| data[1] = (msg_arg.get_param_value(0)?.b).truncate(); | ||
| data[2] = (msg_arg.get_param_value(1)?.a).truncate(); | ||
| data[3] = (msg_arg.get_param_value(1)?.b).truncate(); | ||
| (Some(TeeUuid::from_u32_array(data)), 2) |
| read_data_from_shm(&shm_info, &mut data)?; | ||
| UteeParamOwned::MemrefInput { data: data.into() } | ||
| } | ||
| OpteeMsgAttrType::TmemOutput | OpteeMsgAttrType::RmemOutput => { |
There was a problem hiding this comment.
Minot: It doesn't save much by first handling Tmem and Rmem together and then handling them separately. It might be easier to just handle each case one by one.
| /// Note that we use this function for handing TA requests and in this context | ||
| /// `OpteeMsgParamTmem` and `OpteeMsgParamRmem` are equivalent because every shared memory | ||
| /// reference accessible by TAs must be registered in advance. | ||
| /// `OpteeMsgParamTmem` is matter for the registration of shared memory regions. |
| /// | ||
| /// `rmem.offs` must be an offset within the shared memory region registered with `rmem.shm_ref` before | ||
| /// and `rmem.offs + rmem.size` must not exceed the size of the registered shared memory region. | ||
| /// All addresses this function returns are page aligned and virtually contiguous within the normal world but |
There was a problem hiding this comment.
If we don't trust the normal world, why does it matter if the memory is virtually contiguous in the normal world?
20a424a to
42500bb
Compare
|
Note. This PR cannot be easily merged because #555 has been changed a lot. I'll cherry pick it once approved. |
4cecf50 to
4d0df5e
Compare
|
Since this PR's base branch has been heavily changed, I'll close it and create a new PR. |
This PR adds handlers for OP-TEE TA request and its execution result. It also has a runner-side
controller that leverages all OP-TEE SMC/messages handlers to deal with OP-TEE calls from
the normal world. Currently, this controller is no-op because it should be invoked via
an upcall from the platform and it relies on run_thread, both are in different PRs.