From patchwork Mon Aug 6 07:41:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: R Sricharan X-Patchwork-Id: 1277191 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id B863ADFF71 for ; Mon, 6 Aug 2012 07:44:32 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SyHwb-0007gK-Q8; Mon, 06 Aug 2012 07:41:41 +0000 Received: from comal.ext.ti.com ([198.47.26.152]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SyHwZ-0007g0-3X for linux-arm-kernel@lists.infradead.org; Mon, 06 Aug 2012 07:41:39 +0000 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id q767fVmu012194; Mon, 6 Aug 2012 02:41:32 -0500 Received: from DBDE71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id q767fT2x023859; Mon, 6 Aug 2012 13:11:29 +0530 (IST) Received: from dbdp32.itg.ti.com (172.24.170.251) by DBDE71.ent.ti.com (172.24.170.149) with Microsoft SMTP Server id 14.1.323.3; Mon, 6 Aug 2012 13:11:29 +0530 Received: from localhost.localdomain (smtpvbd.itg.ti.com [172.24.170.250]) by dbdp32.itg.ti.com (8.13.8/8.13.8) with ESMTP id q767fRf6022489; Mon, 6 Aug 2012 13:11:28 +0530 From: R Sricharan To: Subject: [PATCH v2 1/1] ARM: LPAE: Fix mapping in alloc_init_pte for unaligned addresses. Date: Mon, 6 Aug 2012 13:11:25 +0530 Message-ID: <1344238885-13683-1-git-send-email-r.sricharan@ti.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -6.9 (------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-6.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [198.47.26.152 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: r.sricharan@ti.com, santosh.shilimkar@ti.com, catalin.marinas@arm.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org With LPAE, When either the start address or end address or physical address to be mapped is unaligned, alloc_init_section creates page granularity mappings. alloc_init_section calls alloc_init_pte which populates one pmd entry and sets up the ptes. But if the size is greater than what can be mapped by one pmd entry, then the rest remains unmapped. The issue becomes visible when LPAE is enabled, where we have the 3 levels with seperate pgd and pmd's. When a static mapping for 3MB is requested, only 2MB is mapped and the remaining 1MB is unmapped. Fixing this here, by looping in to map the entire unaligned address range. Boot tested on OMAP5 evm with both LPAE enabled/disabled and verified that static mappings with unaligned addresses are properly mapped. Signed-off-by: R Sricharan Reviewed-by: Santosh Shilimkar Cc: Catalin Marinas --- [V2] Moved the loop to alloc_init_pte as per Russell's feedback and changed the subject accordingly. Using PMD_XXX instead of SECTION_XXX to avoid different loop increments with/without LPAE. arch/arm/mm/mmu.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index cf4528d..0ed8808 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -585,11 +585,25 @@ static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr, unsigned long end, unsigned long pfn, const struct mem_type *type) { - pte_t *pte = early_pte_alloc(pmd, addr, type->prot_l1); + unsigned long next; + pte_t *pte; + phys_addr_t phys; + do { - set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0); - pfn++; - } while (pte++, addr += PAGE_SIZE, addr != end); + if ((end-addr) & PMD_MASK) + next = (addr + PMD_SIZE) & PMD_MASK; + else + next = end; + + pte = early_pte_alloc(pmd, addr, type->prot_l1); + do { + set_pte_ext(pte, pfn_pte(pfn, + __pgprot(type->prot_pte)), 0); + pfn++; + } while (pte++, addr += PAGE_SIZE, addr != next); + + phys += next - addr; + } while (pmd++, addr = next, addr != end); } static void __init alloc_init_section(pud_t *pud, unsigned long addr,