Skip to contentSkip to conversation

mm-introduce-a-common-definition-of-mk_pte.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message May 12, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm: introduce a common definition of mk_pte()
has been removed from the -mm tree. Its filename was
mm-introduce-a-common-definition-of-mk_pte.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: "Matthew Wilcox (Oracle)" <[email protected]>
Subject: mm: introduce a common definition of mk_pte()
Date: Wed, 2 Apr 2025 19:16:56 +0100

Most architectures simply call pfn_pte(). Centralise that as the normal definition and remove the definition of mk_pte() from the architectures which have either that exact definition or something similar.

---

 arch/alpha/include/asm/pgtable.h         |    7 -------
 arch/arc/include/asm/pgtable-levels.h    |    1 -
 arch/arm/include/asm/pgtable.h           |    1 -
 arch/arm64/include/asm/pgtable.h         |    6 ------
 arch/csky/include/asm/pgtable.h          |    5 -----
 arch/hexagon/include/asm/pgtable.h       |    3 ---
 arch/loongarch/include/asm/pgtable.h     |    6 ------
 arch/m68k/include/asm/mcf_pgtable.h      |    6 ------
 arch/m68k/include/asm/motorola_pgtable.h |    6 ------
 arch/m68k/include/asm/sun3_pgtable.h     |    6 ------
 arch/microblaze/include/asm/pgtable.h    |    8 --------
 arch/mips/include/asm/pgtable.h          |    6 ------
 arch/nios2/include/asm/pgtable.h         |    6 ------
 arch/openrisc/include/asm/pgtable.h      |    2 --
 arch/parisc/include/asm/pgtable.h        |    6 ------
 arch/powerpc/include/asm/pgtable.h       |    3 +--
 arch/riscv/include/asm/pgtable.h         |    2 --
 arch/s390/include/asm/pgtable.h          |    5 -----
 arch/sh/include/asm/pgtable_32.h         |    8 --------
 arch/sparc/include/asm/pgtable_64.h      |    1 -
 arch/xtensa/include/asm/pgtable.h        |    6 ------
 include/linux/mm.h                       |    9 +++++++++
 22 files changed, 10 insertions(+), 99 deletions(-)
arch/alpha/include/asm/pgtable.h renamed from arch/alpha/include/asm/pgtable.h~mm-introduce-a-common-definition-of-mk_pte +0 -7
@@ -192,13 +192,6 @@ extern unsigned long __zero_page(void);
 #define pte_pfn(pte)		(pte_val(pte) >> PFN_PTE_SHIFT)
 
 #define pte_page(pte)	pfn_to_page(pte_pfn(pte))
-#define mk_pte(page, pgprot)						\
-({									\
-	pte_t pte;							\
-									\
-	pte_val(pte) = (page_to_pfn(page) << 32) | pgprot_val(pgprot);	\
-	pte;								\
-})
 
 extern inline pte_t pfn_pte(unsigned long physpfn, pgprot_t pgprot)
 { pte_t pte; pte_val(pte) = (PHYS_TWIDDLE(physpfn) << 32) | pgprot_val(pgprot); return pte; }
arch/arc/include/asm/pgtable-levels.h renamed from arch/arc/include/asm/pgtable-levels.h~mm-introduce-a-common-definition-of-mk_pte +0 -1
@@ -177,7 +177,6 @@
 #define set_pte(ptep, pte)	((*(ptep)) = (pte))
 #define pte_pfn(pte)		(pte_val(pte) >> PAGE_SHIFT)
 #define pfn_pte(pfn, prot)	__pte(__pfn_to_phys(pfn) | pgprot_val(prot))
-#define mk_pte(page, prot)	pfn_pte(page_to_pfn(page), prot)
 
 #ifdef CONFIG_ISA_ARCV2
 #define pmd_leaf(x)		(pmd_val(x) & _PAGE_HW_SZ)
arch/arm64/include/asm/pgtable.h renamed from arch/arm64/include/asm/pgtable.h~mm-introduce-a-common-definition-of-mk_pte +0 -6
@@ -813,12 +813,6 @@ static inline unsigned long pmd_page_vad
 /* use ONLY for statically allocated translation tables */
 #define pte_offset_kimg(dir,addr)	((pte_t *)__phys_to_kimg(pte_offset_phys((dir), (addr))))
 
