linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au
Cc: linuxppc-dev@lists.ozlabs.org, hmyneni@gmail.com,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: [PATCH 2/3] powerpc/mm: Limit the max memory we can support
Date: Fri, 29 May 2015 09:24:51 +0530	[thread overview]
Message-ID: <1432871692-707-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <1432871692-707-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>

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@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

  reply	other threads:[~2015-05-29  3:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-29  3:54 [PATCH 1/3] powerpc/mm: PTE_RPN_MAX is not used, remove the same Aneesh Kumar K.V
2015-05-29  3:54 ` Aneesh Kumar K.V [this message]
2015-05-29  8:20   ` [PATCH V2] powerpc/mm: Limit the max memory we can support Aneesh Kumar K.V
2015-06-11  9:23     ` [V2] " Michael Ellerman
2015-06-16 16:00       ` Aneesh Kumar K.V
2015-05-29  3:54 ` [PATCH 3/3] powerpc/mm: Change the swap encoding in pte Aneesh Kumar K.V
2015-05-29  8:09   ` Haren Myneni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432871692-707-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=hmyneni@gmail.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).