@@ -90,6 +90,28 @@ pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
}
EXPORT_SYMBOL(phys_mem_access_prot);
+struct headpool {
+ phys_addr_t start;
+ unsigned long size;
+ unsigned long next_idx;
+};
+
+static struct headpool cur_pool __initdata;
+
+void __init set_cur_headpool(phys_addr_t start, unsigned long size)
+{
+ cur_pool.start = start;
+ cur_pool.size = size;
+ cur_pool.next_idx = 0;
+}
+
+phys_addr_t __init head_pgtable_alloc(unsigned long unused_a)
+{
+ unsigned long idx = cur_pool.next_idx++;
+
+ return cur_pool.start + (idx << PAGE_SHIFT);
+}
+
static phys_addr_t __init early_pgtable_alloc(int shift)
{
phys_addr_t phys;
When building a pgtable, __create_pgd_mapping() resorts to pgtable allocator to alloc mem. By introducing an allocator, __create_pgd_mapping() can consider both idmap_pg_dir and init_pg_dir as a memory pool, and get memory from them during the building of pgtable. Signed-off-by: Pingfan Liu <kernelfans@gmail.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will@kernel.org> Cc: Ard Biesheuvel <ardb@kernel.org> Cc: Marc Zyngier <maz@kernel.org> Cc: Kristina Martsenko <kristina.martsenko@arm.com> Cc: James Morse <james.morse@arm.com> Cc: Steven Price <steven.price@arm.com> Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Pavel Tatashin <pasha.tatashin@soleen.com> Cc: Anshuman Khandual <anshuman.khandual@arm.com> Cc: Atish Patra <atish.patra@wdc.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Logan Gunthorpe <logang@deltatee.com> Cc: Mark Brown <broonie@kernel.org> To: linux-arm-kernel@lists.infradead.org --- arch/arm64/mm/mmu.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)