imx: Support i.MX6 High Assurance Boot authentication
PATCH v4 1/1 imx: Support i.MX6 High Assurance Boot authentication
When CONFIG_SECURE_BOOT is enabled, the signed images like kernel and dtb can be authenticated using iMX6 CAAM. The added command hab_auth_img can be used for HAB authentication of images. The command takes the image DDR location, IVT (Image Vector Table) offset inside image as parameters. Detailed info about signing images can be found in Freescale AppNote AN4581.
---
Changes in v4:
- Use single hab_caam_clock_enable api for en/disable
- Remove unused DEBUG_AUTHENTICATE_IMAGE
- Use DEBUG instead of DEBUG_AUTHENTICATE_IMAGE
- Add defined for pu_irom_mmu_enabled var location
- Add MMU check before setting ROM variable
- Replace printf with puts where applicable
Changes in v3:
- Remove typecast of get_cpu_rev since its not required
Changes in v2:
- Cleaned up clock code as per review comments
- Removed dead code as per review comments
- Re-written commit log as per review comments
arch/arm/cpu/armv7/mx6/clock.c | 27 ++++++ arch/arm/cpu/armv7/mx6/hab.c | 169 ++++++++++++++++++++++++++++++++- arch/arm/cpu/armv7/mx6/soc.c | 15 +++ arch/arm/include/asm/arch-mx6/clock.h | 1 + 4 files changed, 211 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/mx6/clock.c +27 -0
@@ -568,6 +568,33 @@ void enable_pll3(void) } } +#ifdef CONFIG_SECURE_BOOT +void hab_caam_clock_enable (unsigned char enable) +{ +u32 reg; + +/* CG4 ~ CG6, CAAM clocks */ + reg =__raw_readl (&imx_ccm->CCGR0); +if (enable) + reg |= (MXC_CCM_CCGR0_CAAM_WRAPPER_IPG_MASK | +MXC_CCM_CCGR0_CAAM_WRAPPER_ACLK_MASK | +MXC_CCM_CCGR0_CAAM_SECURE_MEM_MASK ); +else + reg &= ~(MXC_CCM_CCGR0_CAAM_WRAPPER_IPG_MASK | +MXC_CCM_CCGR0_CAAM_WRAPPER_ACLK_MASK | +MXC_CCM_CCGR0_CAAM_SECURE_MEM_MASK ); +__raw_writel (reg, &imx_ccm->CCGR0); + +/* EMI slow clk */ + reg =__raw_readl (&imx_ccm->CCGR6); +if (enable) + reg |=MXC_CCM_CCGR6_EMI_SLOW_MASK ; +else + reg &= ~MXC_CCM_CCGR6_EMI_SLOW_MASK ; +__raw_writel (reg, &imx_ccm->CCGR6); +} +#endif +unsigned int mxc_get_clock (enum mxc_clock clk) {switch (clk) {
arch/arm/cpu/armv7/mx6/hab.c +168 -1
200 lines not on this page · raw message
arch/arm/cpu/armv7/mx6/soc.c +15 -0
@@ -273,10 +273,25 @@ int board_postclk_init(void)#ifndef CONFIG_SYS_DCACHE_OFF void enable_caches (void ) { +#if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH ) +enum dcache_option option =DCACHE_WRITETHROUGH ; +#else +enum dcache_option option =DCACHE_WRITEBACK ; +#endif +/* Avoid random hang when download by usb */ invalidate_dcache_all (); +/* Enable D-cache. I-cache is already enabled in start.S */ dcache_enable (); + +/* Enable caching on OCRAM and ROM */ +mmu_set_region_dcache_behaviour (ROMCP_ARB_BASE_ADDR , +ROMCP_ARB_END_ADDR , + option); +mmu_set_region_dcache_behaviour (IRAM_BASE_ADDR , +IRAM_SIZE , + option); }#endif
arch/arm/include/asm/arch-mx6/clock.h +1 -0
@@ -61,4 +61,5 @@ int enable_spi_clk(unsigned char enable, unsigned spi_num);void enable_ipu_clock (void );int enable_fec_anatop_clock (enum enet_freq freq);void enable_pll3 (void ); +void hab_caam_clock_enable (unsigned char enable);#endif /* __ASM_ARCH_CLOCK_H */
Signature · 1 line
1.7.9.5
PATCH v4 1/1 imx: Support i.MX6 High Assurance Boot authentication
Hi Nitin,
Quoted 8 lines · Nitin Garg
When
CONFIG_SECURE_BOOTis enabled, the signed images like kernel and dtb can be authenticated using iMX6 CAAM. The added commandhab_auth_imgcan be used for HAB authentication of images. The command takes the image DDR location, IVT (Image Vector Table) offset inside image as parameters. Detailed info about signing images can be found in Freescale AppNote AN4581.
Quoted 4 lines
Signed-off-by Nitin Garg <[email protected]>---
I wanted to apply it on current tree, but it seems it depends on "mx6: clock: Add api to enable pll3". Or better, it seems in your tree on top the the patch for pll3. It is not an issue and I solve it myself, but can you confim that or do you prefer that I apply this one only after the thermal series will be merged ?
Best regards,
Stefano Babic
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-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 1/1 imx: Support i.MX6 High Assurance Boot authentication
Hi Stefano,
Quoted 16 lines · Stefano Babic
Hi Nitin,
Quoted 8 lines · Nitin Garg
When
CONFIG_SECURE_BOOTis enabled, the signed images like kernel and dtb can be authenticated using iMX6 CAAM. The added commandhab_auth_imgcan be used for HAB authentication of images. The command takes the image DDR location, IVT (Image Vector Table) offset inside image as parameters. Detailed info about signing images can be found in Freescale AppNote AN4581.Quoted 4 lines
Signed-off-by Nitin Garg <[email protected]>---
Quoted 10 lines
I wanted to apply it on current tree, but it seems it depends on "mx6: clock: Add api to enable pll3". Or better, it seems in your tree on top the the patch for pll3. It is not an issue and I solve it myself, but can you confim that or do you prefer that I apply this one only after the thermal series will be merged ?
Best regards,
Stefano Babic
Yes you are correct, in my tree I did HAB patch on top of temperature sensor patch. Pls resolve it or I can help if needed. I do not have any preference with ordering of HAB and temperature patch.
Thanks,
Nitin Garg
PATCH v4 1/1 imx: Support i.MX6 High Assurance Boot authentication
In reply to Nitin GargHi Nitin,
Quoted 8 lines · Nitin Garg
When
CONFIG_SECURE_BOOTis enabled, the signed images like kernel and dtb can be authenticated using iMX6 CAAM. The added commandhab_auth_imgcan be used for HAB authentication of images. The command takes the image DDR location, IVT (Image Vector Table) offset inside image as parameters. Detailed info about signing images can be found in Freescale AppNote AN4581.
Quoted 4 lines
Signed-off-by Nitin Garg <[email protected]>---
Applied to u-boot-imx, thanks !
Best regards,
Stefano Babic
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-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v4 1/1 imx: Support i.MX6 High Assurance Boot authentication
In reply to Nitin GargHi Nitin,
Quoted 9 lines · Nitin Garg
When
CONFIG_SECURE_BOOTis enabled, the signed images like kernel and dtb can be authenticated using iMX6 CAAM. The added commandhab_auth_imgcan be used for HAB authentication of images. The command takes the image DDR location, IVT (Image Vector Table) offset inside image as parameters. Detailed info about signing images can be found in Freescale AppNote AN4581.Signed-off-by Nitin Garg <[email protected]>
I have just tested the 'hab_status' command and it hangs my mx6sxsabresd board:
U-Boot 2014.10-rc2-16959-g6eb2f0d-dirty (Sep 30 2014 - 10:28:19)
CPU: Freescale i.MX6SX rev1.0 at 792 MHz Reset cause: POR Board: MX6SX SABRE SDB I2C: ready DRAM: 1 GiB MMC: FSL_SDHC: 0 In: serial Out: serial Err: serial PMIC: PFUZE100 ID=0x10 Net: FEC [PRIME] Hit any key to stop autoboot: 0
=> hab_status
Secure boot disabled
(hangs the system)
Could you please take a look at this issue?
PATCH v4 1/1 imx: Support i.MX6 High Assurance Boot authentication
Hi Fabio,
Quoted 29 lines · Fabio Estevam
Hi Nitin,
Quoted 9 lines · Nitin Garg
When
CONFIG_SECURE_BOOTis enabled, the signed images like kernel and dtb can be authenticated using iMX6 CAAM. The added commandhab_auth_imgcan be used for HAB authentication of images. The command takes the image DDR location, IVT (Image Vector Table) offset inside image as parameters. Detailed info about signing images can be found in Freescale AppNote AN4581.Signed-off-by Nitin Garg <[email protected]>I have just tested the '
hab_status' command and it hangs my mx6sxsabresd board:U-Boot 2014.10-rc2-16959-g6eb2f0d-dirty (Sep 30 2014 - 10:28:19)
CPU: Freescale i.MX6SX rev1.0 at 792 MHz Reset cause: POR Board: MX6SX SABRE SDB I2C: ready DRAM: 1 GiB MMC: FSL_SDHC: 0 In: serial Out: serial Err: serial PMIC: PFUZE100 ID=0x10 Net: FEC [PRIME] Hit any key to stop autoboot: 0
Quoted 8 lines
=>
hab_statusSecure boot disabled
(hangs the system)
Could you please take a look at this issue?
I found the reason for the hang. The HAB api table was not updated for i.MX6SX. Since i.MX6SX ROM implements unified sections in ROM, the HAP function pointers needs to be updated. I have sent a patch for the same.
-Nitin