From 81926317cd8eb13dd41f75d68aab56cd1e46c2c6 Mon Sep 17 00:00:00 2001 From: Rajkumar Ayyasamy Date: Mon, 27 Jan 2020 18:41:38 +0530 Subject: [PATCH] ipq6018: fix rootfs authentication Copy rootfs header and then append the rootfs image to it for authentication. Change-Id: I3e8184fa324e779eb5aa226f65df8e03401d027a Signed-off-by: Rajkumar Ayyasamy --- board/qca/arm/common/cmd_bootqca.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/board/qca/arm/common/cmd_bootqca.c b/board/qca/arm/common/cmd_bootqca.c index f4aab67dbd..4385a53273 100644 --- a/board/qca/arm/common/cmd_bootqca.c +++ b/board/qca/arm/common/cmd_bootqca.c @@ -331,6 +331,8 @@ static int copy_rootfs(unsigned int request, uint32_t size) printf("runcmd: %s\n", runcmd); if (run_command(runcmd, 0) != CMD_RET_SUCCESS) return CMD_RET_FAILURE; + + return 0; } #ifndef CONFIG_IPQ_ELF_AUTH @@ -388,6 +390,7 @@ static int authenticate_rootfs(unsigned int kernel_addr) static int authenticate_rootfs_elf(unsigned int rootfs_hdr) { int ret; + unsigned int request; image_info img_info; struct { unsigned long type; @@ -395,16 +398,21 @@ static int authenticate_rootfs_elf(unsigned int rootfs_hdr) unsigned long addr; } rootfs_img_info; - rootfs_img_info.addr = rootfs_hdr; + request = CONFIG_ROOTFS_LOAD_ADDR; + rootfs_img_info.addr = request; rootfs_img_info.type = SEC_AUTH_SW_ID; if (parse_elf_image_phdr(&img_info, rootfs_hdr)) return CMD_RET_FAILURE; - /* copy rootfs from the boot device */ - copy_rootfs(img_info.img_load_addr, img_info.img_size); + memcpy((void*)request, (void*)rootfs_hdr, img_info.img_offset); - rootfs_img_info.size = img_info.img_offset; + request += img_info.img_offset; + + /* copy rootfs from the boot device */ + copy_rootfs(request, img_info.img_size); + + rootfs_img_info.size = img_info.img_offset + img_info.img_size; ret = qca_scm_secure_authenticate(&rootfs_img_info, sizeof(rootfs_img_info)); if (ret) return CMD_RET_FAILURE;