Skip to content

Support OP-TEE dynamic shared memory#714

Open
athvu wants to merge 1 commit intomainfrom
avu/test_ta
Open

Support OP-TEE dynamic shared memory#714
athvu wants to merge 1 commit intomainfrom
avu/test_ta

Conversation

@athvu
Copy link
Contributor

@athvu athvu commented Mar 11, 2026

No description provided.

@github-actions
Copy link

🤖 SemverChecks 🤖 ⚠️ Potential breaking API changes detected ⚠️

Click for details
--- failure enum_struct_variant_field_added: pub enum struct variant field added ---

Description:
An enum's exhaustive struct variant has a new field, which has to be included when constructing or matching on this variant.
        ref: https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.47.0/src/lints/enum_struct_variant_field_added.ron

Failed in:
  field msg_args_phys_addr of variant OpteeSmcResult::CallWithArg in /home/runner/work/litebox/litebox/litebox_common_optee/src/lib.rs:2137

Copy link
Contributor

@sangho2 sangho2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks!

I've left some minor comments. Also, it would be great if this PR has some description :)

#[derive(Clone, Copy, Default, FromBytes)]
pub struct OpteeSmcArgs {
args: [usize; Self::NUM_OPTEE_SMC_ARGS],
pub args: [usize; Self::NUM_OPTEE_SMC_ARGS],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it require pub?

Comment on lines +207 to +208
let page_index = (shm_info.page_offset + offset) / PAGE_SIZE;
let offset_in_page = (shm_info.page_offset + offset) % PAGE_SIZE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might better to do shm_info.page_offset.checked_add(offset).ok_or(OpteeSmcReturnCode::EBadAddr)?; to deal with potential integer overflow attacks. Also, we don't have to compute this twice.

}
let msg_args_addr = shm_info.page_addrs[page_index].as_usize() + offset_in_page;

let (msg_args, rpc_args) = read_optee_msg_args_from_phys(msg_args_addr, true)?;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LiteBox has read_data_from_shm which reads from offset 0. Could you add another method to read with an offset and use that method here?

msg_args_phys_addr: msg_args_addr as u64,
})
}
OpteeSmcFunction::CallWithRegdArg => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curios, when is this method invoked?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the VTL0 side, the optee_smc_do_call_with_arg() function will pass OPTEE_SMC_CALL_WITH_REGD_ARG if the tee shared memory was dynamically allocated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants