Skip to contentSkip to conversation

i.MX6ULL: set engine software for Secure Boot on HABv4

PATCH Superseded Maik Otto 2 participants 5 messages Sep 11, 2020 – Sep 17, 2020

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Maik Otto

author
#0 lore raw

v2 cover i.MX6ULL: set engine software for Secure Boot on HABv4

The i.MX6ULL has no CAAM engine for Secure Boot on HABv4. This patch series set the engine software for i.MX6ULL and for the PHYTEC boards PCL-063 with i.MX6ULL.

Changes in v2:
- Rework in Patch 2 the file habv4-imx6-gencsf.h, because cst 3.3.1 fails for engine software with parameter Feature.

Maik Otto (2):
arch: arm: boards phytec: Split flash header for pcl063 with i.MX6Ul
and i.MX6ULL
arch: arm: mach-imx: Add habv4 config file for i.MX6ULL

 ...tec-pcl063-512mb.imxcfg => flash-header-phytec-pcl063-512mb.h} | 1 -
 .../phytec-som-imx6/flash-header-phytec-pcl063ul-512mb.imxcfg     | 3 +++
 ...63-256mb.imxcfg => flash-header-phytec-pcl063ull-256mb.imxcfg} | 2 +-
 .../phytec-som-imx6/flash-header-phytec-pcl063ull-512mb.imxcfg    | 3 +++
 arch/arm/mach-imx/include/mach/habv4-imx6-gencsf.h                | 8 ++++++++
 arch/arm/mach-imx/include/mach/habv4-imx6ull-gencsf.h             | 4 ++++
 images/Makefile.imx                                               | 8 ++++----
 7 files changed, 23 insertions(+), 6 deletions(-)
 rename arch/arm/boards/phytec-som-imx6/{flash-header-phytec-pcl063-512mb.imxcfg => flash-header-phytec-pcl063-512mb.h} (83%)
 create mode 100644 arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063ul-512mb.imxcfg
 rename arch/arm/boards/phytec-som-imx6/{flash-header-phytec-pcl063-256mb.imxcfg => flash-header-phytec-pcl063ull-256mb.imxcfg} (82%)
 create mode 100644 arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063ull-512mb.imxcfg
 create mode 100644 arch/arm/mach-imx/include/mach/habv4-imx6ull-gencsf.h
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
author
#1 lore raw

PATCH v2 1/2 arch: arm: boards phytec: Split flash header for pcl063 with i.MX6Ul and i.MX6ULL

i.MX6UL and i.MX6ULL have different engines for Secure Boot on HABv4. For better differentiation rename existing pcl063 flash headers to pcl063ul and pcl063ull.

---
Changes in v2:
- none

---
 ...tec-pcl063-512mb.imxcfg => flash-header-phytec-pcl063-512mb.h} | 1 -
 .../phytec-som-imx6/flash-header-phytec-pcl063ul-512mb.imxcfg     | 3 +++
 ...63-256mb.imxcfg => flash-header-phytec-pcl063ull-256mb.imxcfg} | 0
 .../phytec-som-imx6/flash-header-phytec-pcl063ull-512mb.imxcfg    | 3 +++
 images/Makefile.imx                                               | 8 ++++----
 5 files changed, 10 insertions(+), 5 deletions(-)
 rename arch/arm/boards/phytec-som-imx6/{flash-header-phytec-pcl063-512mb.imxcfg => flash-header-phytec-pcl063-512mb.h} (83%)
 create mode 100644 arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063ul-512mb.imxcfg
 rename arch/arm/boards/phytec-som-imx6/{flash-header-phytec-pcl063-256mb.imxcfg => flash-header-phytec-pcl063ull-256mb.imxcfg} (100%)
 create mode 100644 arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063ull-512mb.imxcfg
arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063-512mb.h renamed from arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063-512mb.imxcfg +0 -1
similarity index 83%
rename from arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063-512mb.imxcfg
rename to arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063-512mb.h
index 26998c3..c4122d2 100644
@@ -7,4 +7,3 @@
 	wm 32 0x021B0000 0x84180000
 
 #include "flash-header-phytec-pcl063.h"
-#include <mach/habv4-imx6-gencsf.h>
arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063ul-512mb.imxcfg new file +3 -0
new file mode 100644
index 0000000..f629a8e
@@ -0,0 +1,3 @@
+
+#include "flash-header-phytec-pcl063-512mb.h"
+#include <mach/habv4-imx6-gencsf.h>
arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063ull-256mb.imxcfg renamed from arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063-256mb.imxcfg +0 -0
similarity index 100%
rename from arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063-256mb.imxcfg
rename to arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063ull-256mb.imxcfg
arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063ull-512mb.imxcfg new file +3 -0
new file mode 100644
index 0000000..f629a8e
@@ -0,0 +1,3 @@
+
+#include "flash-header-phytec-pcl063-512mb.h"
+#include <mach/habv4-imx6-gencsf.h>
images/Makefile.imx +4 -4
index 7b24e5f..3434a10 100644
@@ -346,13 +346,13 @@ $(call build_imx_habv4img, CONFIG_MACH_GRINN_LITEBOARD, start_imx6ul_liteboard_5
 
 $(call build_imx_habv4img, CONFIG_MACH_NXP_IMX6ULL_EVK, start_nxp_imx6ull_evk, nxp-imx6ull-evk/flash-header-nxp-imx6ull-evk, nxp-imx6ull-evk)
 
-$(call build_imx_habv4img, CONFIG_MACH_PHYTEC_SOM_IMX6, start_phytec_phycore_imx6ul_som_nand_512mb, phytec-som-imx6/flash-header-phytec-pcl063-512mb, phytec-phycore-imx6ul-nand-512mb)
+$(call build_imx_habv4img, CONFIG_MACH_PHYTEC_SOM_IMX6, start_phytec_phycore_imx6ul_som_nand_512mb, phytec-som-imx6/flash-header-phytec-pcl063ul-512mb, phytec-phycore-imx6ul-nand-512mb)
 
-$(call build_imx_habv4img, CONFIG_MACH_PHYTEC_SOM_IMX6, start_phytec_phycore_imx6ull_som_lc_nand_256mb, phytec-som-imx6/flash-header-phytec-pcl063-256mb, phytec-phycore-imx6ull-lc-nand-256mb)
+$(call build_imx_habv4img, CONFIG_MACH_PHYTEC_SOM_IMX6, start_phytec_phycore_imx6ull_som_lc_nand_256mb, phytec-som-imx6/flash-header-phytec-pcl063ull-256mb, phytec-phycore-imx6ull-lc-nand-256mb)
 
-$(call build_imx_habv4img, CONFIG_MACH_PHYTEC_SOM_IMX6, start_phytec_phycore_imx6ull_som_nand_512mb, phytec-som-imx6/flash-header-phytec-pcl063-512mb, phytec-phycore-imx6ull-nand-512mb)
+$(call build_imx_habv4img, CONFIG_MACH_PHYTEC_SOM_IMX6, start_phytec_phycore_imx6ull_som_nand_512mb, phytec-som-imx6/flash-header-phytec-pcl063ull-512mb, phytec-phycore-imx6ull-nand-512mb)
 
-$(call build_imx_habv4img, CONFIG_MACH_PHYTEC_SOM_IMX6, start_phytec_phycore_imx6ull_som_emmc_512mb, phytec-som-imx6/flash-header-phytec-pcl063-512mb, phytec-phycore-imx6ull-emmc-512mb)
+$(call build_imx_habv4img, CONFIG_MACH_PHYTEC_SOM_IMX6, start_phytec_phycore_imx6ull_som_emmc_512mb, phytec-som-imx6/flash-header-phytec-pcl063ull-512mb, phytec-phycore-imx6ull-emmc-512mb)
 
 $(call build_imx_habv4img, CONFIG_MACH_PROTONIC_IMX6, start_imx6ul_prti6g, protonic-imx6/flash-header-prti6g, protonic-prti6g)
 
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
author
#2 lore raw

PATCH v2 2/2 arch: arm: mach-imx: Add habv4 config file for i.MX6ULL

In reply to Maik Otto

The i.MX6ULL has no CAAM engine for Secure Boot on HABv4 (NXP AN4581). For i.MX6ULL the engine Software (SW) must used for the image validation.

---
Changes in v2:
- Rework the file habv4-imx6-gencsf.h, because cst 3.3.1 fails for engine software with parameter Feature.

---
 .../phytec-som-imx6/flash-header-phytec-pcl063ull-256mb.imxcfg    | 2 +-
 .../phytec-som-imx6/flash-header-phytec-pcl063ull-512mb.imxcfg    | 2 +-
 arch/arm/mach-imx/include/mach/habv4-imx6-gencsf.h                | 8 ++++++++
 arch/arm/mach-imx/include/mach/habv4-imx6ull-gencsf.h             | 4 ++++
 4 files changed, 14 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-imx/include/mach/habv4-imx6ull-gencsf.h
arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063ull-256mb.imxcfg +1 -1
index b93e81f..e6871d8 100644
@@ -7,4 +7,4 @@
 	wm 32 0x021B0000 0x83180000
 
 #include "flash-header-phytec-pcl063.h"
-#include <mach/habv4-imx6-gencsf.h>
+#include <mach/habv4-imx6ull-gencsf.h>
arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063ull-512mb.imxcfg +1 -1
index f629a8e..d2d7183 100644
@@ -1,3 +1,3 @@
 
 #include "flash-header-phytec-pcl063-512mb.h"
-#include <mach/habv4-imx6-gencsf.h>
+#include <mach/habv4-imx6ull-gencsf.h>
arch/arm/mach-imx/include/mach/habv4-imx6-gencsf.h +8 -0
index 17c4d79..ee21e0b 100644
@@ -14,7 +14,11 @@ hab Hash Algorithm = sha256
 hab Engine Configuration = 0
 hab Certificate Format = X509
 hab Signature Format = CMS
+#ifndef SETUP_HABV4_ENGINE
 hab Engine = CAAM
+#else
+hab Engine = SETUP_HABV4_ENGINE
+#endif
 
 hab [Install SRK]
 hab File = CONFIG_HABV4_TABLE_BIN
@@ -28,8 +32,12 @@ hab File = CONFIG_HABV4_CSF_CRT_PEM
 hab [Authenticate CSF]
 
 hab [Unlock]
+#ifndef SETUP_HABV4_ENGINE
 hab Engine = CAAM
 hab Features = RNG, MID
+#else
+hab Engine = SETUP_HABV4_ENGINE
+#endif
 
 hab [Install Key]
 /* verification key index in key store (0, 2...4) */
arch/arm/mach-imx/include/mach/habv4-imx6ull-gencsf.h new file +4 -0
new file mode 100644
index 0000000..54c4915
@@ -0,0 +1,4 @@
+
+#define SETUP_HABV4_ENGINE SW
+
+#include <mach/habv4-imx6-gencsf.h>
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
maintainer
#3 lore raw

Re: [PATCH v2 2/2] arch: arm: mach-imx: Add habv4 config file for i.MX6ULL

Hi Maik,

arch/arm/mach-imx/include/mach/habv4-imx6-gencsf.h

Quoted 14 lines · Maik Otto

The i.MX6ULL has no CAAM engine for Secure Boot on HABv4 (NXP AN4581). For i.MX6ULL the engine Software (SW) must used for the image validation.

+++ b/arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063ull-512mb.imxcfg

arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063ull-512mb.imxcfg +1 -1
@@ -1,3 +1,3 @@
 
 #include "flash-header-phytec-pcl063-512mb.h"
-#include <mach/habv4-imx6-gencsf.h>
+#include <mach/habv4-imx6ull-gencsf.h>
arch/arm/mach-imx/include/mach/habv4-imx6-gencsf.h +0 -0
index 17c4d79..ee21e0b 100644

I would prefer to rename this file to habv4-imx6-gencsf-template.h and let it start with:

#ifndef SETUP_HABV4_ENGINE
#error "SETUP_HABV4_ENGINE undefined"
#endif

The habv4-imx6-gencsf.h would then only set the defines and include the template file like you already did for the i.MX6ULL.

This makes it more clear what defines the file expects.

Quoted 13 lines
arch/arm/mach-imx/include/mach/habv4-imx6-gencsf.h +4 -0
@@ -14,7 +14,11 @@ hab Hash Algorithm = sha256
 hab Engine Configuration = 0
 hab Certificate Format = X509
 hab Signature Format = CMS
+#ifndef SETUP_HABV4_ENGINE
 hab Engine = CAAM
+#else
+hab Engine = SETUP_HABV4_ENGINE
+#endif
 
 hab [Install SRK]
 hab File = CONFIG_HABV4_TABLE_BIN

arch/arm/mach-imx/include/mach/habv4-imx6-gencsf.h hab File = CONFIG_HABV4_CSF_CRT_PEM · line 40

Quoted 9 lines
arch/arm/mach-imx/include/mach/habv4-imx6-gencsf.h +4 -0
@@ -28,8 +32,12 @@ hab File = CONFIG_HABV4_CSF_CRT_PEM
 hab [Authenticate CSF]
 
 hab [Unlock]
+#ifndef SETUP_HABV4_ENGINE
 hab Engine = CAAM
 hab Features = RNG, MID
+#else
+hab Engine = SETUP_HABV4_ENGINE
+#endif

Do we need this #ifdef here? Can't we instead have a SETUP_HABV4_FEATURES macro and let the SoC specific files define it as

#define SETUP_HABV4_FEATURES RNG,MID

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
author
#4 lore raw

Re: [PATCH v2 2/2] arch: arm: mach-imx: Add habv4 config file for i.MX6ULL

Hi Sascha,

Am 14.09.2020 um 10:44 schrieb Sascha Hauer:

Quoted 20 lines

Hi Maik,

arch/arm/mach-imx/include/mach/habv4-imx6-gencsf.h

Quoted 14 lines · Maik Otto

The i.MX6ULL has no CAAM engine for Secure Boot on HABv4 (NXP AN4581). For i.MX6ULL the engine Software (SW) must used for the image validation.

+++ b/arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063ull-512mb.imxcfg

arch/arm/boards/phytec-som-imx6/flash-header-phytec-pcl063ull-512mb.imxcfg +1 -1
@@ -1,3 +1,3 @@
 
 #include "flash-header-phytec-pcl063-512mb.h"
-#include <mach/habv4-imx6-gencsf.h>
+#include <mach/habv4-imx6ull-gencsf.h>
arch/arm/mach-imx/include/mach/habv4-imx6-gencsf.h +0 -0
index 17c4d79..ee21e0b 100644

I would prefer to rename this file to habv4-imx6-gencsf-template.h and let it start with:

Quoted 8 lines

#ifndef SETUP_HABV4_ENGINE
#error "SETUP_HABV4_ENGINE undefined"
#endif

The habv4-imx6-gencsf.h would then only set the defines and include the template file like you already did for the i.MX6ULL.

This makes it more clear what defines the file expects.

ok, is fine. I will change it

Quoted 25 lines
Quoted 13 lines
arch/arm/mach-imx/include/mach/habv4-imx6-gencsf.h +4 -0
@@ -14,7 +14,11 @@ hab Hash Algorithm = sha256
 hab Engine Configuration = 0
 hab Certificate Format = X509
 hab Signature Format = CMS
+#ifndef SETUP_HABV4_ENGINE
 hab Engine = CAAM
+#else
+hab Engine = SETUP_HABV4_ENGINE
+#endif
 
 hab [Install SRK]
 hab File = CONFIG_HABV4_TABLE_BIN

arch/arm/mach-imx/include/mach/habv4-imx6-gencsf.h hab File = CONFIG_HABV4_CSF_CRT_PEM · line 40

Quoted 9 lines
arch/arm/mach-imx/include/mach/habv4-imx6-gencsf.h +4 -0
@@ -28,8 +32,12 @@ hab File = CONFIG_HABV4_CSF_CRT_PEM
 hab [Authenticate CSF]
 
 hab [Unlock]
+#ifndef SETUP_HABV4_ENGINE
 hab Engine = CAAM
 hab Features = RNG, MID
+#else
+hab Engine = SETUP_HABV4_ENGINE
+#endif

Do we need this #ifdef here? Can't we instead have a SETUP_HABV4_FEATURES macro and let the SoC specific files define it as

Quoted 1 line

#define SETUP_HABV4_FEATURES RNG,MID

yes we need it, because the cst tool in version 3.3.1 fails for hab Engine = SW with hab Features =
The older versions of cst tool had no problem with it.

I rework it to
#ifdef SETUP_HABV4_FEATURES
hab FEATURES = SETUP_HABV4_FEATURES
#endif

Quoted 3 lines

Sascha

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox