Patchwork [U-Boot,2/2] ARM: OMAP5: redefine arm_setup_identity_mapping

login
register
mail settings
Submitter Vincent Stehlé
Date Nov. 19, 2012, 2:59 p.m.
Message ID <1353337174-9858-3-git-send-email-v-stehle@ti.com>
Download mbox | patch
Permalink /patch/200025/
State Changes Requested
Delegated to: Tom Rini
Headers show

Comments

Vincent Stehlé - Nov. 19, 2012, 2:59 p.m.
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é <v-stehle@ti.com>
---
 arch/arm/cpu/armv7/omap5/Makefile     |    1 +
 arch/arm/cpu/armv7/omap5/cache-cp15.c |   40 +++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/omap5/cache-cp15.c
Tom Rini - Nov. 19, 2012, 8:49 p.m.
On Mon, Nov 19, 2012 at 03:59:34PM +0100, Vincent Stehlé wrote:

> 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é <v-stehle@ti.com>
[snip]
> +	/* Perform default mapping, which sets up an identity-mapping for all
> +	 * 4GB, rw for everyone */

/*
 * Multi-line comments must all be like this.
 */

Aside from that (and the comment to 1/2) I think we're good here,
including the naming of the function.  Thanks!
Vincent Stehlé - Nov. 20, 2012, 11:01 a.m.
Tom Rini:
> Aside from that (and the comment to 1/2) I think we're good here,
> including the naming of the function.  Thanks!

Hi Tom,

Thank you very much for your review.

Here is v3 of the patch series with reworks for __weak and comments style:

  [PATCH 1/2] ARM: cache: introduce weak arm_setup_identity_mapping
  [PATCH 2/2] ARM: OMAP5: redefine arm_setup_identity_mapping

This boots ok on OMAP5 HS device.

Best regards,

V.

Patch

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..506cc00
--- /dev/null
+++ b/arch/arm/cpu/armv7/omap5/cache-cp15.c
@@ -0,0 +1,40 @@ 
+/*
+ * (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 <common.h>
+
+/* OMAP5 specific function to set up the identity mapping. */
+void arm_setup_identity_mapping(u32 *page_table)
+{
+	/* 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;
+}