-/*
- * Conversion functions: convert a page and protection to a page entry,
- * and a page entry and page directory to the page they refer to.
- */
-#define mk_pte(page,prot)	pfn_pte(page_to_pfn(page),prot)
-
 #if CONFIG_PGTABLE_LEVELS > 2
 
 #define pmd_ERROR(e)	\
arch/arm/include/asm/pgtable.h renamed from arch/arm/include/asm/pgtable.h~mm-introduce-a-common-definition-of-mk_pte +0 -1
@@ -168,7 +168,6 @@ static inline pte_t *pmd_page_vaddr(pmd_
 #define pfn_pte(pfn,prot)	__pte(__pfn_to_phys(pfn) | pgprot_val(prot))
 
 #define pte_page(pte)		pfn_to_page(pte_pfn(pte))
-#define mk_pte(page,prot)	pfn_pte(page_to_pfn(page), prot)
 
 #define pte_clear(mm,addr,ptep)	set_pte_ext(ptep, __pte(0), 0)
 
arch/csky/include/asm/pgtable.h renamed from arch/csky/include/asm/pgtable.h~mm-introduce-a-common-definition-of-mk_pte +0 -5
@@ -249,11 +249,6 @@ static inline pgprot_t pgprot_writecombi
 	return __pgprot(prot);
 }
 
-/*
- * Conversion functions: convert a page and protection to a page entry,
- * and a page entry and page directory to the page they refer to.
- */
-#define mk_pte(page, pgprot)    pfn_pte(page_to_pfn(page), (pgprot))
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
 	return __pte((pte_val(pte) & _PAGE_CHG_MASK) |
arch/hexagon/include/asm/pgtable.h renamed from arch/hexagon/include/asm/pgtable.h~mm-introduce-a-common-definition-of-mk_pte +0 -3
@@ -238,9 +238,6 @@ static inline int pte_present(pte_t pte)
 	return pte_val(pte) & _PAGE_PRESENT;
 }
 
-/* mk_pte - make a PTE out of a page pointer and protection bits */
-#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
-
 /* pte_page - returns a page (frame pointer/descriptor?) based on a PTE */
 #define pte_page(x) pfn_to_page(pte_pfn(x))
 
arch/loongarch/include/asm/pgtable.h renamed from arch/loongarch/include/asm/pgtable.h~mm-introduce-a-common-definition-of-mk_pte +0 -6
@@ -426,12 +426,6 @@ static inline unsigned long pte_accessib
 	return false;
 }
 
-/*
- * Conversion functions: convert a page and protection to a page entry,
- * and a page entry and page directory to the page they refer to.
- */
-#define mk_pte(page, pgprot)	pfn_pte(page_to_pfn(page), (pgprot))
-
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
 	return __pte((pte_val(pte) & _PAGE_CHG_MASK) |
arch/m68k/include/asm/mcf_pgtable.h renamed from arch/m68k/include/asm/mcf_pgtable.h~mm-introduce-a-common-definition-of-mk_pte +0 -6
@@ -96,12 +96,6 @@
 
 #define pmd_pgtable(pmd) pfn_to_virt(pmd_val(pmd) >> PAGE_SHIFT)
 
-/*
- * Conversion functions: convert a page and protection to a page entry,
- * and a page entry and page directory to the page they refer to.
- */
-#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
-
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
 	pte_val(pte) = (pte_val(pte) & CF_PAGE_CHG_MASK) | pgprot_val(newprot);
arch/m68k/include/asm/motorola_pgtable.h renamed from arch/m68k/include/asm/motorola_pgtable.h~mm-introduce-a-common-definition-of-mk_pte +0 -6
@@ -81,12 +81,6 @@ extern unsigned long mm_cachebits;
 
 #define pmd_pgtable(pmd) ((pgtable_t)pmd_page_vaddr(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.
- */
-#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
-
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
 	pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot);
arch/m68k/include/asm/sun3_pgtable.h renamed from arch/m68k/include/asm/sun3_pgtable.h~mm-introduce-a-common-definition-of-mk_pte +0 -6
@@ -76,12 +76,6 @@
 
 #ifndef __ASSEMBLY__
 
