linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm: mm: Populate initial page tables across sections
@ 2013-03-07  4:52 Laura Abbott
  0 siblings, 0 replies; only message in thread
From: Laura Abbott @ 2013-03-07  4:52 UTC (permalink / raw)
  To: linux-arm-kernel

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-03-07  4:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-07  4:52 [PATCH] arm: mm: Populate initial page tables across sections Laura Abbott

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).