Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion litebox_runner_lvbs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use litebox_platform_lvbs::{
serial_println,
};
use litebox_platform_multiplex::Platform;
use litebox_shim_optee::loader::ElfLoaderError;
use litebox_shim_optee::msg_handler::{
decode_ta_request, handle_optee_msg_args, handle_optee_smc_args, update_optee_msg_args,
};
Expand Down Expand Up @@ -711,6 +712,8 @@ fn open_session_new_instance(
client_identity: Option<litebox_common_optee::TeeIdentity>,
ta_req_info: &litebox_shim_optee::msg_handler::TaRequestInfo<PAGE_SIZE>,
) -> Result<(), OpteeSmcReturnCode> {
let ta_bin = find_ta_binary(ta_uuid).map_err(|_| OpteeSmcReturnCode::ENotAvail)?;

// Create and switch to new page table
let task_pt_id = create_task_page_table()?;

Expand Down Expand Up @@ -742,7 +745,7 @@ fn open_session_new_instance(
shim.load_ldelf(
LDELF_BINARY,
ta_uuid,
Some(TA_BINARY),
Some(ta_bin),
client_identity,
runner_session_id,
)
Expand Down Expand Up @@ -1299,6 +1302,21 @@ fn write_rpc_args_to_normal_world(
// use include_bytes! to include ldelf and (KMPP) TA binaries
const LDELF_BINARY: &[u8] = &[0u8; 0];
const TA_BINARY: &[u8] = &[0u8; 0];
const TA_BINARIES: &[&[u8]] = &[TA_BINARY];

// Look up TA binary by UUID.
fn find_ta_binary(ta_uuid: litebox_common_optee::TeeUuid) -> Result<&'static [u8], ElfLoaderError> {
use litebox_common_optee::parse_ta_head;

for ta_binary in TA_BINARIES {
if let Some(ta_head) = parse_ta_head(ta_binary)
&& ta_head.uuid == ta_uuid
{
return Ok(ta_binary);
}
}
Err(ElfLoaderError::InvalidUuid)
}

#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
Expand Down
2 changes: 2 additions & 0 deletions litebox_shim_optee/src/loader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
pub(crate) mod elf;
pub(crate) mod ta_stack;

pub use elf::ElfLoaderError;

/// The magic number used to identify the LiteBox rewriter and where we should
/// update the syscall callback pointer.
pub const REWRITER_MAGIC_NUMBER: u64 = u64::from_le_bytes(*b"LITE BOX");
Expand Down
Loading