linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: lauraa@codeaurora.org (Laura Abbott)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm: mm: Populate initial page tables across sections
Date: Wed,  6 Mar 2013 20:52:13 -0800	[thread overview]
Message-ID: <1362631933-23567-1-git-send-email-lauraa@codeaurora.org> (raw)

The current code for setting up initial page tables does
not take into account section spanning for the non-section
case. This may result in incorrect population of page tables
and unexpected aborts. These problems have been observed in two cases:

1) An iomap entry that is not section aligned but the mapped size is
greater than the section size
2) Removal a block of section aligned memory with memblock remove and
remapping of a separate region of memory to 4k chunks as part of CMA

The solution is to call alloc_init_pte in SECTION_SIZE chunks. This
ensures that alloc_init_pte will populate the page tables
correctly.

Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
---
 arch/arm/mm/mmu.c |   29 ++++++++++++++++++++++++-----
 1 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 25cb67c..08cf68a 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -652,11 +652,30 @@ static void __init alloc_init_section(pud_t *pud, unsigned long addr,
 
 		flush_pmd_entry(p);
 	} else {
-		/*
-		 * No need to loop; pte's aren't interested in the
-		 * individual L1 entries.
-		 */
-		alloc_init_pte(pmd, addr, end, __phys_to_pfn(phys), type);
+		unsigned long pte_end;
+
+		if (addr + SECTION_SIZE < addr)
+			pte_end = end;
+		else if (IS_ALIGNED(addr, SECTION_SIZE))
+			pte_end = min (end, addr + SECTION_SIZE);
+		else
+			pte_end = min (end, roundup(addr, SECTION_SIZE));
+
+		do {
+			unsigned int offset;
+
+			alloc_init_pte(pmd, addr, pte_end, __phys_to_pfn(phys), type);
+
+			if (addr + SECTION_SIZE < addr)
+				break;
+
+			if (end - pte_end)
+				offset = min(SECTION_SIZE, end - pte_end);
+			else
+				break;
+			addr += offset;
+			pte_end += offset;
+		} while (pmd++, addr < end);
 	}
 }
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

                 reply	other threads:[~2013-03-07  4:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1362631933-23567-1-git-send-email-lauraa@codeaurora.org \
    --to=lauraa@codeaurora.org \
    --cc=linux-arm-kernel@lists.infradead.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).