EFI_ACPI_6_3_GTDT_GT_BLOCK_TIMER_STRUCTURE * GtBlockFrame;\r
CM_ARM_GTBLOCK_TIMER_FRAME_INFO * GTBlockTimerFrameList;\r
UINT32 GTBlockTimerFrameCount;\r
+ UINTN Length;\r
\r
ASSERT (Gtdt != NULL);\r
ASSERT (GTBlockInfo != NULL);\r
return Status;\r
}\r
\r
- GTBlock->Type = EFI_ACPI_6_3_GTDT_GT_BLOCK;\r
- GTBlock->Length = sizeof (EFI_ACPI_6_3_GTDT_GT_BLOCK_STRUCTURE) +\r
- (sizeof (EFI_ACPI_6_3_GTDT_GT_BLOCK_TIMER_STRUCTURE) *\r
- GTBlockInfo->GTBlockTimerFrameCount);\r
+ Length = sizeof (EFI_ACPI_6_3_GTDT_GT_BLOCK_STRUCTURE) +\r
+ (sizeof (EFI_ACPI_6_3_GTDT_GT_BLOCK_TIMER_STRUCTURE) *\r
+ GTBlockInfo->GTBlockTimerFrameCount);\r
\r
+ // Check that the length of the GT block does not\r
+ // exceed MAX_UINT16\r
+ if (Length > MAX_UINT16) {\r
+ Status = EFI_INVALID_PARAMETER;\r
+ DEBUG ((\r
+ DEBUG_ERROR,\r
+ "ERROR: GTDT: Too many GT Frames. Count = %d. " \\r
+ "Maximum supported GT Block size exceeded. " \\r
+ "Status = %r\n",\r
+ GTBlockInfo->GTBlockTimerFrameCount,\r
+ Status\r
+ ));\r
+ return Status;\r
+ }\r
+\r
+ GTBlock->Type = EFI_ACPI_6_3_GTDT_GT_BLOCK;\r
+ GTBlock->Length = (UINT16)Length;\r
GTBlock->Reserved = EFI_ACPI_RESERVED_BYTE;\r
GTBlock->CntCtlBase = GTBlockInfo->GTBlockPhysicalAddress;\r
GTBlock->GTBlockTimerCount = GTBlockInfo->GTBlockTimerFrameCount;\r