From patchwork Mon Aug 9 09:19:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Shilimkar X-Patchwork-Id: 10475427 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EE8CF6029B for ; Tue, 19 Jun 2018 20:29:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E03FD289D2 for ; Tue, 19 Jun 2018 20:28:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4C3328AA5; Tue, 19 Jun 2018 20:28:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, T_TVD_MIME_EPI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BB46E289D2 for ; Tue, 19 Jun 2018 20:28:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Type:In-Reply-To:References:Message-ID:Subject:Date:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=KSyGHB/bd9Q78nc1pDRHFEW3MjNpS9c/XRhJrUDDXYk=; b=SfUEy7vdQ5yhEEDsyhxaPvJpO 6RKiwpFxIScCgoWVOadUz6YmJwqDtdQ+dSZmhMZYIgGlb9HJMAWIiR7SlRFdJkAu8mt3oszCrqOB3 hOgdmldHt/FkzaPegVlZeVhwd3L9PIb8fvXWJ027i90PdUMjMj6Pqfi7AJyMlLcV7KE3mVflffTsP ZDQ83YxcPWVY16WRzFpbXQTbKilFNTRLKZVPfROcA1WLcHee5n1Rbv+qaw3C2eL0YnPeuxbLmo1UB oxailriHnRHQJX6uFJFPIfFGWMKXUrWwZI+P133dOlH1/FS72nW/yrEpOCR4M9Q+scyTeoDk8RXgr 926lnItZA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVNF6-0006uO-Mv; Tue, 19 Jun 2018 20:28:44 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVNCj-0005ZQ-Jf; Tue, 19 Jun 2018 20:26:17 +0000 Received: from vger.kernel.org ([209.132.180.67]) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1OiOW1-0001DD-5l; Mon, 09 Aug 2010 09:19:29 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755862Ab0HIJT1 (ORCPT + 2 others); Mon, 9 Aug 2010 05:19:27 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:53330 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755840Ab0HIJT0 (ORCPT ); Mon, 9 Aug 2010 05:19:26 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id o799JBCO025954 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 9 Aug 2010 04:19:14 -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 o799JAxE003768; Mon, 9 Aug 2010 14:49:10 +0530 (IST) Received: from dbde02.ent.ti.com ([172.24.170.145]) by dbde71.ent.ti.com ([172.24.170.149]) with mapi; Mon, 9 Aug 2010 14:49:11 +0530 From: "Shilimkar, Santosh" To: "linux-omap@vger.kernel.org" Date: Mon, 9 Aug 2010 14:49:09 +0530 Subject: RE: [PATCH 1/3] ARM: mmu: Setup MT_MEMORY and MT_MEMORY_NONACHED L1 entries Thread-Topic: [PATCH 1/3] ARM: mmu: Setup MT_MEMORY and MT_MEMORY_NONACHED L1 entries Thread-Index: Acs27aHoaqYUumqnRd+EFh6pQj1RGQAAXt4wAC0RybA= Message-ID: References: <1281262672-27626-1-git-send-email-santosh.shilimkar@ti.com> <20100808113403.GA23623@n2100.arm.linux.org.uk> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Precedence: bulk X-Mailing-List: linux-omap@vger.kernel.org Status: O X-Keywords: X-UID: 214 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Russell King - ARM Linux , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP > -----Original Message----- > From: linux-omap-owner@vger.kernel.org [mailto:linux-omap- > owner@vger.kernel.org] On Behalf Of Shilimkar, Santosh > Sent: Sunday, August 08, 2010 5:16 PM > To: Russell King - ARM Linux > Cc: linux-omap@vger.kernel.org; linux-arm-kernel@lists.infradead.org > Subject: RE: [PATCH 1/3] ARM: mmu: Setup MT_MEMORY and MT_MEMORY_NONACHED > L1 entries > > > -----Original Message----- > > From: Russell King - ARM Linux [mailto:linux@arm.linux.org.uk] > > Sent: Sunday, August 08, 2010 5:04 PM > > To: Shilimkar, Santosh > > Cc: linux-omap@vger.kernel.org; linux-arm-kernel@lists.infradead.org > > Subject: Re: [PATCH 1/3] ARM: mmu: Setup MT_MEMORY and > MT_MEMORY_NONACHED > > L1 entries > > > > On Sun, Aug 08, 2010 at 03:47:52PM +0530, Santosh Shilimkar wrote: > > > @@ -475,6 +486,9 @@ static void __init build_mem_type_table(void) > > > mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask; > > > mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask; > > > mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd; > > > + mem_types[MT_MEMORY].prot_pte |= kern_pgprot; > > > + mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask | cp->pmd; > > > + mem_types[MT_MEMORY_NONCACHED].prot_pte |= kern_pgprot; > > > > This is wrong - it will result in the non-cached memory mapped in as > > sections having the same cache settings as MT_MEMORY - in other > > words, probably write back. > You are right. Will fix this in next version. > Updated version with Russell's comments incorporated. -------------------------------------------------------------------- >From 23d712c1846d78bdb09979087261911e5d80f014 Mon Sep 17 00:00:00 2001 From: Santosh Shilimkar Date: Sun, 8 Aug 2010 12:05:25 +0530 Subject: [PATCH 1/3 v2] ARM: mmu: Setup MT_MEMORY and MT_MEMORY_NONCACHED L1 entries This patch populates the L1 entries for MT_MEMORY and MT_MEMORY_NONCACHED types so that at boot-up, we can map memories outside system memory at page level granularity Previously the mapping was limiting to section level, which creates unnecessary additional mapping for which physical memory may not present. On the newer ARM with speculation, this is dangerous and can result in untraceable aborts. The patch is based on inputs from Russell King Signed-off-by: Santosh Shilimkar Cc: Russell King --- arch/arm/mm/mmu.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 6e1c4f6..3e986a6 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -246,6 +246,9 @@ static struct mem_type mem_types[] = { .domain = DOMAIN_USER, }, [MT_MEMORY] = { + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY | + L_PTE_USER | L_PTE_EXEC, + .prot_l1 = PMD_TYPE_TABLE, .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE, .domain = DOMAIN_KERNEL, }, @@ -254,6 +257,9 @@ static struct mem_type mem_types[] = { .domain = DOMAIN_KERNEL, }, [MT_MEMORY_NONCACHED] = { + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY | + L_PTE_USER | L_PTE_EXEC | L_PTE_MT_BUFFERABLE, + .prot_l1 = PMD_TYPE_TABLE, .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE, .domain = DOMAIN_KERNEL, }, @@ -411,9 +417,12 @@ static void __init build_mem_type_table(void) * Enable CPU-specific coherency if supported. * (Only available on XSC3 at the moment.) */ - if (arch_is_coherent() && cpu_is_xsc3()) + if (arch_is_coherent() && cpu_is_xsc3()) { mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S; - + mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED; + mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S; + mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED; + } /* * ARMv6 and above have extended page tables. */ @@ -438,7 +447,9 @@ static void __init build_mem_type_table(void) mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S; mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED; mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S; + mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED; mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S; + mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED; #endif } @@ -475,6 +486,8 @@ static void __init build_mem_type_table(void) mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask; mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask; mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd; + mem_types[MT_MEMORY].prot_pte |= kern_pgprot; + mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask; mem_types[MT_ROM].prot_sect |= cp->pmd; switch (cp->pmd) {