[PATCH 2/3] powerpc/mm: Limit the max memory we can support
Aneesh Kumar K.V
aneesh.kumar at linux.vnet.ibm.com
Fri May 29 13:54:51 AEST 2015
We need to limit the max memory based on Linux page table format.
For example, with 4K page size we can't support 64TB memory based
on the existing pte format. Add checks to limit memory based
on pte size.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.vnet.ibm.com>
---
arch/powerpc/kernel/prom.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 308c5e15676b..a0108ddde01c 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -698,9 +698,25 @@ void __init early_init_devtree(void *params)
#endif
reserve_crashkernel();
early_reserve_mem();
-
- /* Ensure that total memory size is page-aligned. */
- limit = ALIGN(memory_limit ?: memblock_phys_mem_size(), PAGE_SIZE);
+ /*
+ * if not specified limit the memory based on the pfn count that
+ * we can fit in pte_t. Also ensure that total memory size is
+ * page-aligned.
+ */
+ if (!memory_limit) {
+ int bit_count;
+ phys_addr_t pte_mem_limit;
+
+ BUILD_BUG_ON(sizeof(pte_basic_t) > 8);
+ bit_count = (sizeof(pte_basic_t) * 8) - PTE_RPN_SHIFT + PAGE_SHIFT;
+ pte_mem_limit = ~0ULL >> (64 - bit_count);
+ limit = memblock_phys_mem_size();
+ if (limit > pte_mem_limit)
+ limit = pte_mem_limit;
+ } else
+ limit = memory_limit;
+
+ limit = ALIGN(limit, PAGE_SIZE);
memblock_enforce_memory_limit(limit);
memblock_allow_resize();
--
2.1.4
More information about the Linuxppc-dev
mailing list