[PATCH 05/10] arm64: mm: Force early mapping aligned on SWAPPER_BLOCK_SIZE

Pingfan Liu piliu at redhat.com
Wed Mar 13 05:57:03 PDT 2024


At this very early stage, the page table size is limited and
block-mapping is appealed.

Force the input param aligned on SWAPPER_BLOCK_SIZE, so that
__create_pgd_mapping_locked() can use the block-mapping scheme.

Signed-off-by: Pingfan Liu <piliu at redhat.com>
Cc: Ard Biesheuvel <ardb at kernel.org>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: Will Deacon <will at kernel.org>
Cc: Mark Rutland <mark.rutland at arm.com>
To: linux-arm-kernel at lists.infradead.org
---
 arch/arm64/mm/mmu_head.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm64/mm/mmu_head.c b/arch/arm64/mm/mmu_head.c
index 562d036dc30a..e00f6f2c7bec 100644
--- a/arch/arm64/mm/mmu_head.c
+++ b/arch/arm64/mm/mmu_head.c
@@ -60,5 +60,11 @@ void INSTRUMENT_OPTION mmu_head_create_pgd_mapping(pgd_t *pgdir, phys_addr_t phy
 					phys_addr_t (*pgtable_alloc)(int),
 					int flags)
 {
+	phys_addr_t end = phys + size;
+
+	phys = ALIGN_DOWN(phys, SWAPPER_BLOCK_SIZE);
+	virt = ALIGN_DOWN(virt, SWAPPER_BLOCK_SIZE);
+	end = ALIGN(end, SWAPPER_BLOCK_SIZE);
+	size = end - phys;
 	__create_pgd_mapping_locked(pgdir, phys, virt, size, prot, pgtable_alloc, flags);
 }
-- 
2.41.0




More information about the linux-arm-kernel mailing list