]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
powerpc/64s: Add support for huge pfnmaps
authorRitesh Harjani (IBM) <ritesh.list@gmail.com>
Mon, 9 Mar 2026 12:38:38 +0000 (18:08 +0530)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Mon, 30 Mar 2026 10:22:17 +0000 (15:52 +0530)
This uses _RPAGE_SW2 bit for the PMD and PUDs similar to PTEs.
This also adds support for {pte,pmd,pud}_pgprot helpers needed for
follow_pfnmap APIs.

This allows us to extend the PFN mappings, e.g. PCI MMIO bars where
it can grow as large as 8GB or even bigger, to map at PMD / PUD level.
VFIO PCI core driver already supports fault handling at PMD / PUD level
for more efficient BAR mappings.

Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/6fca726574236f556dd4e1e259692e82a4c29e85.1773058761.git.ritesh.list@gmail.com
arch/powerpc/Kconfig
arch/powerpc/include/asm/book3s/64/pgtable.h
arch/powerpc/include/asm/pgtable.h

index 10240cb80904392b68aa926d9e8e6b1a752b3f39..fd3e66e4ee0a1c92e2551d735bff953cce2c9d17 100644 (file)
@@ -172,6 +172,7 @@ config PPC
        select ARCH_STACKWALK
        select ARCH_SUPPORTS_ATOMIC_RMW
        select ARCH_SUPPORTS_DEBUG_PAGEALLOC    if PPC_BOOK3S || PPC_8xx
+       select ARCH_SUPPORTS_HUGE_PFNMAP        if PPC_BOOK3S_64 && TRANSPARENT_HUGEPAGE
        select ARCH_SUPPORTS_PAGE_TABLE_CHECK   if !HUGETLB_PAGE
        select ARCH_SUPPORTS_SCHED_MC           if SMP
        select ARCH_SUPPORTS_SCHED_SMT          if PPC64 && SMP
index a105aede4f6bb3bf37f5ed3992edd968004f04aa..1b8916618f899f3eab8122ff38b74baa3e2620b0 100644 (file)
@@ -1289,6 +1289,29 @@ static inline pud_t pud_mkhuge(pud_t pud)
        return pud;
 }
 
+#ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP
+static inline bool pmd_special(pmd_t pmd)
+{
+       return pte_special(pmd_pte(pmd));
+}
+
+static inline pmd_t pmd_mkspecial(pmd_t pmd)
+{
+       return pte_pmd(pte_mkspecial(pmd_pte(pmd)));
+}
+#endif
+
+#ifdef CONFIG_ARCH_SUPPORTS_PUD_PFNMAP
+static inline bool pud_special(pud_t pud)
+{
+       return pte_special(pud_pte(pud));
+}
+
+static inline pud_t pud_mkspecial(pud_t pud)
+{
+       return pte_pud(pte_mkspecial(pud_pte(pud)));
+}
+#endif
 
 #define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS
 extern int pmdp_set_access_flags(struct vm_area_struct *vma,
index dcd3a88caaf634fef26fa57f5b8852274e0d4cb5..97ccfa6e3dde80f7a7806b94a6ffe6c80e886201 100644 (file)
@@ -63,6 +63,20 @@ static inline pgprot_t pte_pgprot(pte_t pte)
        return __pgprot(pte_flags);
 }
 
+#ifdef CONFIG_PPC64
+#define pmd_pgprot pmd_pgprot
+static inline pgprot_t pmd_pgprot(pmd_t pmd)
+{
+       return pte_pgprot(pmd_pte(pmd));
+}
+
+#define pud_pgprot pud_pgprot
+static inline pgprot_t pud_pgprot(pud_t pud)
+{
+       return pte_pgprot(pud_pte(pud));
+}
+#endif /* CONFIG_PPC64 */
+
 static inline pgprot_t pgprot_nx(pgprot_t prot)
 {
        return pte_pgprot(pte_exprotect(__pte(pgprot_val(prot))));