If address passed arm_create_pte() is not 1M (PGDIR_SIZE) aligned, page table that is created will end up having unexpected mapping offset, breaking "1:1 mapping" assumption and leading to bugs that are not immediately obvious in their nature. To prevent this and because all of the callers already do said alignement in-place, move the alignment code to be a part of are_create_pte(). Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx> --- arch/arm/cpu/mmu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c index 1713238ad..21394deb1 100644 --- a/arch/arm/cpu/mmu.c +++ b/arch/arm/cpu/mmu.c @@ -92,6 +92,8 @@ static u32 *arm_create_pte(unsigned long virt, uint32_t flags) u32 *table; int i; + virt = ALIGN_DOWN(virt, PGDIR_SIZE); + table = xmemalign(PTRS_PER_PTE * sizeof(u32), PTRS_PER_PTE * sizeof(u32)); @@ -291,8 +293,7 @@ static void create_vector_table(unsigned long adr) vectors = xmemalign(PAGE_SIZE, PAGE_SIZE); pr_debug("Creating vector table, virt = 0x%p, phys = 0x%08lx\n", vectors, adr); - exc = arm_create_pte(ALIGN_DOWN(adr, PGDIR_SIZE), - pte_flags_uncached); + exc = arm_create_pte(adr, pte_flags_uncached); idx = (adr & (PGDIR_SIZE - 1)) >> PAGE_SHIFT; exc[idx] = (u32)vectors | PTE_TYPE_SMALL | pte_flags_cached; } -- 2.17.0 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox