imx8: Add AHAB secure boot support
Subsystems (3)
PATCH 1/3 imx8: Add AHAB secure boot support
Add function and new command "auth_cntr" for secure boot support. When booting with life cycle set to OEM closed, we need to use this function to authenticate the OS container and load kernel & FDT from OS container to their destination.
Also add image authentication call when loading container images.
Users can set CONFIG_AHAB_BOOT=y to enable the feature. It is not set at default.
Signed-off-by Ye Li <[email protected]>
Signed-off-by Peng Fan <[email protected]>
--- arch/arm/mach-imx/imx8/Kconfig | 5 + arch/arm/mach-imx/imx8/ahab.c | 347 +++++++++++++++++++++++++++++++ arch/arm/mach-imx/imx8/parse-container.c | 95 ++++++++- 3 files changed, 443 insertions(+), 4 deletions(-) create mode 100644 arch/arm/mach-imx/imx8/ahab.c
arch/arm/mach-imx/imx8/Kconfig +5 -0
@@ -1,5 +1,10 @@ if ARCH_IMX8 +config AHAB_BOOT + bool "Support i.MX8 AHAB features" + help + This option enables the support for AHAB secure boot. + config IMX8 bool
arch/arm/mach-imx/imx8/ahab.c new file +347 -0
347 lines not on this page · raw message
arch/arm/mach-imx/imx8/parse-container.c +91 -4
130 lines not on this page · raw message
Signature · 1 line
2.16.4
PATCH 2/3 imx8qm: mek: add secure boot script
Add secure boot script, use ahab to verify image
Signed-off-by Peng Fan <[email protected]>
--- include/configs/imx8qm_mek.h | 64 +++++++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 15 deletions(-)
include/configs/imx8qm_mek.h +49 -15
@@ -56,8 +56,15 @@#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG +#ifdef CONFIG_AHAB_BOOT +#define AHAB_ENV "sec_boot=yes\0" +#else +#define AHAB_ENV "sec_boot=no\0" +#endif +/* Initial environment variables */ #define CONFIG_EXTRA_ENV_SETTINGS \ + AHAB_ENV \ "script=boot.scr\0" \ "image=Image\0" \ "panel=NULL\0" \
@@ -78,16 +85,27 @@"source\0" \"loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \"loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \ +"boot_os=booti ${loadaddr} - ${fdt_addr};\0" \ +"loadcntr=fatload mmc ${mmcdev}:${mmcpart} ${cntr_addr} ${cntr_file}\0" \ +"auth_os=auth_cntr ${cntr_addr}\0" \"mmcboot=echo Booting from mmc ...; " \"run mmcargs; " \ -"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \ -"if run loadfdt; then " \ -"booti ${loadaddr} - ${fdt_addr}; " \ +"if test ${sec_boot} = yes; then " \ +"if run auth_os; then " \ +"run boot_os; " \"else " \ -"echo WARN: Cannot load the DT; " \ +"echo ERR: failed to authenticate; " \"fi; " \"else " \ -"echo wait for boot; " \ +"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \ +"if run loadfdt; then " \ +"run boot_os; " \ +"else " \ +"echo WARN: Cannot load the DT; " \ +"fi; " \ +"else " \ +"echo wait for boot; " \ +"fi;" \"fi;\0" \"netargs=setenv bootargs console=${console} " \"root=/dev/nfs " \
@@ -99,15 +117,24 @@"else " \"setenv get_cmd tftp; " \"fi; " \ -"${get_cmd} ${loadaddr} ${image}; " \ -"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \ -"if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \ -"booti ${loadaddr} - ${fdt_addr}; " \ +"if test ${sec_boot} = yes; then " \ +"${get_cmd} ${cntr_addr} ${cntr_file}; " \ +"if run auth_os; then " \ +"run boot_os; " \"else " \ -"echo WARN: Cannot load the DT; " \ +"echo ERR: failed to authenticate; " \"fi; " \"else " \ -"booti; " \ +"${get_cmd} ${loadaddr} ${image}; " \ +"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \ +"if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \ +"booti ${loadaddr} - ${fdt_addr}; " \ +"else " \ +"echo WARN: Cannot load the DT; " \ +"fi; " \ +"else " \ +"booti; " \ +"fi;" \"fi;\0" #define CONFIG_BOOTCOMMAND \
@@ -115,10 +142,17 @@"if run loadbootscript; then " \"run bootscript; " \"else " \ -"if run loadimage; then " \ -"run mmcboot; " \ -"else run netboot; " \ -"fi; " \ +"if test ${sec_boot} = yes; then " \ +"if run loadcntr; then " \ +"run mmcboot; " \ +"else run netboot; " \ +"fi; " \ +"else " \ +"if run loadimage; then " \ +"run mmcboot; " \ +"else run netboot; " \ +"fi; " \ +"fi; " \"fi; " \"else booti ${loadaddr} - ${fdt_addr}; fi"
Signature · 1 line
2.16.4
PATCH 3/3 imx8qxp: mek: add secure boot script
In reply to Peng FanAdd secure boot script, use ahab to verify image
Signed-off-by Peng Fan <[email protected]>
--- include/configs/imx8qxp_mek.h | 64 +++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 15 deletions(-)
include/configs/imx8qxp_mek.h +49 -15
@@ -54,8 +54,15 @@#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG +#ifdef CONFIG_AHAB_BOOT +#define AHAB_ENV "sec_boot=yes\0" +#else +#define AHAB_ENV "sec_boot=no\0" +#endif +/* Initial environment variables */ #define CONFIG_EXTRA_ENV_SETTINGS \ + AHAB_ENV \ "script=boot.scr\0" \ "image=Image\0" \ "panel=NULL\0" \
@@ -76,16 +83,27 @@"source\0" \"loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \"loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \ +"loadcntr=fatload mmc ${mmcdev}:${mmcpart} ${cntr_addr} ${cntr_file}\0" \ +"auth_os=auth_cntr ${cntr_addr}\0" \ +"boot_os=booti ${loadaddr} - ${fdt_addr};\0" \"mmcboot=echo Booting from mmc ...; " \"run mmcargs; " \ -"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \ -"if run loadfdt; then " \ -"booti ${loadaddr} - ${fdt_addr}; " \ +"if test ${sec_boot} = yes; then " \ +"if run auth_os; then " \ +"run boot_os; " \"else " \ -"echo WARN: Cannot load the DT; " \ +"echo ERR: failed to authenticate; " \"fi; " \"else " \ -"echo wait for boot; " \ +"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \ +"if run loadfdt; then " \ +"run boot_os; " \ +"else " \ +"echo WARN: Cannot load the DT; " \ +"fi; " \ +"else " \ +"echo wait for boot; " \ +"fi;" \"fi;\0" \"netargs=setenv bootargs console=${console} " \"root=/dev/nfs " \
@@ -97,15 +115,24 @@"else " \"setenv get_cmd tftp; " \"fi; " \ -"${get_cmd} ${loadaddr} ${image}; " \ -"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \ -"if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \ -"booti ${loadaddr} - ${fdt_addr}; " \ +"if test ${sec_boot} = yes; then " \ +"${get_cmd} ${cntr_addr} ${cntr_file}; " \ +"if run auth_os; then " \ +"run boot_os; " \"else " \ -"echo WARN: Cannot load the DT; " \ +"echo ERR: failed to authenticate; " \"fi; " \"else " \ -"booti; " \ +"${get_cmd} ${loadaddr} ${image}; " \ +"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \ +"if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \ +"run boot_os; " \ +"else " \ +"echo WARN: Cannot load the DT; " \ +"fi; " \ +"else " \ +"booti; " \ +"fi;" \"fi;\0" #define CONFIG_BOOTCOMMAND \
@@ -113,10 +140,17 @@"if run loadbootscript; then " \"run bootscript; " \"else " \ -"if run loadimage; then " \ -"run mmcboot; " \ -"else run netboot; " \ -"fi; " \ +"if test ${sec_boot} = yes; then " \ +"if run loadcntr; then " \ +"run mmcboot; " \ +"else run netboot; " \ +"fi; " \ +"else " \ +"if run loadimage; then " \ +"run mmcboot; " \ +"else run netboot; " \ +"fi; " \ +"fi; " \"fi; " \"else booti ${loadaddr} - ${fdt_addr}; fi"
Signature · 1 line
2.16.4