summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrakruthi Deepak Heragu <pheragu@codeaurora.org>2019-08-19 17:13:36 -0700
committerAníbal Limón <anibal.limon@linaro.org>2019-12-09 18:41:31 -0600
commitfe1eaeb15947e1fec986acbe80f29debbb650efb (patch)
tree007d5ece6b6b8cdde127e76493391c68714d951e
parent9fe5e6019c5adde33178e55d1b28300d65522827 (diff)
edk2: QcomModulePkg: Calculate image offsets based on Header Version
[Cherry-picked from https://source.codeaurora.org/quic/la/abl/tianocore/edk2/commit/?id=221dc1de0c97e4eb91262e67539908fb0b0f14e3] When we disable avb feature, calculate the size of the data needed to be read from the flash completely. Add suport to read the dtb.img which is present at the end of the boot image in case of the header version 2. This change is needed because up until header version 2, dtbs were appended to the kernel and in kernel size, dtbs were included. Change-Id: Iad055672e473951fc92c4138c98555e67875aeb0 Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
-rw-r--r--QcomModulePkg/Library/BootLib/BootLinux.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/QcomModulePkg/Library/BootLib/BootLinux.c b/QcomModulePkg/Library/BootLib/BootLinux.c
index 61feed46d9..6492e91c1f 100644
--- a/QcomModulePkg/Library/BootLib/BootLinux.c
+++ b/QcomModulePkg/Library/BootLib/BootLinux.c
@@ -1309,6 +1309,7 @@ CheckImageHeader (VOID *ImageHdrBuffer,
BOOLEAN BootIntoRecovery)
{
EFI_STATUS Status = EFI_SUCCESS;
+ struct boot_img_hdr_v2 *BootImgHdrV2;
UINT32 KernelSizeActual = 0;
UINT32 DtSizeActual = 0;
UINT32 RamdiskSizeActual = 0;
@@ -1318,6 +1319,7 @@ CheckImageHeader (VOID *ImageHdrBuffer,
UINT32 KernelSize = 0;
UINT32 RamdiskSize = 0;
UINT32 SecondSize = 0;
+ UINT32 DtSize = 0;
UINT32 tempImgSize = 0;
if (CompareMem ((void *)((boot_img_hdr *)(ImageHdrBuffer))->magic, BOOT_MAGIC,
@@ -1358,6 +1360,21 @@ CheckImageHeader (VOID *ImageHdrBuffer,
return EFI_BAD_BUFFER_SIZE;
}
+ if (HeaderVersion == BOOT_HEADER_VERSION_TWO) {
+ BootImgHdrV2 = (struct boot_img_hdr_v2 *)
+ ((UINT64) ImageHdrBuffer +
+ BOOT_IMAGE_HEADER_V1_RECOVERY_DTBO_SIZE_OFFSET +
+ BOOT_IMAGE_HEADER_V2_OFFSET);
+ DtSize = BootImgHdrV2->dtb_size;
+
+ DtSizeActual = ROUND_TO_PAGE (DtSize, *PageSize - 1);
+ if (DtSize &&
+ !DtSizeActual) {
+ DEBUG ((EFI_D_ERROR, "Integer Overflow: dt Size = %u\n", DtSize));
+ return EFI_BAD_BUFFER_SIZE;
+ }
+ }
+
*ImageSizeActual = ADD_OF (*PageSize, KernelSizeActual);
if (!*ImageSizeActual) {
DEBUG ((EFI_D_ERROR, "Integer Overflow: Actual Kernel size = %u\n",