Skip to content

Commit

Permalink
core: mmu: Add dynamic VA regions' mapping to page table
Browse files Browse the repository at this point in the history
When optee boots, the initial mapping for MEM_AREA_RES_VASPACE and
MEM_AREA_SHM_VASPACE should be added into page tables and replicated to
all CPU cores too. This fixes an issue when the VA of
MEM_AREA_RES_VASPACE or MEM_AREA_SHM_VASPACE is not in a same 1GB region
with other memory regions.

Link: OP-TEE#7275
Signed-off-by: Mark Zhang <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
  • Loading branch information
markz-zhang authored and jforissier committed Feb 14, 2025
1 parent be4e760 commit 873f5f6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
3 changes: 1 addition & 2 deletions core/arch/arm/mm/core_mmu_lpae.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,8 +803,7 @@ static void core_init_mmu_prtn_tee(struct mmu_partition *prtn,
memset(prtn->base_tables, 0, BASE_TABLE_SIZE * CFG_TEE_CORE_NB_CORE);

for (n = 0; n < mem_map->count; n++)
if (!core_mmu_is_dynamic_vaspace(mem_map->map + n))
core_mmu_map_region(prtn, mem_map->map + n);
core_mmu_map_region(prtn, mem_map->map + n);

/*
* Primary mapping table is ready at index `get_core_pos()`
Expand Down
3 changes: 1 addition & 2 deletions core/arch/arm/mm/core_mmu_v7.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,7 @@ void core_init_mmu_prtn(struct mmu_partition *prtn, struct memory_map *mem_map)
memset(ttb1, 0, L1_TBL_SIZE);

for (n = 0; n < mem_map->count; n++)
if (!core_mmu_is_dynamic_vaspace(mem_map->map + n))
core_mmu_map_region(prtn, mem_map->map + n);
core_mmu_map_region(prtn, mem_map->map + n);
}

void core_init_mmu(struct memory_map *mem_map)
Expand Down
3 changes: 1 addition & 2 deletions core/arch/riscv/mm/core_mmu_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,7 @@ static void core_init_mmu_prtn_tee(struct mmu_partition *prtn,
memset(prtn->pool_pgts, 0, RISCV_MMU_MAX_PGTS * RISCV_MMU_PGT_SIZE);

for (n = 0; n < mem_map->count; n++)
if (!core_mmu_is_dynamic_vaspace(mem_map->map + n))
core_mmu_map_region(prtn, mem_map->map + n);
core_mmu_map_region(prtn, mem_map->map + n);

/*
* Primary mapping table is ready at index `get_core_pos()`
Expand Down
9 changes: 8 additions & 1 deletion core/mm/core_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2002,7 +2002,14 @@ void core_mmu_map_region(struct mmu_partition *prtn, struct tee_mmap_region *mm)
panic("Page is already mapped");

core_mmu_set_entry(&tbl_info, idx, paddr, mm->attr);
paddr += block_size;
/*
* Dynamic vaspace regions don't have a physical
* address initially but we need to allocate and
* initialize the translation tables now for later
* updates to work properly.
*/
if (paddr)
paddr += block_size;
vaddr += block_size;
size_left -= block_size;

Expand Down

0 comments on commit 873f5f6

Please sign in to comment.