Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Move pgd_alloc() out of header

pgd_alloc() references init_mm which is not exported to modules. In
order for KVM to be able to use pgd_alloc() to allocate GVA page tables,
move pgd_alloc() into a new pgtable.c file and export it to modules.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: linux-mips@linux-mips.org
Cc: kvm@vger.kernel.org

+27 -16
+1 -15
arch/mips/include/asm/pgalloc.h
··· 43 43 * Initialize a new pgd / pmd table with invalid pointers. 44 44 */ 45 45 extern void pgd_init(unsigned long page); 46 - 47 - static inline pgd_t *pgd_alloc(struct mm_struct *mm) 48 - { 49 - pgd_t *ret, *init; 50 - 51 - ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER); 52 - if (ret) { 53 - init = pgd_offset(&init_mm, 0UL); 54 - pgd_init((unsigned long)ret); 55 - memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD, 56 - (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t)); 57 - } 58 - 59 - return ret; 60 - } 46 + extern pgd_t *pgd_alloc(struct mm_struct *mm); 61 47 62 48 static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) 63 49 {
+1 -1
arch/mips/mm/Makefile
··· 4 4 5 5 obj-y += cache.o dma-default.o extable.o fault.o \ 6 6 gup.o init.o mmap.o page.o page-funcs.o \ 7 - tlbex.o tlbex-fault.o tlb-funcs.o 7 + pgtable.o tlbex.o tlbex-fault.o tlb-funcs.o 8 8 9 9 ifdef CONFIG_CPU_MICROMIPS 10 10 obj-y += uasm-micromips.o
+25
arch/mips/mm/pgtable.c
··· 1 + /* 2 + * This file is subject to the terms and conditions of the GNU General Public 3 + * License. See the file "COPYING" in the main directory of this archive 4 + * for more details. 5 + */ 6 + #include <linux/export.h> 7 + #include <linux/mm.h> 8 + #include <linux/string.h> 9 + #include <asm/pgalloc.h> 10 + 11 + pgd_t *pgd_alloc(struct mm_struct *mm) 12 + { 13 + pgd_t *ret, *init; 14 + 15 + ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER); 16 + if (ret) { 17 + init = pgd_offset(&init_mm, 0UL); 18 + pgd_init((unsigned long)ret); 19 + memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD, 20 + (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t)); 21 + } 22 + 23 + return ret; 24 + } 25 + EXPORT_SYMBOL_GPL(pgd_alloc);