Architectures whose empty kernel PTE representation is not all zero must initialize new kernel PTE tables. LoongArch therefore wraps __pte_alloc_one_kernel() solely to call kernel_pte_init(). Call the architecture initialization hook from the generic allocator so LoongArch can use it directly. The default hook is empty, so this does not change other architectures. Assisted-by: LLM Signed-off-by: Muchun Song --- arch/loongarch/include/asm/pgalloc.h | 11 ----------- include/asm-generic/pgalloc.h | 6 +++++- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/arch/loongarch/include/asm/pgalloc.h b/arch/loongarch/include/asm/pgalloc.h index 248f62d0b590..a3f93a8b58be 100644 --- a/arch/loongarch/include/asm/pgalloc.h +++ b/arch/loongarch/include/asm/pgalloc.h @@ -10,7 +10,6 @@ #define __HAVE_ARCH_PMD_ALLOC_ONE #define __HAVE_ARCH_PUD_ALLOC_ONE -#define __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL #include static inline void pmd_populate_kernel(struct mm_struct *mm, @@ -45,16 +44,6 @@ extern void pagetable_init(void); extern pgd_t *pgd_alloc(struct mm_struct *mm); -static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm) -{ - pte_t *pte = __pte_alloc_one_kernel(mm); - - if (pte) - kernel_pte_init(pte); - - return pte; -} - #define __pte_free_tlb(tlb, pte, address) tlb_remove_ptdesc((tlb), page_ptdesc(pte)) #ifndef __PAGETABLE_PMD_FOLDED diff --git a/include/asm-generic/pgalloc.h b/include/asm-generic/pgalloc.h index 051aa1331051..a1de7d246754 100644 --- a/include/asm-generic/pgalloc.h +++ b/include/asm-generic/pgalloc.h @@ -19,6 +19,7 @@ static inline pte_t *__pte_alloc_one_kernel_noprof(struct mm_struct *mm) { struct ptdesc *ptdesc = pagetable_alloc_noprof(GFP_PGTABLE_KERNEL, 0); + pte_t *pte; if (!ptdesc) return NULL; @@ -29,7 +30,10 @@ static inline pte_t *__pte_alloc_one_kernel_noprof(struct mm_struct *mm) ptdesc_set_kernel(ptdesc); - return ptdesc_address(ptdesc); + pte = ptdesc_address(ptdesc); + kernel_pte_init(pte); + + return pte; } #define __pte_alloc_one_kernel(...) alloc_hooks(__pte_alloc_one_kernel_noprof(__VA_ARGS__)) -- 2.54.0