1814f91bfSJames Hogan /* 2814f91bfSJames Hogan * This file is subject to the terms and conditions of the GNU General Public 3814f91bfSJames Hogan * License. See the file "COPYING" in the main directory of this archive 4814f91bfSJames Hogan * for more details. 5814f91bfSJames Hogan */ 6814f91bfSJames Hogan #include <linux/export.h> 7814f91bfSJames Hogan #include <linux/mm.h> 8814f91bfSJames Hogan #include <linux/string.h> 9814f91bfSJames Hogan #include <asm/pgalloc.h> 10814f91bfSJames Hogan pgd_alloc(struct mm_struct * mm)11814f91bfSJames Hoganpgd_t *pgd_alloc(struct mm_struct *mm) 12814f91bfSJames Hogan { 13*3e14fb19SVishal Moola (Oracle) pgd_t *init, *ret = NULL; 14*3e14fb19SVishal Moola (Oracle) struct ptdesc *ptdesc = pagetable_alloc(GFP_KERNEL & ~__GFP_HIGHMEM, 15*3e14fb19SVishal Moola (Oracle) PGD_TABLE_ORDER); 16814f91bfSJames Hogan 17*3e14fb19SVishal Moola (Oracle) if (ptdesc) { 18*3e14fb19SVishal Moola (Oracle) ret = ptdesc_address(ptdesc); 19814f91bfSJames Hogan init = pgd_offset(&init_mm, 0UL); 2022c4e804SFeiyang Chen pgd_init(ret); 21814f91bfSJames Hogan memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD, 22814f91bfSJames Hogan (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t)); 23814f91bfSJames Hogan } 24814f91bfSJames Hogan 25814f91bfSJames Hogan return ret; 26814f91bfSJames Hogan } 27814f91bfSJames Hogan EXPORT_SYMBOL_GPL(pgd_alloc); 28