UINTN BlockIndex;\r
UINTN BlockIndex2;\r
UINTN LinearOffset;\r
+ UINT32 FvAlignment;\r
EFI_FV_BLOCK_MAP_ENTRY *PtrBlockMapEntry;\r
-\r
+ \r
+ FvAlignment = 0;\r
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)BaseAddress;\r
//\r
// Validate FV Header, if not as expected, return\r
return EFI_VOLUME_CORRUPTED;\r
}\r
//\r
+ // Get FvHeader alignment\r
+ //\r
+ FvAlignment = 1 << ((FwVolHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);\r
+ if (FvAlignment < 8) {\r
+ FvAlignment = 8;\r
+ }\r
+ if ((UINTN)BaseAddress % FvAlignment != 0) {\r
+ //\r
+ // FvImage buffer is not at its required alignment.\r
+ //\r
+ return EFI_VOLUME_CORRUPTED;\r
+ }\r
+ //\r
// Allocate EFI_FW_VOL_BLOCK_DEVICE \r
//\r
FvbDev = CoreAllocateCopyPool (sizeof (EFI_FW_VOL_BLOCK_DEVICE), &mFwVolBlock);\r