2017-02-02 01:21:35 +00:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
#include <linux/export.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <asm/pgalloc.h>
|
|
|
|
|
|
|
|
pgd_t *pgd_alloc(struct mm_struct *mm)
|
|
|
|
{
|
|
|
|
pgd_t *ret, *init;
|
|
|
|
|
2022-07-03 17:11:55 +03:00
|
|
|
ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_TABLE_ORDER);
|
2017-02-02 01:21:35 +00:00
|
|
|
if (ret) {
|
|
|
|
init = pgd_offset(&init_mm, 0UL);
|
2022-10-27 20:52:50 +08:00
|
|
|
pgd_init(ret);
|
2017-02-02 01:21:35 +00:00
|
|
|
memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD,
|
|
|
|
(PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(pgd_alloc);
|