]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
powerpc/mm: Change the swap encoding in pte.
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Wed, 17 Jun 2015 02:43:41 +0000 (08:13 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 19 Jun 2015 07:10:29 +0000 (17:10 +1000)
Current swap encoding in pte can't support large pfns
above 4TB. Change the swap encoding such that we put
the swap type in the PTE bits. Also add build checks
to make sure we don't overlap with HPTEFLAGS.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/pgtable-ppc64.h
arch/powerpc/include/asm/pte-book3e.h
arch/powerpc/include/asm/pte-hash64.h

index f951d9cf358af801483461f60d02e5d43e40dc10..f890f7ce159323d8a3f35fca2f95a594ed0fa9e9 100644 (file)
@@ -347,11 +347,27 @@ static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)
        pr_err("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
 
 /* Encode and de-code a swap entry */
-#define __swp_type(entry)      (((entry).val >> 1) & 0x3f)
-#define __swp_offset(entry)    ((entry).val >> 8)
-#define __swp_entry(type, offset) ((swp_entry_t){((type)<< 1)|((offset)<<8)})
-#define __pte_to_swp_entry(pte)        ((swp_entry_t){pte_val(pte) >> PTE_RPN_SHIFT})
-#define __swp_entry_to_pte(x)  ((pte_t) { (x).val << PTE_RPN_SHIFT })
+#define MAX_SWAPFILES_CHECK() do { \
+       BUILD_BUG_ON(MAX_SWAPFILES_SHIFT > SWP_TYPE_BITS); \
+       /*                                                      \
+        * Don't have overlapping bits with _PAGE_HPTEFLAGS     \
+        * We filter HPTEFLAGS on set_pte.                      \
+        */                                                     \
+       BUILD_BUG_ON(_PAGE_HPTEFLAGS & (0x1f << _PAGE_BIT_SWAP_TYPE)); \
+       } while (0)
+/*
+ * on pte we don't need handle RADIX_TREE_EXCEPTIONAL_SHIFT;
+ */
+#define SWP_TYPE_BITS 5
+#define __swp_type(x)          (((x).val >> _PAGE_BIT_SWAP_TYPE) \
+                               & ((1UL << SWP_TYPE_BITS) - 1))
+#define __swp_offset(x)                ((x).val >> PTE_RPN_SHIFT)
+#define __swp_entry(type, offset)      ((swp_entry_t) { \
+                                       ((type) << _PAGE_BIT_SWAP_TYPE) \
+                                       | ((offset) << PTE_RPN_SHIFT) })
+
+#define __pte_to_swp_entry(pte)                ((swp_entry_t) { pte_val((pte)) })
+#define __swp_entry_to_pte(x)          __pte((x).val)
 
 void pgtable_cache_add(unsigned shift, void (*ctor)(void *));
 void pgtable_cache_init(void);
index 91a704952ca1a96234b9088c4493b6371bbbefcf..8d8473278d91c37e1bf5b742bbe20f8938a9ed9a 100644 (file)
@@ -11,6 +11,7 @@
 /* Architected bits */
 #define _PAGE_PRESENT  0x000001 /* software: pte contains a translation */
 #define _PAGE_SW1      0x000002
+#define _PAGE_BIT_SWAP_TYPE    2
 #define _PAGE_BAP_SR   0x000004
 #define _PAGE_BAP_UR   0x000008
 #define _PAGE_BAP_SW   0x000010
index fc852f7e7b3a63f86e94f0cb43b62eb2b11fc3a3..ef612c160da7c8fb8d4b11ed8a6f67c270d2dcce 100644 (file)
@@ -16,6 +16,7 @@
  */
 #define _PAGE_PRESENT          0x0001 /* software: pte contains a translation */
 #define _PAGE_USER             0x0002 /* matches one of the PP bits */
+#define _PAGE_BIT_SWAP_TYPE    2
 #define _PAGE_EXEC             0x0004 /* No execute on POWER4 and newer (we invert) */
 #define _PAGE_GUARDED          0x0008
 /* We can derive Memory coherence from _PAGE_NO_CACHE */