Skip to content

Commit de93e05

Browse files
mrutland-armAlex Shi
authored andcommitted
arm64: mm: avoid redundant __pa(__va(x))
When we "upgrade" to a section mapping, we free any table we made redundant by giving it back to memblock. To get the PA, we acquire the physical address and convert this to a VA, then subsequently convert this back to a PA. This works currently, but will not work if the tables are not accessed via linear map VAs (e.g. is we use fixmap slots). This patch uses {pmd,pud}_page_paddr to acquire the PA. This avoids the __pa(__va()) round trip, saving some work and avoiding reliance on the linear mapping. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Jeremy Linton <jeremy.linton@arm.com> Cc: Laura Abbott <labbott@fedoraproject.org> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> (cherry picked from commit 316b39db06718d59d82736df9fc65cf05b467cc7) Signed-off-by: Alex Shi <alex.shi@linaro.org>
1 parent 98b513e commit de93e05

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

arch/arm64/mm/mmu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static void alloc_init_pmd(struct mm_struct *mm, pud_t *pud,
171171
if (!pmd_none(old_pmd)) {
172172
flush_tlb_all();
173173
if (pmd_table(old_pmd)) {
174-
phys_addr_t table = __pa(pte_offset_map(&old_pmd, 0));
174+
phys_addr_t table = pmd_page_paddr(old_pmd);
175175
if (!WARN_ON_ONCE(slab_is_available()))
176176
memblock_free(table, PAGE_SIZE);
177177
}
@@ -232,7 +232,7 @@ static void alloc_init_pud(struct mm_struct *mm, pgd_t *pgd,
232232
if (!pud_none(old_pud)) {
233233
flush_tlb_all();
234234
if (pud_table(old_pud)) {
235-
phys_addr_t table = __pa(pmd_offset(&old_pud, 0));
235+
phys_addr_t table = pud_page_paddr(old_pud);
236236
if (!WARN_ON_ONCE(slab_is_available()))
237237
memblock_free(table, PAGE_SIZE);
238238
}

0 commit comments

Comments
 (0)