Skip to contentSkip to conversation

powerpc/p4080: Add support for secure boot flow on CoreNet Based QorIQ chips

PATCH New Kumar Gala 2 participants 2 messages Apr 9, 2011 – Apr 30, 2011 PowerPC

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

PATCH 1/1 powerpc/p4080: Add support for secure boot flow on CoreNet Based QorIQ chips

From: Ruchika Gupta <[email protected]>

1. Create a temp mapping in AS=1 of CONFIG_SYS_MONITOR_BASE to the 1M CONFIG_SYS_PBI_FLASH_WINDOW
(The CONFIG_SYS_PBI_FLASH_WINDOW is the address map for the flash
created by PBL within 0 - 3.5G memory range. The u-boot image at this address has been validated by ISBC code)
2. Remove TLB entries for 0 - 3.5G created by ISBC code
3. Remove the LAW entry for the CONFIG_SYS_PBI_FLASH_WINDOW created by PBL after switch to AS = 1

Flow for secure-boot for which the changes have been made is given below:
1. User loads the u-boot image in flash
2. PBL creates LAW for Flash at 0xc0000000
(Please note that ISBC expects all these addresses, images to be
validated, entry point etc within 0 - 3.5G range)
3. ISBC validates the u-boot image, and passes control to u-boot at 0xcffffffc.

---
 arch/powerpc/cpu/mpc85xx/cpu_init.c        |    7 ++++
 arch/powerpc/cpu/mpc85xx/cpu_init_early.c  |   10 +++++-
 arch/powerpc/cpu/mpc85xx/start.S           |   53 +++++++++++++++++++++++++++-
 arch/powerpc/include/asm/fsl_secure_boot.h |   40 +++++++++++++++++++++
 boards.cfg                                 |    1 +
 include/configs/corenet_ds.h               |    4 ++
 6 files changed, 113 insertions(+), 2 deletions(-)
 create mode 100644 arch/powerpc/include/asm/fsl_secure_boot.h
arch/powerpc/cpu/mpc85xx/cpu_init.c +7 -0
index 6f256cf..aafb007 100644
@@ -239,6 +239,13 @@ void cpu_init_f (void)
 	disable_tlb(14);
 	disable_tlb(15);
 
+#ifdef CONFIG_SYS_ESBC_FLASH
+	/* Disable the LAW created for NOR flash by the PBI commands */
+	struct law_entry law = find_law(CONFIG_SYS_PBI_FLASH_BASE);
+	if (law.index != -1)
+		disable_law(law.index);
+#endif
+
 #ifdef CONFIG_CPM2
 	config_8560_ioports((ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR);
 #endif
arch/powerpc/cpu/mpc85xx/cpu_init_early.c +9 -1
index 32aa94b..58397ec 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009 Freescale Semiconductor, Inc
+ * Copyright 2009-2011 Freescale Semiconductor, Inc
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -108,5 +108,13 @@ void cpu_init_early_f(void)
 
 	init_laws();
 	invalidate_tlb(0);
+
+#if defined(CONFIG_SECURE_BOOT)
+/* Disable the TLBs created by ISBC */
+	for (i = CONFIG_SYS_ISBC_START_TLB;
+	     i < CONFIG_SYS_ISBC_START_TLB + CONFIG_SYS_ISBC_NUM_TLBS; i++)
+			disable_tlb(i);
+#endif
+
 	init_tlbs();
 }
arch/powerpc/cpu/mpc85xx/start.S +52 -1

71 lines not on this page · raw message

arch/powerpc/include/asm/fsl_secure_boot.h new file +40 -0
new file mode 100644
index 0000000..786a98e
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2010-2011 Freescale Semiconductor, Inc.
+ *
+ * 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
+ */
+
+#ifndef __FSL_SECURE_BOOT_H
+#define __FSL_SECURE_BOOT_H
+
+/* This define indicates that u-boot's code is executing from flash
+ * after ISBC Validation */
+#define CONFIG_SYS_ESBC_FLASH
+
+/*Starting TLB number for the TLB entried for 3.5 G space created by ISBC */
+#define CONFIG_SYS_ISBC_START_TLB		3
+
+/* Number fo TLB's created by ISBC */
+#define CONFIG_SYS_ISBC_NUM_TLBS		5
+
+/* Address map where flash lies as done by PBI commands */
+#define CONFIG_SYS_PBI_FLASH_BASE		0xc0000000
+#define CONFIG_SYS_PBI_FLASH_WINDOW		0xcff80000
+
+#endif
boards.cfg +1 -0
index cc1ae6c..6ffcd96 100644
@@ -545,6 +545,7 @@ P2020RDB_SDCARD              powerpc     mpc85xx     p1_p2_rdb           freesca
 P2020RDB_SPIFLASH            powerpc     mpc85xx     p1_p2_rdb           freescale      -           P1_P2_RDB:P2020RDB,SPIFLASH
 P4080DS                      powerpc     mpc85xx     corenet_ds          freescale
 P4080DS_RAMBOOT_PBL          powerpc     mpc85xx     corenet_ds          freescale      -           P4080DS:RAMBOOT_PBL,SYS_TEXT_BASE=0xFFF80000
