Skip to content

Commit

Permalink
core: mm: allow unmapping VCORE_FREE
Browse files Browse the repository at this point in the history
Allow unmapping core memory in the VCORE_FREE range when the original
boot mapping isn't needed any more.

Signed-off-by: Jens Wiklander <[email protected]>
Reviewed-by: Jerome Forissier <[email protected]>
Reviewed-by: Etienne Carriere <[email protected]>
  • Loading branch information
jenswi-linaro authored and jforissier committed Dec 12, 2024
1 parent a5ac48d commit 06a2580
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/mm/core_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,12 @@ TEE_Result core_mmu_map_contiguous_pages(vaddr_t vstart, paddr_t pstart,
return TEE_SUCCESS;
}

static bool mem_range_is_in_vcore_free(vaddr_t vstart, size_t num_pages)
{
return core_is_buffer_inside(vstart, num_pages * SMALL_PAGE_SIZE,
VCORE_FREE_PA, VCORE_FREE_SZ);
}

void core_mmu_unmap_pages(vaddr_t vstart, size_t num_pages)
{
struct core_mmu_table_info tbl_info;
Expand All @@ -2071,7 +2077,8 @@ void core_mmu_unmap_pages(vaddr_t vstart, size_t num_pages)
if (!mm || !va_is_in_map(mm, vstart + num_pages * SMALL_PAGE_SIZE - 1))
panic("VA does not belong to any known mm region");

if (!core_mmu_is_dynamic_vaspace(mm))
if (!core_mmu_is_dynamic_vaspace(mm) &&
!mem_range_is_in_vcore_free(vstart, num_pages))
panic("Trying to unmap static region");

for (i = 0; i < num_pages; i++, vstart += SMALL_PAGE_SIZE) {
Expand Down

0 comments on commit 06a2580

Please sign in to comment.