-/*
- * Conversion functions: convert a page and protection to a page entry,
- * and a page entry and page directory to the page they refer to.
- */
-#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
-
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
 	pte_val(pte) = (pte_val(pte) & SUN3_PAGE_CHG_MASK) | pgprot_val(newprot);
arch/microblaze/include/asm/pgtable.h renamed from arch/microblaze/include/asm/pgtable.h~mm-introduce-a-common-definition-of-mk_pte +0 -8
@@ -285,14 +285,6 @@ static inline pte_t mk_pte_phys(phys_add
 	return pte;
 }
 
-#define mk_pte(page, pgprot) \
-({									   \
-	pte_t pte;							   \
-	pte_val(pte) = (((page - mem_map) << PAGE_SHIFT) + memory_start) |  \
-			pgprot_val(pgprot);				   \
-	pte;								   \
-})
-
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
 	pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot);
arch/mips/include/asm/pgtable.h renamed from arch/mips/include/asm/pgtable.h~mm-introduce-a-common-definition-of-mk_pte +0 -6
@@ -504,12 +504,6 @@ static inline int ptep_set_access_flags(
 	return true;
 }
 
-/*
- * Conversion functions: convert a page and protection to a page entry,
- * and a page entry and page directory to the page they refer to.
- */
-#define mk_pte(page, pgprot)	pfn_pte(page_to_pfn(page), (pgprot))
-
 #if defined(CONFIG_XPA)
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
arch/nios2/include/asm/pgtable.h renamed from arch/nios2/include/asm/pgtable.h~mm-introduce-a-common-definition-of-mk_pte +0 -6
@@ -221,12 +221,6 @@ static inline void pte_clear(struct mm_s
  * Conversion functions: convert a page and protection to a page entry,
  * and a page entry and page directory to the page they refer to.
  */
-#define mk_pte(page, prot)	(pfn_pte(page_to_pfn(page), prot))
-
-/*
- * Conversion functions: convert a page and protection to a page entry,
- * and a page entry and page directory to the page they refer to.
- */
 #define pmd_phys(pmd)		virt_to_phys((void *)pmd_val(pmd))
 #define pmd_pfn(pmd)		(pmd_phys(pmd) >> PAGE_SHIFT)
 #define pmd_page(pmd)		(pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
arch/openrisc/include/asm/pgtable.h renamed from arch/openrisc/include/asm/pgtable.h~mm-introduce-a-common-definition-of-mk_pte +0 -2
@@ -299,8 +299,6 @@ static inline pte_t __mk_pte(void *page,
 	return pte;
 }
 
-#define mk_pte(page, pgprot) __mk_pte(page_address(page), (pgprot))
-
 #define mk_pte_phys(physpage, pgprot) \
 ({                                                                      \
 	pte_t __pte;                                                    \
arch/parisc/include/asm/pgtable.h renamed from arch/parisc/include/asm/pgtable.h~mm-introduce-a-common-definition-of-mk_pte +0 -6
@@ -338,10 +338,6 @@ static inline pte_t pte_mkspecial(pte_t
 #endif
 
 
-/*
- * Conversion functions: convert a page and protection to a page entry,
- * and a page entry and page directory to the page they refer to.
- */
 #define __mk_pte(addr,pgprot) \
 ({									\
 	pte_t __pte;							\
@@ -351,8 +347,6 @@ static inline pte_t pte_mkspecial(pte_t
 	__pte;								\
 })
 
-#define mk_pte(page, pgprot)	pfn_pte(page_to_pfn(page), (pgprot))
-
 static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot)
 {
 	pte_t pte;
arch/powerpc/include/asm/pgtable.h renamed from arch/powerpc/include/asm/pgtable.h~mm-introduce-a-common-definition-of-mk_pte +1 -2
@@ -53,9 +53,8 @@ void set_ptes(struct mm_struct *mm, unsi
 #define MAX_PTRS_PER_PGD PTRS_PER_PGD
 #endif
 
-/* Keep these as a macros to avoid include dependency mess */
+/* Keep this as a macro to avoid include dependency mess */
 #define pte_page(x)		pfn_to_page(pte_pfn(x))
-#define mk_pte(page, pgprot)	pfn_pte(page_to_pfn(page), (pgprot))
 
 static inline unsigned long pte_pfn(pte_t pte)
 {
arch/riscv/include/asm/pgtable.h renamed from arch/riscv/include/asm/pgtable.h~mm-introduce-a-common-definition-of-mk_pte +0 -2
@@ -343,8 +343,6 @@ static inline pte_t pfn_pte(unsigned lon
 	return __pte((pfn << _PAGE_PFN_SHIFT) | prot_val);
 }
 
-#define mk_pte(page, prot)       pfn_pte(page_to_pfn(page), prot)
-
 #define pte_pgprot pte_pgprot
 static inline pgprot_t pte_pgprot(pte_t pte)
 {
arch/s390/include/asm/pgtable.h renamed from arch/s390/include/asm/pgtable.h~mm-introduce-a-common-definition-of-mk_pte +0 -5
@@ -1448,11 +1448,6 @@ static inline pte_t mk_pte_phys(unsigned
 	return pte_mkyoung(__pte);
 }
 
-static inline pte_t mk_pte(struct page *page, pgprot_t pgprot)
-{
-	return mk_pte_phys(page_to_phys(page), pgprot);
-}
-
 #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
 #define p4d_index(address) (((address) >> P4D_SHIFT) & (PTRS_PER_P4D-1))
 #define pud_index(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
arch/sh/include/asm/pgtable_32.h renamed from arch/sh/include/asm/pgtable_32.h~mm-introduce-a-common-definition-of-mk_pte +0 -8
@@ -380,14 +380,6 @@ PTE_BIT_FUNC(low, mkspecial, |= _PAGE_SP
 
 #define pgprot_noncached	 pgprot_writecombine
 
-/*
- * Conversion functions: convert a page and protection to a page entry,
- * and a page entry and page directory to the page they refer to.
- *
- * extern pte_t mk_pte(struct page *page, pgprot_t pgprot)
- */
-#define mk_pte(page, pgprot)	pfn_pte(page_to_pfn(page), (pgprot))
-
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
 	pte.pte_low &= _PAGE_CHG_MASK;
arch/sparc/include/asm/pgtable_64.h renamed from arch/sparc/include/asm/pgtable_64.h~mm-introduce-a-common-definition-of-mk_pte +0 -1
@@ -225,7 +225,6 @@ static inline pte_t pfn_pte(unsigned lon
 	BUILD_BUG_ON(_PAGE_SZBITS_4U != 0UL || _PAGE_SZBITS_4V != 0UL);
 	return __pte(paddr | pgprot_val(prot));
 }
-#define mk_pte(page, pgprot)	pfn_pte(page_to_pfn(page), (pgprot))
 
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
arch/xtensa/include/asm/pgtable.h renamed from arch/xtensa/include/asm/pgtable.h~mm-introduce-a-common-definition-of-mk_pte +0 -6
@@ -269,17 +269,11 @@ static inline pte_t pte_mkwrite_novma(pt
 		((__pgprot((pgprot_val(prot) & ~_PAGE_CA_MASK) | \
 			   _PAGE_CA_BYPASS)))
 
-/*
- * Conversion functions: convert a page and protection to a page entry,
- * and a page entry and page directory to the page they refer to.
- */
-
 #define PFN_PTE_SHIFT		PAGE_SHIFT
 #define pte_pfn(pte)		(pte_val(pte) >> PAGE_SHIFT)
 #define pte_same(a,b)		(pte_val(a) == pte_val(b))
 #define pte_page(x)		pfn_to_page(pte_pfn(x))
 #define pfn_pte(pfn, prot)	__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
-#define mk_pte(page, prot)	pfn_pte(page_to_pfn(page), prot)
 
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
include/linux/mm.h renamed from include/linux/mm.h~mm-introduce-a-common-definition-of-mk_pte +9 -0
@@ -2004,6 +2004,15 @@ static inline struct folio *pfn_folio(un
 	return page_folio(pfn_to_page(pfn));
 }
 
+#ifndef mk_pte
+#ifdef CONFIG_MMU
+static inline pte_t mk_pte(struct page *page, pgprot_t pgprot)
+{
+	return pfn_pte(page_to_pfn(page), pgprot);
+}
+#endif
+#endif
+
 static inline bool folio_has_pincount(const struct folio *folio)
 {
 	if (IS_ENABLED(CONFIG_64BIT))

_

Patches currently in -mm which might be from [email protected] are