diff options
author | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-12-10 08:50:24 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-12-10 08:50:24 +0000 |
commit | 38837959db04259d0dbfc1ab906330961d5f9d8e (patch) | |
tree | bbfb2b1b9b1bcdbd29848d148dd7b1dd21a53e36 /MdeModulePkg/Core/Dxe/FwVolBlock | |
parent | 3d5c59747e661e3e45ac5e9f629de83b07f48fb9 (diff) | |
download | edk2-platforms-38837959db04259d0dbfc1ab906330961d5f9d8e.tar.xz |
Move sure FvImage buffer at its alignment when install FVB protocol on it.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4380 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Core/Dxe/FwVolBlock')
-rw-r--r-- | MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c b/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c index bdac781776..d507167594 100644 --- a/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c +++ b/MdeModulePkg/Core/Dxe/FwVolBlock/FwVolBlock.c @@ -413,8 +413,10 @@ Returns: UINTN BlockIndex;
UINTN BlockIndex2;
UINTN LinearOffset;
+ UINT32 FvAlignment;
EFI_FV_BLOCK_MAP_ENTRY *PtrBlockMapEntry;
-
+
+ FvAlignment = 0;
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)BaseAddress;
//
// Validate FV Header, if not as expected, return
@@ -423,6 +425,19 @@ Returns: return EFI_VOLUME_CORRUPTED;
}
//
+ // Get FvHeader alignment
+ //
+ FvAlignment = 1 << ((FwVolHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16);
+ if (FvAlignment < 8) {
+ FvAlignment = 8;
+ }
+ if ((UINTN)BaseAddress % FvAlignment != 0) {
+ //
+ // FvImage buffer is not at its required alignment.
+ //
+ return EFI_VOLUME_CORRUPTED;
+ }
+ //
// Allocate EFI_FW_VOL_BLOCK_DEVICE
//
FvbDev = CoreAllocateCopyPool (sizeof (EFI_FW_VOL_BLOCK_DEVICE), &mFwVolBlock);
|