From patchwork Mon Jan 7 14:44:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Vincent_Stehl=C3=A9?= X-Patchwork-Id: 209942 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 958E42C007C for ; Tue, 8 Jan 2013 01:45:35 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 162654A0FF; Mon, 7 Jan 2013 15:45:33 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id az3o5ly23HwT; Mon, 7 Jan 2013 15:45:32 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7CD9B4A103; Mon, 7 Jan 2013 15:45:24 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3C5024A0C7 for ; Mon, 7 Jan 2013 15:45:22 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iC1RFcYD8oyJ for ; Mon, 7 Jan 2013 15:45:21 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by theia.denx.de (Postfix) with ESMTPS id 9B5B24A0F3 for ; Mon, 7 Jan 2013 15:45:10 +0100 (CET) Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r07Ej7TZ010785; Mon, 7 Jan 2013 08:45:07 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r07Ej77d032688; Mon, 7 Jan 2013 08:45:07 -0600 Received: from dlelxv23.itg.ti.com (172.17.1.198) by dfle72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.1.323.3; Mon, 7 Jan 2013 08:45:07 -0600 Received: from svrhermes.tif.ti.com (svrhermes.tif.ti.com [137.167.130.169]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id r07Ej6No021428; Mon, 7 Jan 2013 08:45:07 -0600 Received: from unb0919505.tif.ti.com (unb0919505.tif.ti.com [137.167.100.142]) by svrhermes.tif.ti.com (Postfix) with ESMTP id 6EF3D37068; Mon, 7 Jan 2013 15:45:06 +0100 (MET) Received: from vstehle by unb0919505.tif.ti.com with local (Exim 4.76) (envelope-from ) id 1TsDwi-0002e7-QQ; Mon, 07 Jan 2013 15:45:00 +0100 From: =?UTF-8?q?Vincent=20Stehl=C3=A9?= To: Date: Mon, 7 Jan 2013 15:44:40 +0100 Message-ID: <1357569880-10067-4-git-send-email-v-stehle@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1357569880-10067-1-git-send-email-v-stehle@ti.com> References: <92476020c6e1ef888207ca6f661c48068050efbf> <1357569880-10067-1-git-send-email-v-stehle@ti.com> MIME-Version: 1.0 Cc: Tom Rini Subject: [U-Boot] [PATCH v4 3/3] ARM: OMAP5: redefine arm_setup_identity_mapping X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de We introduce an OMAP5 specific version of arm_setup_identity_mapping(), which makes the first page of the identity mapping invalid. We want to unmap the region near address zero on HS OMAP devices, to avoid speculative accesses. Accessing this region causes security violations, which we want to avoid. Signed-off-by: Vincent Stehlé Cc: Tom Rini --- Changes for v4: - Protect functions according to cache config - Remove page_table argument - Declare global data ptr and use it to retrieve page_table Changes for v3: - Use definition of __arm_setup_identity_mapping() from asm/cache.h Changes for v2: - Fix missing page_table argument - Add extern definition to fix compilation warning arch/arm/cpu/armv7/omap5/Makefile | 1 + arch/arm/cpu/armv7/omap5/cache-cp15.c | 52 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 arch/arm/cpu/armv7/omap5/cache-cp15.c diff --git a/arch/arm/cpu/armv7/omap5/Makefile b/arch/arm/cpu/armv7/omap5/Makefile index 9b261c4..49c454c 100644 --- a/arch/arm/cpu/armv7/omap5/Makefile +++ b/arch/arm/cpu/armv7/omap5/Makefile @@ -29,6 +29,7 @@ COBJS += hwinit.o COBJS += clocks.o COBJS += emif.o COBJS += sdram.o +COBJS += cache-cp15.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS) $(SOBJS)) diff --git a/arch/arm/cpu/armv7/omap5/cache-cp15.c b/arch/arm/cpu/armv7/omap5/cache-cp15.c new file mode 100644 index 0000000..a9666f7 --- /dev/null +++ b/arch/arm/cpu/armv7/omap5/cache-cp15.c @@ -0,0 +1,52 @@ +/* + * (C) Copyright 2002 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * (C) Copyright 2012 + * Vincent Stehlé, Texas Instruments, v-stehle@ti.com. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include +#include + +#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) + +DECLARE_GLOBAL_DATA_PTR; + +/* OMAP5 specific function to set up the identity mapping. */ +void arm_setup_identity_mapping(void) +{ + u32 *page_table = (u32 *)gd->tlb_addr; + + /* + * Perform default mapping, which sets up an identity-mapping for all + * 4GB, rw for everyone. + */ + __arm_setup_identity_mapping(); + + /* + * First page (starting at 0x0) is made invalid to avoid speculative + * accesses in secure rom. + * TODO: use second level descriptors for finer grained mapping. + */ + page_table[0] = 0; +} +#endif