From patchwork Thu Mar 7 04:52:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 2230291 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 437DE3FCF6 for ; Thu, 7 Mar 2013 04:55:41 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UDSob-0005zk-Do; Thu, 07 Mar 2013 04:52:25 +0000 Received: from wolverine02.qualcomm.com ([199.106.114.251]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UDSoX-0005xa-QH for linux-arm-kernel@lists.infradead.org; Thu, 07 Mar 2013 04:52:22 +0000 X-IronPort-AV: E=Sophos;i="4.84,800,1355126400"; d="scan'208";a="27998399" Received: from pdmz-ns-snip_115_219.qualcomm.com (HELO mostmsg01.qualcomm.com) ([199.106.115.219]) by wolverine02.qualcomm.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Mar 2013 20:52:17 -0800 Received: from lauraa-linux.qualcomm.com (pdmz-ns-snip_218_1.qualcomm.com [192.168.218.1]) by mostmsg01.qualcomm.com (Postfix) with ESMTPA id 3791B10004B6; Wed, 6 Mar 2013 20:52:17 -0800 (PST) From: Laura Abbott To: Russell King Subject: [PATCH] arm: mm: Populate initial page tables across sections Date: Wed, 6 Mar 2013 20:52:13 -0800 Message-Id: <1362631933-23567-1-git-send-email-lauraa@codeaurora.org> X-Mailer: git-send-email 1.7.8.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130306_235222_178814_43EAC742 X-CRM114-Status: GOOD ( 13.89 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [199.106.114.251 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Nicolas Pitre , Catalin Marinas , Laura Abbott , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 --- 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); } }