Skip to contentSkip to conversation

board: ls1043ardb: move sec_init to board_init

PATCH New Sumit Garg 2 participants 4 messages Sep 1, 2016 – Sep 20, 2016 Arm (32-bit)

lore
Share & tools
lore

Sumit Garg

author
#0 lore raw

PATCH v2 1/2 board: ls1043ardb: move sec_init to board_init

sec_init() which was earlier called in misc_init_r() is now done in board_init() before PPA init as SEC block will be used during PPA image validation.

---

Changes in v2:
Rebased Aneesh's patchset. No dependency.
Link to patchset: https://patchwork.ozlabs.org/patch/586783/

 board/freescale/ls1043ardb/ls1043ardb.c | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)
board/freescale/ls1043ardb/ls1043ardb.c +17 -15
index d3e37b4..70fef79 100644
@@ -94,6 +94,23 @@ int board_init(void)
 	enable_layerscape_ns_access();
 #endif
 
+#ifdef CONFIG_SECURE_BOOT
+	/* In case of Secure Boot, the IBR configures the SMMU
+	 * to allow only Secure transactions.
+	 * SMMU must be reset in bypass mode.
+	 * Set the ClientPD bit and Clear the USFCFG Bit
+	 */
+	u32 val;
+	val = (in_le32(SMMU_SCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
+	out_le32(SMMU_SCR0, val);
+	val = (in_le32(SMMU_NSCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
+	out_le32(SMMU_NSCR0, val);
+#endif
+
+#ifdef CONFIG_FSL_CAAM
+	sec_init();
+#endif
+
 #ifdef CONFIG_FSL_LS_PPA
 	ppa_init();
 #endif
@@ -137,21 +154,6 @@ int config_board_mux(void)
 int misc_init_r(void)
 {
 	config_board_mux();
-#ifdef CONFIG_SECURE_BOOT
-	/* In case of Secure Boot, the IBR configures the SMMU
-	 * to allow only Secure transactions.
-	 * SMMU must be reset in bypass mode.
-	 * Set the ClientPD bit and Clear the USFCFG Bit
-	 */
-	u32 val;
-	val = (in_le32(SMMU_SCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
-	out_le32(SMMU_SCR0, val);
-	val = (in_le32(SMMU_NSCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
-	out_le32(SMMU_NSCR0, val);
-#endif
-#ifdef CONFIG_FSL_CAAM
-	return sec_init();
-#endif
 	return 0;
 }
 #endif
Signature · 1 line
1.8.1.4
author
#1 lore raw

PATCH v2 2/2 ls1043ardb: PPA: add PPA validation in case of secure boot

As part of Secure Boot Chain of trust, PPA image must be validated before the image is started.
The code for the same has been added.

---

Rebased Aneesh's patchset. No dependency.
Link to patchset: https://patchwork.ozlabs.org/patch/586784/

 arch/arm/cpu/armv8/fsl-layerscape/ppa.c | 21 +++++++++++++++++++++
 arch/arm/include/asm/fsl_secure_boot.h  | 18 ++++++++++++++++++
 2 files changed, 39 insertions(+)
arch/arm/cpu/armv8/fsl-layerscape/ppa.c +21 -0
index f54ac3f..b68e87d 100644
@@ -17,6 +17,9 @@
 #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
 #include <asm/armv8/sec_firmware.h>
 #endif
+#ifdef CONFIG_CHAIN_OF_TRUST
+#include <fsl_validate.h>
+#endif
 
 int ppa_init(void)
 {
@@ -24,12 +27,30 @@ int ppa_init(void)
 	u32 *boot_loc_ptr_l, *boot_loc_ptr_h;
 	int ret;
 
+#ifdef CONFIG_CHAIN_OF_TRUST
+	uintptr_t ppa_esbc_hdr = CONFIG_SYS_LS_PPA_ESBC_ADDR;
+	uintptr_t ppa_img_addr = 0;
+#endif
+
 #ifdef CONFIG_SYS_LS_PPA_FW_IN_XIP
 	ppa_fit_addr = (void *)CONFIG_SYS_LS_PPA_FW_ADDR;
 #else
 #error "No CONFIG_SYS_LS_PPA_FW_IN_xxx defined"
 #endif
 
+#ifdef CONFIG_CHAIN_OF_TRUST
+	ppa_img_addr = (uintptr_t)ppa_fit_addr;
+	if (fsl_check_boot_mode_secure() != 0) {
+		ret = fsl_secboot_validate(ppa_esbc_hdr,
+					   CONFIG_PPA_KEY_HASH,
+					   &ppa_img_addr);
+		if (ret != 0)
+			printf("PPA validation failed\n");
+		else
+			printf("PPA validation Successful\n");
+	}
+#endif
+
 #ifdef CONFIG_FSL_LSCH3
 	struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
 	boot_loc_ptr_l = &gur->bootlocptrl;
arch/arm/include/asm/fsl_secure_boot.h +18 -0
index b35c271..6b9d3e4 100644
@@ -126,6 +126,24 @@
 /* BOOTSCRIPT_ADDR is not required */
 #endif
 
+#ifdef CONFIG_FSL_LS_PPA
+#ifdef CONFIG_SYS_LS_PPA_FW_IN_XIP
+#ifdef CONFIG_LS1043A
+#define CONFIG_SYS_LS_PPA_ESBC_ADDR	0x600c0000
+#endif
+#else
+#error "No CONFIG_SYS_LS_PPA_FW_IN_xxx defined"
+#endif /* ifdef CONFIG_SYS_LS_PPA_FW_IN_XIP */
+
+/* Define the key hash here if SRK used for signing PPA image is
+ * different from SRK hash put in SFP used for U-Boot.
+ * Example
+ * #define CONFIG_PPA_KEY_HASH \
+ *	"41066b564c6ffcef40ccbc1e0a5d0d519604000c785d97bbefd25e4d288d1c8b"
+ */
+#define CONFIG_PPA_KEY_HASH		NULL
+#endif /* ifdef CONFIG_FSL_LS_PPA */
+
 #include <config_fsl_chain_trust.h>
 #endif /* #ifndef CONFIG_SPL_BUILD */
 #endif /* #ifdef CONFIG_CHAIN_OF_TRUST */
Signature · 1 line
1.8.1.4
Applied
#3 lore raw

PATCH v2 1/2 board: ls1043ardb: move sec_init to board_init

In reply to Sumit Garg
Quoted 11 lines · Sumit Garg

sec_init() which was earlier called in misc_init_r() is now done in board_init() before PPA init as SEC block will be used during PPA image validation.

---

Changes in v2:
Rebased Aneesh's patchset. No dependency.
Link to patchset: https://patchwork.ozlabs.org/patch/586783/

Applied to fsl-qoriq master. Awaiting upstream. Thanks.

York

Applied
#2 lore raw

PATCH v2 2/2 ls1043ardb: PPA: add PPA validation in case of secure boot

In reply to Sumit Garg
Quoted 10 lines · Sumit Garg

As part of Secure Boot Chain of trust, PPA image must be validated before the image is started.
The code for the same has been added.

---

Rebased Aneesh's patchset. No dependency.
Link to patchset: https://patchwork.ozlabs.org/patch/586784/

Applied to fsl-qoriq master. Awaiting upstream. Thanks.

York