Skip to content

Commit 15122ee

Browse files
wildea01ctmarinas
authored andcommitted
arm64: Enforce BBM for huge IO/VMAP mappings
ioremap_page_range doesn't honour break-before-make and attempts to put down huge mappings (using p*d_set_huge) over the top of pre-existing table entries. This leads to us leaking page table memory and also gives rise to TLB conflicts and spurious aborts, which have been seen in practice on Cortex-A75. Until this has been resolved, refuse to put block mappings when the existing entry is found to be present. Fixes: 324420b ("arm64: add support for ioremap() block mappings") Reported-by: Hanjun Guo <hanjun.guo@linaro.org> Reported-by: Lei Li <lious.lilei@hisilicon.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 0331365 commit 15122ee

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

arch/arm64/mm/mmu.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,11 @@ int pud_set_huge(pud_t *pudp, phys_addr_t phys, pgprot_t prot)
933933
{
934934
pgprot_t sect_prot = __pgprot(PUD_TYPE_SECT |
935935
pgprot_val(mk_sect_prot(prot)));
936+
937+
/* ioremap_page_range doesn't honour BBM */
938+
if (pud_present(READ_ONCE(*pudp)))
939+
return 0;
940+
936941
BUG_ON(phys & ~PUD_MASK);
937942
set_pud(pudp, pfn_pud(__phys_to_pfn(phys), sect_prot));
938943
return 1;
@@ -942,6 +947,11 @@ int pmd_set_huge(pmd_t *pmdp, phys_addr_t phys, pgprot_t prot)
942947
{
943948
pgprot_t sect_prot = __pgprot(PMD_TYPE_SECT |
944949
pgprot_val(mk_sect_prot(prot)));
950+
951+
/* ioremap_page_range doesn't honour BBM */
952+
if (pmd_present(READ_ONCE(*pmdp)))
953+
return 0;
954+
945955
BUG_ON(phys & ~PMD_MASK);
946956
set_pmd(pmdp, pfn_pmd(__phys_to_pfn(phys), sect_prot));
947957
return 1;

0 commit comments

Comments
 (0)