1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _LINUX_PGALLOC_H 3 #define _LINUX_PGALLOC_H 4 5 #include <linux/pgtable.h> 6 #include <asm/pgalloc.h> 7 8 /* 9 * {pgd,p4d}_populate_kernel() are defined as macros to allow 10 * compile-time optimization based on the configured page table levels. 11 * Without this, linking may fail because callers (e.g., KASAN) may rely 12 * on calls to these functions being optimized away when passing symbols 13 * that exist only for certain page table levels. 14 */ 15 #define pgd_populate_kernel(addr, pgd, p4d) \ 16 do { \ 17 pgd_populate(&init_mm, pgd, p4d); \ 18 if (ARCH_PAGE_TABLE_SYNC_MASK & PGTBL_PGD_MODIFIED) \ 19 arch_sync_kernel_mappings(addr, addr); \ 20 } while (0) 21 22 #define p4d_populate_kernel(addr, p4d, pud) \ 23 do { \ 24 p4d_populate(&init_mm, p4d, pud); \ 25 if (ARCH_PAGE_TABLE_SYNC_MASK & PGTBL_P4D_MODIFIED) \ 26 arch_sync_kernel_mappings(addr, addr); \ 27 } while (0) 28 29 #endif /* _LINUX_PGALLOC_H */ 30