arm64: mmu: implement arch_virt_region_align()
Add the arm64 MMU arch_virt_region_align() implementation used to return a possible virtual addres alignment in order to optimize the MMU table layout and possibly avoid using L3 tables and use some L1 & L3 blocks instead for most of the mapping. Suggested-by: Nicolas Pitre <npitre@baylibre.com> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
This commit is contained in:
parent
7830f87ccd
commit
c24d0c8405
1 changed files with 23 additions and 0 deletions
|
@ -943,6 +943,29 @@ int arch_page_phys_get(void *virt, uintptr_t *phys)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t arch_virt_region_align(uintptr_t phys, size_t size)
|
||||||
|
{
|
||||||
|
size_t alignment = CONFIG_MMU_PAGE_SIZE;
|
||||||
|
size_t level_size;
|
||||||
|
int level;
|
||||||
|
|
||||||
|
for (level = XLAT_LAST_LEVEL; level >= BASE_XLAT_LEVEL; level--) {
|
||||||
|
level_size = 1 << LEVEL_TO_VA_SIZE_SHIFT(level);
|
||||||
|
|
||||||
|
if (size < level_size) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((phys & (level_size - 1))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
alignment = level_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
return alignment;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_USERSPACE
|
#ifdef CONFIG_USERSPACE
|
||||||
|
|
||||||
static void z_arm64_swap_ptables(struct k_thread *incoming);
|
static void z_arm64_swap_ptables(struct k_thread *incoming);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue