powerpc: Don't truncate pgd_index wrongly
[firefly-linux-kernel-4.4.55.git] / arch / powerpc / include / asm / pgtable-ppc64.h
index 0182c203e41157520866b57f0a5d1760bfe054cc..e3d55f6f24fe1828ae3ce7603770fcbd6c7470f1 100644 (file)
  * Find an entry in a page-table-directory.  We combine the address region
  * (the high order N bits) and the pgd portion of the address.
  */
-/* to avoid overflow in free_pgtables we don't use PTRS_PER_PGD here */
-#define pgd_index(address) (((address) >> (PGDIR_SHIFT)) & 0x1ff)
+#define pgd_index(address) (((address) >> (PGDIR_SHIFT)) & (PTRS_PER_PGD - 1))
 
 #define pgd_offset(mm, address)         ((mm)->pgd + pgd_index(address))