Skip to content

Commit 873f5f6

Browse files
markz-zhangjforissier
authored andcommitted
core: mmu: Add dynamic VA regions' mapping to page table
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 <markz@nvidia.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
1 parent be4e760 commit 873f5f6

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

core/arch/arm/mm/core_mmu_lpae.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,7 @@ static void core_init_mmu_prtn_tee(struct mmu_partition *prtn,
803803
memset(prtn->base_tables, 0, BASE_TABLE_SIZE * CFG_TEE_CORE_NB_CORE);
804804

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

809808
/*
810809
* Primary mapping table is ready at index `get_core_pos()`

core/arch/arm/mm/core_mmu_v7.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,7 @@ void core_init_mmu_prtn(struct mmu_partition *prtn, struct memory_map *mem_map)
781781
memset(ttb1, 0, L1_TBL_SIZE);
782782

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

788787
void core_init_mmu(struct memory_map *mem_map)

core/arch/riscv/mm/core_mmu_arch.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,7 @@ static void core_init_mmu_prtn_tee(struct mmu_partition *prtn,
308308
memset(prtn->pool_pgts, 0, RISCV_MMU_MAX_PGTS * RISCV_MMU_PGT_SIZE);
309309

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

314313
/*
315314
* Primary mapping table is ready at index `get_core_pos()`

core/mm/core_mmu.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,14 @@ void core_mmu_map_region(struct mmu_partition *prtn, struct tee_mmap_region *mm)
20022002
panic("Page is already mapped");
20032003

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

0 commit comments

Comments
 (0)