summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrakruthi Deepak Heragu <pheragu@codeaurora.org>2019-08-19 17:13:36 -0700
committerAmit Pundir <amit.pundir@linaro.org>2021-06-24 10:41:30 +0530
commit93e515d9d2dec9628d91ac99f73275dd458b5e1b (patch)
tree7aa66d7e831eb68324e746803c983df891636f0f
parent143895e47c4e1af1c2558203a32af750e5743a8b (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 60394e3bc9..3e469c34a5 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",