Message ID | 20240814154427.162475-3-willy@infradead.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Provide a single definition of mk_pte() | expand |
Hi Matthew, kernel test robot noticed the following build errors: [auto build test ERROR on geert-m68k/for-next] [also build test ERROR on geert-m68k/for-linus uml/next linus/master v6.11-rc3 next-20240814] [cannot apply to uml/fixes] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Matthew-Wilcox-Oracle/mm-Introduce-a-common-definition-of-mk_pte/20240815-001852 base: https://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k.git for-next patch link: https://lore.kernel.org/r/20240814154427.162475-3-willy%40infradead.org patch subject: [PATCH 2/5] x86: Remove custom definition of mk_pte() config: x86_64-buildonly-randconfig-003-20240815 (https://download.01.org/0day-ci/archive/20240815/202408151133.BaOdxDkR-lkp@intel.com/config) compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240815/202408151133.BaOdxDkR-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202408151133.BaOdxDkR-lkp@intel.com/ All errors (new ones prefixed by >>): In file included from arch/x86/kernel/asm-offsets.c:14: In file included from include/linux/suspend.h:5: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:21: In file included from include/linux/mm.h:30: >> include/linux/pgtable.h:47:17: error: call to undeclared function 'page_to_section'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 47 | return pfn_pte(page_to_pfn(page), pgprot); | ^ include/asm-generic/memory_model.h:64:21: note: expanded from macro 'page_to_pfn' 64 | #define page_to_pfn __page_to_pfn | ^ include/asm-generic/memory_model.h:47:14: note: expanded from macro '__page_to_pfn' 47 | int __sec = page_to_section(__pg); \ | ^ include/linux/pgtable.h:47:17: note: did you mean '__nr_to_section'? include/asm-generic/memory_model.h:64:21: note: expanded from macro 'page_to_pfn' 64 | #define page_to_pfn __page_to_pfn | ^ include/asm-generic/memory_model.h:47:14: note: expanded from macro '__page_to_pfn' 47 | int __sec = page_to_section(__pg); \ | ^ include/linux/mmzone.h:1853:35: note: '__nr_to_section' declared here 1853 | static inline struct mem_section *__nr_to_section(unsigned long nr) | ^ In file included from arch/x86/kernel/asm-offsets.c:14: In file included from include/linux/suspend.h:5: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:21: >> include/linux/mm.h:1904:29: error: static declaration of 'page_to_section' follows non-static declaration 1904 | static inline unsigned long page_to_section(const struct page *page) | ^ include/linux/pgtable.h:47:17: note: previous implicit declaration is here 47 | return pfn_pte(page_to_pfn(page), pgprot); | ^ include/asm-generic/memory_model.h:64:21: note: expanded from macro 'page_to_pfn' 64 | #define page_to_pfn __page_to_pfn | ^ include/asm-generic/memory_model.h:47:14: note: expanded from macro '__page_to_pfn' 47 | int __sec = page_to_section(__pg); \ | ^ 2 errors generated. make[3]: *** [scripts/Makefile.build:117: arch/x86/kernel/asm-offsets.s] Error 1 shuffle=262036656 make[3]: Target 'prepare' not remade because of errors. make[2]: *** [Makefile:1208: prepare0] Error 2 shuffle=262036656 make[2]: Target 'prepare' not remade because of errors. make[1]: *** [Makefile:240: __sub-make] Error 2 shuffle=262036656 make[1]: Target 'prepare' not remade because of errors. make: *** [Makefile:240: __sub-make] Error 2 shuffle=262036656 make: Target 'prepare' not remade because of errors. vim +/page_to_section +47 include/linux/pgtable.h 1c2f7d14d84f767 Anshuman Khandual 2021-06-30 43 9353c36cfa235ae Matthew Wilcox (Oracle 2024-08-14 44) #ifndef mk_pte 9353c36cfa235ae Matthew Wilcox (Oracle 2024-08-14 45) static inline pte_t mk_pte(struct page *page, pgprot_t pgprot) 9353c36cfa235ae Matthew Wilcox (Oracle 2024-08-14 46) { 9353c36cfa235ae Matthew Wilcox (Oracle 2024-08-14 @47) return pfn_pte(page_to_pfn(page), pgprot); 9353c36cfa235ae Matthew Wilcox (Oracle 2024-08-14 48) } 9353c36cfa235ae Matthew Wilcox (Oracle 2024-08-14 49) #endif 9353c36cfa235ae Matthew Wilcox (Oracle 2024-08-14 50)
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index a7c1e9cfea41..59baf4e183b2 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -760,6 +760,9 @@ static inline pgprotval_t check_pgprot(pgprot_t pgprot) static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot) { phys_addr_t pfn = (phys_addr_t)page_nr << PAGE_SHIFT; + /* This bit combination is used to mark shadow stacks */ + WARN_ON_ONCE((pgprot_val(pgprot) & (_PAGE_DIRTY | _PAGE_RW)) == + _PAGE_DIRTY); pfn ^= protnone_mask(pgprot_val(pgprot)); pfn &= PTE_PFN_MASK; return __pte(pfn | check_pgprot(pgprot)); @@ -1056,22 +1059,6 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd) */ #define pmd_page(pmd) pfn_to_page(pmd_pfn(pmd)) -/* - * Conversion functions: convert a page and protection to a page entry, - * and a page entry and page directory to the page they refer to. - * - * (Currently stuck as a macro because of indirect forward reference - * to linux/mm.h:page_to_nid()) - */ -#define mk_pte(page, pgprot) \ -({ \ - pgprot_t __pgprot = pgprot; \ - \ - WARN_ON_ONCE((pgprot_val(__pgprot) & (_PAGE_DIRTY | _PAGE_RW)) == \ - _PAGE_DIRTY); \ - pfn_pte(page_to_pfn(page), __pgprot); \ -}) - static inline int pmd_bad(pmd_t pmd) { return (pmd_flags(pmd) & ~(_PAGE_USER | _PAGE_ACCESSED)) !=
Move the shadow stack check to pfn_pte() which lets us use the common definition of mk_pte(). Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> --- arch/x86/include/asm/pgtable.h | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-)