Skip to content

Commit

Permalink
td-payload: check the size for init_shared_memory
Browse files Browse the repository at this point in the history
The size needs to be aligned with 4KiB, panic if not.

Signed-off-by: Jiaqi Gao <[email protected]>
  • Loading branch information
gaojiaqi7 authored and jyao1 committed Mar 4, 2024
1 parent dec6f6b commit 36a9200
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions td-payload/src/mm/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ use crate::arch::shared::decrypt;
static SHARED_MEMORY_ALLOCATOR: LockedHeap = LockedHeap::empty();

pub fn init_shared_memory(start: u64, size: usize) {
if size % SIZE_4K != 0 {
panic!("Failed to initialize shared memory: size needs to be aligned with 0x1000");
}

// Set the shared memory region to be shared
decrypt(start, size);
// Initialize the shared memory allocator
Expand Down

0 comments on commit 36a9200

Please sign in to comment.