From: "Feng, YunhuaX" <yunhuax.feng@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Gao, Liming" <liming.gao@intel.com>,
"Feng, Bob C" <bob.c.feng@intel.com>
Subject: [edk2-staging][PATCH] BaseTools/FMMT: Fix FV add FFs issue
Date: Tue, 21 Apr 2020 03:21:21 +0000 [thread overview]
Message-ID: <BN8PR11MB3793526877471E1743501BCC8DD50@BN8PR11MB3793.namprd11.prod.outlook.com> (raw)
when Fv not include any FFS, will encounter not enough space to add issue.
Change-Id: Ie401f0edcf3f9b6bcae706a877b284e840f61fe9
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
BaseTools/Source/C/FMMT/FirmwareModuleManagement.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c
index 415096742d..59fda0b729 100644
--- a/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c
+++ b/BaseTools/Source/C/FMMT/FirmwareModuleManagement.c
@@ -477,10 +477,12 @@ AddFfs(UINT8 *FdBuffer, UINT32 ImageAddress, EFI_FIRMWARE_VOLUME_HEADER* Fv, EFI
UINTN Offset;
UINTN FfsSize;
EFI_STATUS Status;
EFI_FFS_FILE_HEADER2 *CurrentFile;
EFI_FFS_FILE_HEADER FreeHeader;
+ EFI_FIRMWARE_VOLUME_HEADER* hdr;
+ EFI_FIRMWARE_VOLUME_EXT_HEADER * FwVolExtHeader;
if (Fv->Attributes & EFI_FVB2_ERASE_POLARITY) {
memset(&FreeHeader, -1, sizeof(EFI_FFS_FILE_HEADER));
}
else {
@@ -499,10 +501,20 @@ AddFfs(UINT8 *FdBuffer, UINT32 ImageAddress, EFI_FIRMWARE_VOLUME_HEADER* Fv, EFI
//
FreeOffset = (UINTN)ALIGN_POINTER(Offset, 8);
}
Status = FvBufFindNextFile(FdBuffer + ImageAddress, &Offset, (VOID **)&CurrentFile);
if (Status == EFI_NOT_FOUND) {
+ if (FreeOffset == 0) {
+ hdr = ( EFI_FIRMWARE_VOLUME_HEADER*)((UINT8*)FdBuffer + ImageAddress);
+ if (hdr->ExtHeaderOffset != 0) {
+ FwVolExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *)((UINT8 *)hdr + hdr->ExtHeaderOffset);
+ FreeOffset = (UINTN)hdr->ExtHeaderOffset + FwVolExtHeader->ExtHeaderSize;
+ FreeOffset = (UINTN)ALIGN_POINTER(FreeOffset, 8);
+ } else {
+ FreeOffset = hdr->HeaderLength;
+ }
+ }
CurrentFile = NULL;
break;
}
else if (EFI_ERROR(Status)) {
return Status;
--
2.12.2.windows.2
reply other threads:[~2020-04-21 3:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BN8PR11MB3793526877471E1743501BCC8DD50@BN8PR11MB3793.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox