1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Linux architectural port borrowing liberally from similar works of
6 * others. All original copyrights apply as per the original source
9 * Modifications for the OpenRISC architecture:
14 #include <linux/vmalloc.h>
16 #include <linux/pgtable.h>
17 #include <asm/pgalloc.h>
18 #include <asm/fixmap.h>
20 #include <linux/sched.h>
21 #include <asm/tlbflush.h>
23 extern int mem_init_done;
26 * OK, this one's a bit tricky... ioremap can get called before memory is
27 * initialized (early serial console does this) and will want to alloc a page
28 * for its mapping. No userspace pages will ever get allocated before memory
29 * is initialized so this applies only to kernel pages. In the event that
30 * this is called before memory is initialized we allocate the page using
31 * the memblock infrastructure.
34 pte_t __ref *pte_alloc_one_kernel(struct mm_struct *mm)
38 if (likely(mem_init_done)) {
39 pte = (pte_t *)get_zeroed_page(GFP_KERNEL);
41 pte = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
43 panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
44 __func__, PAGE_SIZE, PAGE_SIZE);