diff mbox series

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

Message ID 20240313125711.20651-6-piliu@redhat.com (mailing list archive)
State New, archived
Headers show
Series arm64: mm: Use __create_pgd_mapping_locked() in | expand

Commit Message

Pingfan Liu March 13, 2024, 12:57 p.m. UTC
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@redhat.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
To: linux-arm-kernel@lists.infradead.org
---
 arch/arm64/mm/mmu_head.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

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);
 }