+P4080DS_SECURE_BOOT          powerpc     mpc85xx     corenet_ds          freescale      -           P4080DS:SECURE_BOOT
 mpq101                       powerpc     mpc85xx     mpq101              mercury        -           mpq101
 stxgp3                       powerpc     mpc85xx     stxgp3              stx
 stxssa                       powerpc     mpc85xx     stxssa              stx            -           stxssa
include/configs/corenet_ds.h +4 -0
index 2bd2553..9bc9017 100644
@@ -607,4 +607,8 @@
 
 #define CONFIG_BOOTCOMMAND		CONFIG_HDBOOT
 
+#ifdef CONFIG_SECURE_BOOT
+#include <asm/fsl_secure_boot.h>
+#endif
+
 #endif	/* __CONFIG_H */
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 1/1 powerpc/p4080: Add support for secure boot flow on CoreNet Based QorIQ chips

Dear Kumar Gala,

In message <[email protected]> you wrote:
...

arch/powerpc/cpu/mpc85xx/cpu_init.c void cpu_init_f (void) · line 244

Quoted 11 lines
arch/powerpc/cpu/mpc85xx/cpu_init.c +3 -0
index 6f256cf..aafb007 100644
@@ -239,6 +239,13 @@ void cpu_init_f (void)
 	disable_tlb(14);
 	disable_tlb(15);
 
+#ifdef CONFIG_SYS_ESBC_FLASH
+	/* Disable the LAW created for NOR flash by the PBI commands */
+	struct law_entry law = find_law(CONFIG_SYS_PBI_FLASH_BASE);

NAK. We do not allow variable declaratios in the middle of the code.

arch/powerpc/cpu/mpc85xx/cpu_init.c void cpu_init_f (void) · line 247

Quoted 3 lines
arch/powerpc/cpu/mpc85xx/cpu_init.c +3 -0
+#if defined(CONFIG_SECURE_BOOT)
+/* Disable the TLBs created by ISBC */
+	for (i = CONFIG_SYS_ISBC_START_TLB;

The comment should be indented as the following code.

arch/powerpc/cpu/mpc85xx/cpu_init.c void cpu_init_f (void)

Quoted 5 lines
arch/powerpc/cpu/mpc85xx/cpu_init.c +5 -0
+#ifdef CONFIG_SECURE_BOOT
+	/* ISBC uses L2 as stack.
+	Disable L2 cache here so that u-boot can enable it later
+	as part of it's normal flow
+	*/

Incorrect multiline comment style. Please fix globally.

arch/powerpc/cpu/mpc85xx/cpu_init.c

Quoted 2 lines
arch/powerpc/cpu/mpc85xx/cpu_init.c +2 -0
+	lis     r9,FSL_BOOKE_MAS3(CONFIG_SYS_PBI_FLASH_WINDOW, 0, (MAS3_SX|MAS3_SW|MAS3_SR))@h
+	ori     r9,r9,FSL_BOOKE_MAS3(CONFIG_SYS_PBI_FLASH_WINDOW, 0, (MAS3_SX|MAS3_SW|MAS3_SR))@l

Lines too long. Please fix globally.

...

include/configs/corenet_ds.h line 612

Quoted 9 lines
include/configs/corenet_ds.h +3 -0
@@ -607,4 +607,8 @@
 
 #define CONFIG_BOOTCOMMAND		CONFIG_HDBOOT
 
+#ifdef CONFIG_SECURE_BOOT
+#include <asm/fsl_secure_boot.h>
+#endif

Is this #ifdef really needed ?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Do not underestimate the value of print statements for debugging.
Don't have aesthetic convulsions when using them, either.