From 9846ae4c121a47845a963f23f29ac026c6c5f684 Mon Sep 17 00:00:00 2001 From: AlieZ22 <820460891@qq.com> Date: Sat, 17 Sep 2022 00:25:21 +0800 Subject: [PATCH] arm64/mm: fix page table check compile error for CONFIG_PGTABLE_LEVELS=2 mainline inclusion from mainline-v6.0 commit ed928a3402d8a24a70c242c63109c069a7b1f3ab category: feature bugzilla: https://gitee.com/openeuler/open-source-summer/issues/I56FG1?from=project-issue CVE: N/A Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ed928a3402d8a24a70c242c63109c069a7b1f3ab ------------------------------------------------- If CONFIG_PGTABLE_LEVELS=2 and CONFIG_ARCH_SUPPORTS_PAGE_TABLE_CHECK=y, then we trigger a compile error: error: implicit declaration of function 'pte_user_accessible_page' Move the definition of page table check helper out of branch CONFIG_PGTABLE_LEVELS > 2 Link: https://lkml.kernel.org/r/20220517074548.2227779-3-tongtiangen@huawei.com Fixes: daf214c14dbe ("arm64/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK") Signed-off-by: Tong Tiangen Acked-by: Catalin Marinas Cc: Anshuman Khandual Cc: Pasha Tatashin Cc: Anshuman Khandual Cc: Will Deacon Cc: Paul Walmsley Cc: Palmer Dabbelt Cc: Albert Ou Cc: Arnd Bergmann Cc: Guohanjun Cc: Xie XiuQi Cc: kernel test robot Signed-off-by: Andrew Morton (cherry picked from commit ed928a3402d8a24a70c242c63109c069a7b1f3ab) Signed-off-by: Kefeng Wang Signed-off-by: Zeng Zhimin --- arch/arm64/include/asm/pgtable.h | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 4f94892e312f..e9ef73849896 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -633,23 +633,6 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd) #define pud_valid(pud) pte_valid(pud_pte(pud)) #define pud_user(pud) pte_user(pud_pte(pud)) -#ifdef CONFIG_PAGE_TABLE_CHECK -static inline bool pte_user_accessible_page(pte_t pte) -{ - return pte_present(pte) && (pte_user(pte) || pte_user_exec(pte)); -} - -static inline bool pmd_user_accessible_page(pmd_t pmd) -{ - return pmd_present(pmd) && (pmd_user(pmd) || pmd_user_exec(pmd)); -} - -static inline bool pud_user_accessible_page(pud_t pud) -{ - return pud_present(pud) && pud_user(pud); -} -#endif - static inline void set_pud(pud_t *pudp, pud_t pud) { #ifdef __PAGETABLE_PUD_FOLDED @@ -821,6 +804,23 @@ static inline int pgd_devmap(pgd_t pgd) } #endif +#ifdef CONFIG_PAGE_TABLE_CHECK +static inline bool pte_user_accessible_page(pte_t pte) +{ + return pte_present(pte) && (pte_user(pte) || pte_user_exec(pte)); +} + +static inline bool pmd_user_accessible_page(pmd_t pmd) +{ + return pmd_present(pmd) && (pmd_user(pmd) || pmd_user_exec(pmd)); +} + +static inline bool pud_user_accessible_page(pud_t pud) +{ + return pud_present(pud) && pud_user(pud); +} +#endif + /* * Atomic pte/pmd modifications. */ -- GitLab