Subject: [PATCH] powerpc/mm: Add _PAGE_DEVMAP pte bit for ppc64.

From: "Aneesh Kumar K.V" <[email-masked]>
Date: Mon, 7 Nov 2016 14:08:24 +0530

Signed-off-by: Aneesh Kumar K.V <[email-masked]>
---
NOTE: We need other patches to enable pmem on ppc64. I am waiting
for dax pmd fault handling cleanup to hit upstream before I send
the changes. Meanwhile reserve the pte bit.

 arch/powerpc/include/asm/book3s/64/pgtable.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h
index 9eed9d66d24f..af9e1a150ae7 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -32,6 +32,8 @@
 #define _PAGE_SOFT_DIRTY	0x00000
 #endif
 #define _PAGE_SPECIAL		_RPAGE_SW2 /* software: special page */
+#define _PAGE_DEVMAP		_RPAGE_SW1
+#define __HAVE_ARCH_PTE_DEVMAP

 #define _PAGE_PTE		(1ul << 62)	/* distinguishes PTEs from pointers */
@@ -485,6 +487,16 @@ static inline pte_t pte_mkhuge(pte_t pte)
 	return pte;
 }
 
+static inline pte_t pte_mkdevmap(pte_t pte)
+{
+	return __pte(pte_val(pte) | _PAGE_SPECIAL|_PAGE_DEVMAP);
+}
+
+static inline int pte_devmap(pte_t pte)
+{
+	return !!(pte_raw(pte) & cpu_to_be64(_PAGE_DEVMAP));
+}
+
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
 	/* FIXME!! check whether this need to be a conditional */
@@ -1030,6 +1042,18 @@ static inline bool arch_needs_pgtable_deposit(void)
 	return true;
 }
 
+static inline pmd_t pmd_mkdevmap(pmd_t pmd)
+{
+	/*
+	 * No special ptes at pmd level.
+	 */
+	return __pmd(pmd_val(pmd) | _PAGE_DEVMAP);
+}
+
+static inline int pmd_devmap(pmd_t pmd)
+{
+	return pte_devmap(pmd_pte(pmd));
+}
 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
 #endif /* __ASSEMBLY__ */
 #endif /* _ASM_POWERPC_BOOK3S_64_PGTABLE_H_ */
-- 
2.10.2