Skip to content

Commit a64293e

Browse files
ardbiesheuvelwilldeacon
authored andcommitted
arm64: mm: Preserve existing table mappings when mapping DRAM
Instead of blindly overwriting an existing table entry when mapping DRAM regions, take care not to replace a pre-existing table entry with a block entry. This permits the logic of mapping the kernel's linear alias to be simplified in a subsequent patch. Reviewed-by: Ryan Roberts <ryan.roberts@arm.com> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Will Deacon <will@kernel.org>
1 parent 8dd640d commit a64293e

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

arch/arm64/mm/mmu.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ static int init_pmd(pmd_t *pmdp, unsigned long addr, unsigned long end,
256256

257257
/* try section mapping first */
258258
if (((addr | next | phys) & ~PMD_MASK) == 0 &&
259-
(flags & NO_BLOCK_MAPPINGS) == 0) {
259+
(flags & NO_BLOCK_MAPPINGS) == 0 &&
260+
!pmd_table(old_pmd)) {
260261
WARN_ON(!pmd_set_huge(pmdp, phys, prot));
261262

262263
/*
@@ -379,7 +380,8 @@ static int alloc_init_pud(p4d_t *p4dp, unsigned long addr, unsigned long end,
379380
*/
380381
if (pud_sect_supported() &&
381382
((addr | next | phys) & ~PUD_MASK) == 0 &&
382-
(flags & NO_BLOCK_MAPPINGS) == 0) {
383+
(flags & NO_BLOCK_MAPPINGS) == 0 &&
384+
!pud_table(old_pud)) {
383385
WARN_ON(!pud_set_huge(pudp, phys, prot));
384386

385387
/*

0 commit comments

Comments
 (0)