board: zynqmp: add cmd for getting boot auth state
Subsystems (3)
PATCH v6 1/1 board: zynqmp: add cmd for getting boot auth state
Add command for checking if boot was authenticated.
---V1->V2:
- extended zynqmp command with verify_auth sub-command
- changed return value, so it can be used with scripts V2->V3:
- separated status and ret values
- replaced BIT(0) with ZYNQMP_CSU_STATUS_AUTHENTICATED
- changed env variable name to "boot_auth" V3->V4:
- removed unnecessary zynqmp_verify_auth function V4->V5:
- added newline to zynqmp_mmio_read error msg V5->V6:
- changed printf statements to debug
- simplied status check in if statement
--- arch/arm/mach-zynqmp/zynqmp.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
arch/arm/mach-zynqmp/zynqmp.c +33 -1
@@ -362,6 +362,35 @@ static int do_zynqmp_reboot(struct cmd_tbl *cmdtp, int flag,return CMD_RET_SUCCESS ; } +static int do_zynqmp_verify_auth (struct cmd_tbl *cmdtp,int flag, +int argc,char *const argv[]) +{ +u32 status; +int ret; + + ret =zynqmp_mmio_read ((ulong)&csu_base->status, &status); +if (ret) { +printf ("Can't obtain boot auth state\n" ); +return CMD_RET_FAILURE ; + } + +if (status &ZYNQMP_CSU_STATUS_AUTHENTICATED ) { +debug ("Boot is authenticated\n" ); + + ret =env_set ("boot_auth" ,"1" ); +if (ret) +return CMD_RET_FAILURE ; + }else { +debug ("Boot is not authenticated\n" ); + + ret =env_set ("boot_auth" ,"0" ); +if (ret) +return CMD_RET_FAILURE ; + } + +return CMD_RET_SUCCESS ; +} +static struct cmd_tbl cmd_zynqmp_sub[] = {U_BOOT_CMD_MKENT (secure,5 ,0 , do_zynqmp_verify_secure,"" ,"" ),U_BOOT_CMD_MKENT (pmufw,4 ,0 , do_zynqmp_pmufw,"" ,"" ),
@@ -371,6 +400,7 @@ static struct cmd_tbl cmd_zynqmp_sub[] = {U_BOOT_CMD_MKENT (rsa,7 ,0 , do_zynqmp_rsa,"" ,"" ),U_BOOT_CMD_MKENT (sha3,5 ,0 , do_zynqmp_sha3,"" ,"" ),U_BOOT_CMD_MKENT (reboot,3 ,0 , do_zynqmp_reboot,"" ,"" ), +U_BOOT_CMD_MKENT (verify_auth,2 ,0 , do_zynqmp_verify_auth,"" ,"" ), #ifdef CONFIG_DEFINE_TCM_OCM_MMAP U_BOOT_CMD_MKENT(tcminit, 3, 0, do_zynqmp_tcm_init, "", ""), #endif
@@ -446,10 +476,12 @@ U_BOOT_LONGHELP(zynqmp," 48 bytes hash value into srcaddr\n" " Optional key_addr can be specified for saving sha3 hash value\n" " Note: srcaddr/srclen should not be 0\n" +"zynqmp verify_auth - verifies if boot.bin was authenticated\n" +" Returns boot_auth : 0 not authenticated, 1 authenticated\n" );U_BOOT_CMD ( - zynqmp,9 ,1 , do_zynqmp, + zynqmp,10 ,1 , do_zynqmp,"ZynqMP sub-system" , zynqmp_help_text );
Signature · 1 line
2.25.1
Michal Simek
maintainerQuoted 73 lines · Neal Frager
Add command for checking if boot was authenticated.
Signed-off-by Igor Opaniuk <[email protected]>Signed-off-by Neal Frager <[email protected]>Reviewed-by Tomas Melin <[email protected]>---
V1->V2:
- extended zynqmp command withverify_authsub-command
- changed return value, so it can be used with scriptsV2->V3:
- separated status and ret values
- replaced BIT(0) withZYNQMP_CSU_STATUS_AUTHENTICATED
- changed env variable name to "boot_auth"V3->V4:
- removed unnecessaryzynqmp_verify_authfunctionV4->V5:
- added newline tozynqmp_mmio_readerror msgV5->V6:
- changed printf statements to debug
- simplied status check in if statement--- arch/arm/mach-zynqmp/zynqmp.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)arch/arm/mach-zynqmp/zynqmp.c +30
-0@@ -362,6 +362,35 @@ static int do_zynqmp_reboot(struct cmd_tbl *cmdtp, int flag,return CMD_RET_SUCCESS ; } +static int do_zynqmp_verify_auth (struct cmd_tbl *cmdtp,int flag, +int argc,char *const argv[]) +{ +u32 status; +int ret; + + ret =zynqmp_mmio_read ((ulong)&csu_base->status, &status); +if (ret) { +printf ("Can't obtain boot auth state\n" ); +return CMD_RET_FAILURE ; + } + +if (status &ZYNQMP_CSU_STATUS_AUTHENTICATED ) { +debug ("Boot is authenticated\n" ); + + ret =env_set ("boot_auth" ,"1" ); +if (ret) +return CMD_RET_FAILURE ; + }else { +debug ("Boot is not authenticated\n" ); + + ret =env_set ("boot_auth" ,"0" ); +if (ret) +return CMD_RET_FAILURE ; + } + +return CMD_RET_SUCCESS ; +} +static struct cmd_tbl cmd_zynqmp_sub[] = {U_BOOT_CMD_MKENT (secure,5 ,0 , do_zynqmp_verify_secure,"" ,"" ),U_BOOT_CMD_MKENT (pmufw,4 ,0 , do_zynqmp_pmufw,"" ,"" ),@@ -371,6 +400,7 @@ static struct cmd_tbl cmd_zynqmp_sub[] = {U_BOOT_CMD_MKENT (rsa,7 ,0 , do_zynqmp_rsa,"" ,"" ),U_BOOT_CMD_MKENT (sha3,5 ,0 , do_zynqmp_sha3,"" ,"" ),U_BOOT_CMD_MKENT (reboot,3 ,0 , do_zynqmp_reboot,"" ,"" ), +U_BOOT_CMD_MKENT (verify_auth,2 ,0 , do_zynqmp_verify_auth,"" ,"" ), #ifdef CONFIG_DEFINE_TCM_OCM_MMAP U_BOOT_CMD_MKENT(tcminit, 3, 0, do_zynqmp_tcm_init, "", ""), #endif
arch/arm/mach-zynqmp/zynqmp.c U_BOOT_LONGHELP(zynqmp, · line 480
Quoted 5 lines
arch/arm/mach-zynqmp/zynqmp.c +2
-0@@ -446,10 +476,12 @@ U_BOOT_LONGHELP(zynqmp," 48 bytes hash value into srcaddr\n" " Optional key_addr can be specified for saving sha3 hash value\n" " Note: srcaddr/srclen should not be 0\n" +"zynqmp verify_auth - verifies if boot.bin was authenticated\n" +" Returns boot_auth : 0 not authenticated, 1 authenticated\n"
This is not aligned with implementation above.
arch/arm/mach-zynqmp/zynqmp.c U_BOOT_LONGHELP(zynqmp, · line 484
Quoted 5 lines
arch/arm/mach-zynqmp/zynqmp.c +1
-1); U_BOOT_CMD( - zynqmp, 9, 1, do_zynqmp, + zynqmp, 10, 1, do_zynqmp,
This is maximum amount of arguments not number of commands
arch/arm/mach-zynqmp/zynqmp.c U_BOOT_LONGHELP(zynqmp, · line 487
Quoted 3 lines
arch/arm/mach-zynqmp/zynqmp.c +0
-0"ZynqMP sub-system" , zynqmp_help_text );
Thanks,
Michal